Friday, October 13, 2017

[SAP ABAP] Convert LIST MEMORY to HTML

FUNCTION zfmarein_list_to_html.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  TABLES
*"      T_HTML STRUCTURE  W3HTML
*"----------------------------------------------------------------------


  DATA li_tmp LIKE STANDARD TABLE OF abaplist WITH HEADER LINE,
           li_html LIKE STANDARD TABLE OF w3html WITH HEADER LINE.

  REFRESH t_html.

*  "Get Report Memory
  CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
      listobject li_tmp
    EXCEPTIONS
      not_found  4
      OTHERS     8.

  CALL FUNCTION 'WRITE_LIST'
    TABLES
      listobject li_tmp
    EXCEPTIONS
      empty_list 1
      OTHERS     2.

  CALL FUNCTION 'WWW_LIST_TO_HTML'
    TABLES
      html   li_html
    EXCEPTIONS
      OTHERS 1.

  t_html[] li_html[].



ENDFUNCTION.

[SAP ABAP] Remove XML BUGS

FUNCTION zfm_mmods_remove_xml_bugs .
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  CHANGING
*"     REFERENCE(C_XML) TYPE  STRING
*"----------------------------------------------------------------------


  TYPES BEGIN OF ty_data,
            line TYPE string,
          END OF ty_data.
  DATA li_data TYPE STANDARD TABLE OF ty_data WITH HEADER LINE.

  DATA lv_tmp TYPE string,
         lv_cell1 TYPE string,
         lv_cell2 TYPE string,
         lv_cell3 TYPE string,
         lv_cell_header TYPE string,
         lv_cell_top TYPE string,
         lv_cell_last TYPE string,
         lv_cell_replace TYPE string,
         lv_len1 TYPE i.

  "Header
  lv_cell_header ''.
  CONCATENATE lv_cell_header cl_abap_char_utilities=>cr_lf INTO lv_cell_replace.
  REPLACE lv_cell_header IN c_xml  WITH lv_cell_replace.

  "Top
  SPLIT c_xml AT '>' INTO lv_tmp lv_cell_top.
  SPLIT lv_cell_top AT '>' INTO lv_cell_top lv_tmp.
  CONCATENATE lv_cell_top '>' INTO lv_cell_top.
  CONCATENATE lv_cell_top cl_abap_char_utilities=>cr_lf INTO lv_cell_replace.
  REPLACE lv_cell_top IN c_xml  WITH lv_cell_replace.

  "Clear Last from note
  lv_len1 STRLENlv_cell_top 3.
  lv_cell_last lv_cell_top+3(lv_len1).
  CONCATENATE '</' lv_cell_last INTO lv_cell_last.
  CONCATENATE lv_cell_last lv_cell_last INTO lv_cell_last.

  SPLIT c_xml AT lv_cell_last INTO lv_cell1 lv_cell2.

  CLEAR c_xml.
  CONCATENATE lv_cell1 lv_cell_last INTO c_xml.


ENDFUNCTION.

[SAP ABAP] Convert ITAB to STRING

 FUNCTION ZFM_MMODS_ITAB_STRING.

*"----------------------------------------------------------------------

*"*"Local Interface:

*"  EXPORTING

*"     REFERENCE(E_STRING) TYPE  STRING

*"  TABLES

*"      T_ITAB TYPE  TABLE

*"----------------------------------------------------------------------



  FIELD-SYMBOLS <data>  TYPE ANY.
  DATA : lv_str TYPE string,
         lv_len TYPE i,
         j TYPE i,
         lv_blanks TYPE string.

  CLEAR E_STRING.
  LOOP AT T_ITAB ASSIGNING <data>.
    EXIT.
  ENDLOOP.
  IF sy-subrc EQ 0.

    DESCRIBE FIELD  LENGTH lv_len IN CHARACTER MODE.
    SHIFT lv_blanks RIGHT BY lv_len PLACES.

    LOOP AT T_ITAB ASSIGNING <data>.
      lv_str = <data>.
      j = lv_len - STRLEN( lv_str ).
      IF j EQ 0.
        CONCATENATE E_STRING lv_str INTO E_STRING.
      ELSE.
        CONCATENATE E_STRING lv_str lv_blanks(j) INTO E_STRING.
      ENDIF.
    ENDLOOP.

  ENDIF.


