05-03-2004 10:41 AM
Subject: Abap to XML
hi.
i try to use the command CALL TRANSFORMATION id in order to move abap data to XML file.
the XML file had been created without the data.
please advise me.
here is some of the code:
g_ixml = cl_ixml=>create( ).
g_stream_factory = g_ixml->create_stream_factory( ).
ABAP to XML
REFRESH restab.
resstream =
g_stream_factory->create_ostream_itable
( table = restab ).
CALL TRANSFORMATION id
SOURCE source = reserch_details_tbl
RESULT XML resstream.
05-04-2004 4:23 PM
hi ronan.
the coding seems to be correct. But what's the type of RESTAB? Only "flat" tables are supported, tables of STRING or tables of XSTRING are not supported.
05-05-2004 4:19 PM
Hi Stefan.
Can you explain me how do i use the type abap_trans_srcbind_tab?
i have an internal table with data,how do i transfer this table to that type?
05-11-2004 8:23 AM
I need a function to convert the content of two internal tables to an XML-File
the XML-file must be looks so:
the tags must be case-sensitive and i need three tags before the content of the internal tables is comming.
<Request>
<ProcessHRDataSAP>
<HumanResources>
content of the internal table1.....
</HumanResources>
<OrganizationStructure>
content of the internal table2.....
</OrganizationStructure>
</ProcessHRDataSAP>
</Request>
Hava anybody a answer for me?
I need this for Release 4.6...
Thanks
05-11-2004 10:24 AM
The following (untested) logic might get you on the right track. It's not exactly the structure you were after (I omitted the ProcessHRDataSAP node) but it should be enough to get you going.
==================
DATA:
lo_xml TYPE REF TO cl_xml_document,
lo_xml_child TYPE REF TO cl_xml_document,
lo_node TYPE REF TO if_ixml_node,
lv_name TYPE string,
lv_retcode TYPE sysubrc,
lt_data TYPE typ_xml_tab,
lv_data LIKE LINE OF lt_data.
* Create the XML document
CREATE OBJECT lo_xml.
lv_data = '<Request></Request>'.
APPEND lv_data TO lt_data.
CALL METHOD lo_xml->create_with_table
EXPORTING
table = lt_data
RECEIVING
retcode = lv_retcode.
IF lv_retcode NE 0.
* Unexpected return code...
ENDIF.
CALL METHOD lo_xml->get_first_node
RECEIVING
node = lo_node.
IF lo_node IS INITIAL.
* Unexpected outcome...
ENDIF.
CREATE OBJECT lo_xml_child.
CALL METHOD lo_xml_child->create_with_data
EXPORTING
name = 'HumanResources'
dataobject = << Human Resources Internal Table >>
RECEIVING
retcode = lv_retcode.
IF lv_retcode NE 0.
* Unexpected return code...
ENDIF.
CALL METHOD lo_xml->insert_document_as_child
EXPORTING
node = lo_node
document = lo_xml_child
RECEIVING
retcode = lv_retcode.
FREE lo_xml_child.
IF lv_retcode NE 0.
* Unexpected return code...
ENDIF.
CREATE OBJECT lo_xml_child.
CALL METHOD lo_xml_child->create_with_data
EXPORTING
name = 'OrganizationStructure'
dataobject = << Org Structure Internal Table >>
RECEIVING
retcode = lv_retcode.
CALL METHOD lo_xml->insert_document_as_child
EXPORTING
node = lo_node
document = lo_xml_child
RECEIVING
retcode = lv_retcode.
FREE lo_xml_child.
IF lv_retcode NE 0.
* Unexpected return code...
ENDIF.
* CALL METHOD lo_xml->export_to_file...