[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.

Comments

Popular posts from this blog

SAP Overview (Indonesia)

[SAP ABAP] Convert LIST MEMORY to HTML