Posted: Mon Mar 17, 2008 12:38 am Post subject: Exampe XML data conversions
Code:
REPORT z_xml_example.
DATA: it_table LIKE dd02l OCCURS 0.
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.
START-OF-SELECTION.
SELECT * FROM dd02l INTO TABLE it_table
UP TO 10 ROWS.
END-OF-SELECTION.
********************************************
**** initialize iXML-Framework ****
********************************************
WRITE / 'initialiazing iXML:'.
CLASS cl_ixml DEFINITION LOAD.
g_ixml = cl_ixml=>create( ).
CHECK NOT g_ixml IS INITIAL.
WRITE: 'ok'.
********************************************
**** create DOM from SAP data ****
********************************************
WRITE / 'creating iXML doc:'.
m_document = g_ixml->create_document( ).
CHECK NOT m_document IS INITIAL.
WRITE: 'ok'.
WRITE / 'converting DATA TO DOM 1:'.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
name = 'IT_TABLE'
dataobject = it_table[]
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.
WRITE / 'appending DOM to iXML doc:'.
w_rc = m_document->append_child( new_child = l_dom ).
IF w_rc IS INITIAL.
WRITE 'ok'.
ELSE.
WRITE: 'Err =', w_rc.
ENDIF.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG. SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG. Every effort is made to ensure content integrity. Use information on this site at your own risk.