ENDFUNCTION.

[SAP ABAP] Convert ITAB to XML

 FUNCTION zfm_mmods_itab_xml.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_ITAB) TYPE  TABLE
*"  EXPORTING
*"     VALUE(E_XML) TYPE  STRING
*"----------------------------------------------------------------------


  DATA : lv_return TYPE string,
         lv_len1 TYPE i,
         lv_len2 TYPE i.

  DATA : li_xml TYPE  truxs_xml_table.

  CALL FUNCTION 'SAP_CONVERT_TO_XML_FORMAT'
    TABLES
      i_tab_sap_data       = i_itab
    CHANGING
      i_tab_converted_data = li_xml.

*--------------------------------------------------------------------*
  FIELD-SYMBOLS <data>  TYPE ANY.

  DESCRIBE TABLE li_xml LINES lv_len1.

  LOOP AT li_xml ASSIGNING <data>.
    DESCRIBE FIELD  LENGTH lv_len2 IN BYTE MODE.
    EXIT.
  ENDLOOP.

  lv_len1 = lv_len1 * lv_len2.
*--------------------------------------------------------------------*

  CALL FUNCTION 'SCMS_BINARY_TO_STRING'
    EXPORTING
      input_length = lv_len1
    IMPORTING
      text_buffer  = e_xml
    TABLES
      binary_tab   = li_xml.

*--------------------------------------------------------------------*
*
*--------------------------------------------------------------------*
*  CALL FUNCTION 'SF_SPECIALCHAR_DELETE'
*    EXPORTING
*      with_specialchar    = e_xml
*    IMPORTING
*      without_specialchar = e_xml.

  CALL FUNCTION 'ZFM_MMODS_REMOVE_XML_BUGS'
    CHANGING
      c_xml = e_xml.


ENDFUNCTION.

[SAP ABAP] Get PO Tax

FUNCTION zfm_mmods_po_get_tax.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(I_EBELN) LIKE  EKPO-EBELN
*"     REFERENCE(I_EBELP) LIKE  EKPO-EBELP
*"  EXPORTING
*"     REFERENCE(E_TAXCOM) TYPE  TAXCOM
*"  TABLES
*"      T_KOMV STRUCTURE  KOMV
*"----------------------------------------------------------------------
  DATA lw_ekko LIKE ekko,
         lw_ekpo LIKE ekpo,
         lw_lfa1 LIKE lfa1.

  SELECT SINGLE INTO lw_ekko
  FROM ekko
  WHERE ebeln i_ebeln.

  IF lw_ekko IS NOT INITIAL.
    SELECT SINGLE INTO lw_ekpo
    FROM ekpo
    WHERE ebeln i_ebeln AND
          ebelp i_ebelp.

    SELECT SINGLE INTO lw_lfa1
    FROM lfa1
    WHERE lifnr lw_ekko-lifnr.
  ELSE.
    EXIT.
  ENDIF.

  CHECK lw_ekpo IS NOT INITIAL.

  DATAli_tax TYPE j_1b_taxcom ,
        li_taxcom  TYPE taxcom ,
        l_wa_t001    TYPE t001,
*        e_taxcom  TYPE taxcom ,
        l_wa_komv TYPE komv ,
        l_gv_amount TYPE netwr ,
        l_unitprice TYPE netwr,
        l_ipiamount TYPE netwr,
        l_total_ipi TYPE netwr,
        l_total  TYPE netwr  ,
        l_taxamount TYPE netwr.

  SELECT SINGLE FROM t001
                  INTO l_wa_t001
                  WHERE bukrs EQ lw_ekko-bukrs.

* Fill tax fields relevant for PO
  li_tax-txreg_sf lw_lfa1-txjcd.
  li_tax-txreg_st lw_ekpo-txjcd.
  li_tax-taxbs    lw_lfa1-taxbs.
  li_tax-ipisp    lw_lfa1-ipisp.
  li_tax-brsch    lw_lfa1-brsch.
  li_tax-mtuse    lw_ekpo-j_1bmatuse.
  li_tax-mtorg    lw_ekpo-j_1bmatorg.
  li_tax-ownpr    lw_ekpo-j_1bownpro.
  li_tax-steuc    lw_ekpo-j_1bnbm.
  li_tax-matkl    lw_ekpo-matkl.
  li_tax-vrkme    lw_ekpo-meins.
  li_tax-mgame    lw_ekpo-menge.

