Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

XML in background

Former Member
0 Likes
1,071

Hi,

Can anybody tell me how to convert the data in internal table into xml and then generate that xml file on application server in background.

Regards,

venu.

6 REPLIES 6
Read only

Former Member
0 Likes
854

Take a look at this:

Read only

former_member156446
Active Contributor
0 Likes
854

Hi Venu

check this thread

Read only

Former Member
0 Likes
854

hi ,

Try this function module to convert internal data to XML

SWF_ABAP_TO_XML

Regards,

Prabhudas

Read only

Former Member
0 Likes
854

hi Venu,

Where i_final is the table with actual data.


PERFORM descarga_xml.




* 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 FUNCTION 'SDIXML_DATA_TO_DOM'
    EXPORTING
      name         = 'i_final'
      dataobject   = i_final[]
    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.
Open dataset.
move data from work area to application server.
close dataset.

ENDFORM.                    "DESCARGA_XML

Reardas,

Prabhudas

Read only

0 Likes
854

Hi prabhu,

Thanks for the code.

It was throing the unicode error like

For the statement

"TRANSFER f TO ..."

only character-type data objects are supported at the argument position

"f".

I am using ECC 6.20.

Read only

Former Member
0 Likes
854

Hi,

You can use FM:

SAP_CONVERT_TO_XML_FORMAT

And refer this:

Hope it helps

Regards

Mansi