Skip to Content
0
Jul 09, 2018 at 05:21 AM

How to remove tab from XML file format?

476 Views Last edit Jul 09, 2018 at 07:34 AM 2 rev

Hello Users,

While I am transferring data into XML file then we are getting <ITEM> tag by default in XML file. We didn't done any code for this tag. How we can remove this tag form the file?.

find attached Image and code. I have checked so many SCN threads for the same but i didn't get any proper solution. Please help me.

REPORT ztest_s8.
* PANTALLA SELECCION *
PARAMETERS: gk_ruta TYPE rlgrap-filename DEFAULT 'D:\file2.xml'.
* PANTALLA SELECCION *
data :it_xml_final TYPE TABLE OF blob.
TYPES :begin of analysiscatid,
       AnlCat_SHead TYPE char20,
       END OF analysiscatid.


TYPES : BEGIN OF analysiscode,
        accountcode  TYPE char15,
        analysisdimensionid  TYPE numc2,
        name  TYPE char50,
        status TYPE numc1,
        AnalysisCatid TYPE analysiscatid,
  END OF analysiscode.

TYPES : BEGIN OF payload,
        analysiscode TYPE analysiscode,
  END OF payload.

TYPES : BEGIN OF sunsystemscontext,
        businessunit TYPE char3,
END OF sunsystemscontext.



TYPES: BEGIN OF user ,

    name TYPE char3,

END OF user.



TYPES: BEGIN OF ssc,

    user TYPE user,

    sunsystemscontext TYPE sunsystemscontext,

    payload TYPE payload,

END OF ssc.
data : it_file type TABLE OF ssc.
Data : wa_file type ssc.
* START OF SELECTION *
START-OF-SELECTION.
  PERFORM llena_accesos.
  PERFORM descarga_xml.
END-OF-SELECTION.
* END OF SELECTION *
* FORM LLENA_ACCESOS *
FORM llena_accesos.
    CLEAR it_file.
  MOVE: 'PK1' TO wa_file-user-name,
                'KEV' TO wa_file-sunsystemscontext-businessunit,
                '99320042' TO wa_file-payload-analysiscode-accountcode,
                '05' TO wa_file-payload-analysiscode-analysisdimensionid,
                'SUNIL' TO wa_file-payload-analysiscode-name,
                '1' TO wa_file-payload-analysiscode-status,
                'T5_STAFFID/CRED' TO wa_file-payload-analysiscode-AnalysisCatid-AnlCat_SHead.
  APPEND wa_file to it_file.
  CLEAR : wa_file.
ENDFORM.                    "LLENA_ACCESOS
* FORM LLENA_ACCESOS *
* FORM DESCARGA_XML *
FORM descarga_xml.
  DATA: l_dom TYPE REF TO if_ixml_element,
                m_document TYPE REF TO if_ixml_document,
                g_ixml TYPE REF TO if_ixml,
                w_string TYPE xstring,
                w_size TYPE i,
                w_result TYPE i,
                w_line TYPE string,
                it_xml TYPE dcxmllines,
                s_xml LIKE LINE OF it_xml,
                w_rc LIKE sy-subrc.
  DATA: xml TYPE dcxmllines.
  DATA: rc TYPE sy-subrc,
  BEGIN OF xml_tab OCCURS 0,
                d LIKE LINE OF xml,
  END OF xml_tab.



 * CLASS cl_ixml DEFINITION LOAD.
 * g_ixml = cl_ixml=>create( ).
 * CHECK NOT g_ixml IS INITIAL.
 * m_document = g_ixml->create_document( ).
 * CHECK NOT m_document IS INITIAL.
  WRITE: / 'Converting DATA TO DOM 1:'.
 
 CALL TRANSFORMATION ('ID')
       SOURCE ssc = 'abc' "extractiondate = sy-datum
              obs = it_file
    RESULT XML it_xml_final.

*  CALL FUNCTION 'SDIXML_DATA_TO_DOM'
*    EXPORTING
*      name         = 'SSC'
*      dataobject   = it_file
*    IMPORTING
*      data_as_dom  = l_dom
*    CHANGING
*      document     = m_document
*    EXCEPTIONS
*      illegal_name = 1
*      OTHERS       = 2.
*  IF sy-subrc = 0.
*    WRITE 'Ok'.
*  ELSE.
*    WRITE: 'Err =',
*    sy-subrc.
*  ENDIF.
*  CHECK NOT l_dom IS INITIAL.
*  w_rc = m_document->append_child( new_child = l_dom ).
*  IF w_rc IS INITIAL.
*    WRITE 'Ok'.
*  ELSE.
*    WRITE: 'Err =',
*    w_rc.
*  ENDIF.


*  CALL FUNCTION 'SDIXML_DOM_TO_XML'
*    EXPORTING
*      document      = m_document
*    IMPORTING
*      xml_as_string = w_string
*      size          = w_size
*    TABLES
*      xml_as_table  = it_xml
*    EXCEPTIONS
*      no_document   = 1
*      OTHERS        = 2.

*  IF sy-subrc = 0.
*    WRITE 'Ok'.
*  ELSE.
*   WRITE: 'Err =',
*    sy-subrc.
*  ENDIF.
*  LOOP AT it_xml INTO xml_tab-d.

*    APPEND xml_tab.

*  ENDLOOP.

  CALL FUNCTION 'WS_DOWNLOAD'
    EXPORTING
      bin_filesize = w_size
      filename     = gk_ruta
      filetype     = 'BIN'
    TABLES
*      data_tab     = xml_tab
      data_tab     = it_xml_final
    EXCEPTIONS
      OTHERS       = 10.
  IF sy-subrc <> 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
  ENDIF.
ENDFORM.                    "DESCARGA_XML

* FORM DESCARGA_XML *

Attachments

item.jpg (90.2 kB)