* ISS Calculation with 2-level tax jurisdiction code
* To get the ISS Tax Condtions, need to pass the Following Parameters
  li_tax-loc_se lw_lfa1-txjcd.
  li_tax-loc_sr lw_lfa1-txjcd.
* if you don't pass the above parameters and if your PO has ISS Tax conditions,
* you don't see them in the Result


* Location of service provider = Tax Jur. Code of
* vendor:
  li_tax-loc_pr   lw_lfa1-txjcd.
* Location of service = Tax Jur. Code of delivery address

*Populate fields based on country
  CALL FUNCTION 'J_1B_SAVE_TAX_FIELDS'
    EXPORTING
      i_taxcom li_tax.

  CLEAR li_taxcom.
  li_taxcom-bukrs lw_ekpo-bukrs.
  li_taxcom-budat lw_ekko-bedat.
  li_taxcom-waers lw_ekko-waers.
  li_taxcom-kposn lw_ekpo-ebelp.
  li_taxcom-mwskz lw_ekpo-mwskz.
  li_taxcom-txjcd lw_ekpo-txjcd.
  li_taxcom-shkzg 'H'.
  li_taxcom-xmwst 'X'.
  IF lw_ekko-bstyp EQ 'F'.
    li_taxcom-wrbtr lw_ekpo-netwr.
  ELSE.
    li_taxcom-wrbtr lw_ekpo-zwert.
  ENDIF.
  li_taxcom-lifnr lw_ekko-lifnr.
  li_taxcom-land1 lw_ekko-lands"WIA
  li_taxcom-ekorg lw_ekko-ekorg.
  li_taxcom-hwaer l_wa_t001-waers.
  li_taxcom-llief lw_ekko-llief.
  li_taxcom-bldat lw_ekko-bedat.
  li_taxcom-matnr lw_ekpo-matnr"HTN-Abwicklung
  li_taxcom-werks lw_ekpo-werks.
  li_taxcom-bwtar lw_ekpo-bwtar.
  li_taxcom-matkl lw_ekpo-matkl.
  li_taxcom-meins lw_ekpo-meins.
  IF lw_ekko-bstyp EQ 'F'.
    li_taxcom-mglme lw_ekpo-menge.
  ELSE.
    IF lw_ekko-bstyp EQ 'K' AND lw_ekpo-abmng GT 0.
      li_taxcom-mglme lw_ekpo-abmng.
    ELSE.
      li_taxcom-mglme lw_ekpo-ktmng.
    ENDIF.
  ENDIF.
  IF li_taxcom-mglme EQ 0.
    li_taxcom-mglme 1000.
  ENDIF.
  li_taxcom-mtart lw_ekpo-mtart.

*Calculation of TAX

  CALL FUNCTION 'CALCULATE_TAX_ITEM'
    EXPORTING
      dialog       ' '
      display_only ' '
      i_taxcom     li_taxcom
    IMPORTING
      e_taxcom     e_taxcom
    TABLES
      t_xkomv      t_komv.




ENDFUNCTION.

Friday, June 30, 2017

[SAP] SAP Management History for MB52 (Full Documentation + Source Code)

[SAP] SAP Management History for MB52 (Full Documentation + Source Code) 





Deskripsi :
Program MB52_Management_History menyediakan fasilitas untuk me-manage data history dari inventory dashboard.
Purpose :
Tujuan pembuatan program MB52_Management_History adalah untuk mempermudah management data history dari inventory dashboard, membuat rekap report dan menampilkan report. Program memiliki beberapa fitur yang mempermudah user untuk menyimpan data history melalui fasilitas export serta memperoleh data realtime.

loading...
CHM File
>> Download <<

PDF File
>> Download <<

[SAP ABAP] Convert LIST MEMORY to HTML

FUNCTION  zfmarein_list_to_html . *"---------------------------------------------------------------------- *"*"Local Inte...