[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<f> TYPE ANY.

  DESCRIBE TABLE li_xml LINES lv_len1.

  LOOP AT li_xml ASSIGNING <f>.
    DESCRIBE FIELD <f> 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.

ENDFUNCTION.

Comments

Popular posts from this blog

SAP Overview (Indonesia)