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

Data Transfer with XML

Former Member
0 Likes
881

Hello SDN community,

i have a proglem regarding data transfer from an internal table into an xml document.

At first im trying to create an xml document with data from an internal table with one line which works correctly.


DATA: lt_xml TYPE TABLE hrp5122,
      wa_xml LIKE LINE OF lt_xml,
lo_xml TYPE REF TO cl_xml_document.

SELECT * FROM hrp5122 INTO CORRESPONDING FIELDS OF TABLE lt_xml WHERE pinst_guid = 'ABCDE'

LOOP AT lt_xml INTO wa_xml.
ENDLOOP.

CREATE OBJECT lo_xml.

CALL METHOD lo_xml->create_with_data
  EXPORTING
    name       = 'lt_xml'
    dataobject = lt_xml
  RECEIVING
    retcode    = lv_retcode.

The next step im trying to accomplish is to transfer that xml document back to another internal table.

The problem is that the new internal table should contain the xml code (with al its tags etc.).

The internal table should look like:

Row1 Row2

1 <?xml version="1.0" ?>

2 <Tag1>XXX</Tag1>

3 <Tag2>

4 <Tag3>XXX</Tag3>

5 </Tag2>

Looking forward to hearing some interesting answers

Regards

Danulf

Edited by: Danulf on Nov 17, 2011 10:52 AM

5 REPLIES 5
Read only

Former Member
0 Likes
804

Hi ,

You are trying to read the XML fiel not just the contents with in it.

Treat it just a file whose contents will be updated in an internal table.

Below code

data : file type string value 'filename.xml'.

OPEN DATA SET file l for INPUT IN TEXT MODE.

READ DATA TO WORk AREA.

APPEND WORK AREA to INTERNAl TABLE.

CLEAR WORk AREA.

CLOSE DATA SET file.

Hope It helps.

Read only

Former Member
0 Likes
804

Hi,

Have a llok on function module 'SDIXML_DDIC_TO_SCHEMA'. That's work with a DDIC, so if your itab is based on ddic, that should be ok.

Here's a doucment:

[http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0a575986-0601-0010-7cbe-f17b353c3a28?QuickLink=index&overridelayout=truehttp://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/0a575986-0601-0010-7cbe-f17b353c3a28?QuickLink=index&overridelayout=true]

you can also used FM 'SDIXML_DATA_TO_DOM' with 'SDIXML_DOM_TO_XML':

[http://www.erpgenie.com/sap/abap/code/abap27.htm|http://www.erpgenie.com/sap/abap/code/abap27.htm]

regards

Mickael

Read only

Former Member
0 Likes
804

Thx

Read only

0 Likes
804

Hi Danulf,

have you the answer of your question?

mickael

P.S: it's only for me, but also to other consultants who could have the same question in the future...

Read only

0 Likes
804

Hi Mickael,

a function module called 'BANK_API_PP_UT_DATA_TO_XML' was the answer for my question.

You can export an internal table to that FM which creates another itab with the XML code.

The problem is, that the created itab contains the code in only one single row, but in my case thats no problem.

Greets

Danulf