Application Development 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: 

How can if fix this ABAP to XML File (version 2)?

Former Member
0 Kudos
374

I sent this out the first time with far too much in it - so have cut down the size by 80% (not listing all of the fiels or code now.

I have a program that is doing ABAP to XML.

It is creating the file but some of the line entries are not formatted correctly and i do not know how to correct this.

It relates to 1) the Data line is not formatted the way I want; and 2) I do not know how to get rid of the "item" level is is creating (although I do not have "item" anywhere in my code).

I have listed below: 1) the way the file should look; 2) how my output looks (with notes on lines not the way I want them) and 3) my source code.

The file should look like this format:

<?xml version="1.0" encoding="UTF-8" ?>

- <Data xmlns="ServiceNet">

<BatchDateTime>2009-10-23T17:37:16</BatchDateTime>

- <Sale>

<StreamNumber>11000000</StreamNumber>

<UpdateActionCode>001</UpdateActionCode>

<CancelRequestDate />

but I get this:

<?xml version="1.0" encoding="utf-8" ?>

- <DATA>

- <item>

<LV_XMINS>xmlns="ServiceNet"</LV_XMINS>

<BATCHDATETIME>2009-11-12T10:29:29</BATCHDATETIME>

- <SALE>

<STREAMNUMBER>11000000</STREAMNUMBER>

<UPDATEACTIONCODE>115</UPDATEACTIONCODE>

<CANCELREQUESTDATE></CANCELREQUESTDATE>

Here a sample of my code:

DATA: BEGIN OF data OCCURS 0,

lv_xmins(18),

batchdatetime(19),

sale TYPE sale,

END OF data.

*populate data (only once per run)

data-lv_xmins = 'xmlns="DUMMY FIELD"'.

CONCATENATE sy-datum0(4) '-' sy-datum4(2) '-' sy-datum+6(2) 'T'

sy-uzeit0(2) ':' sy-uzeit2(2) ':' sy-uzeit+4(2)

INTO data-batchdatetime.

I call the FM SDIXML_DATA_TO_DOM' and then FM SDIXML_DOM_TO_XML.

Thanks.

Scott

4 REPLIES 4

karsten_korte
Participant
0 Kudos
166

Hi Scott,

in SDIXML_DATA_TO_DOM you can only pass the name of root node, so you can not assign attribute xmlns to root node (<Data xmlns="ServiceNet">) ... unless you build the xml document from scratch (without SDIXML_DATA_TO_DOM)

when using your sample code (without sale) I get xml without <item>

SDIXML_DATA_TO_DOM => SDIXML_DOM_TO_SCREEN::


<?xml version="1.0" encoding="utf-8" ?> 
- <Data>
  <LV_XMINS>xmlns="DUMMY FIELD</LV_XMINS> 
  <BATCHDATETIME>2009-11-13T12:05:58</BATCHDATETIME> 
  </Data>

???

regards, Karsten

0 Kudos
166

Karsten,

Thanks for pointer on only passing data from scratch without using the FM for SDIXML_DATA_TO_DOM .

I do not know how to build that from scratch - do you have an exmaple of code to show me - something simple.

As for the "item" - that has been resolved by passing the "Data" as a structure instead of a table to the FM SDIXML_DOM_TO_XML.

However i now only get the last entry for my table of products in the file - still working on how to resolve that.

Thanks - this is new area for me and expert in ABAP but novice at XML.

Scott

0 Kudos
166

Hi Scott,

here you'll find an example for creating a simple xml document:

use SDIXML_DOM_TO_SCREEN to display result at screen.

regards, Karsten

Former Member
0 Kudos
166

tHANKS TO ALL BUT WE ARE GOING ANOTHER DIRECTION WITH THIS FOR NOW.