cancel
Showing results for 
Search instead for 
Did you mean: 

Hierarchy message mapping: XML to IDOC

Former Member
0 Kudos

Hi All,

I am into a File to IDOC scenario.

I am refering to blog

and have successfully managed to convert my file into XML. However I am not able to map it successfully to IDOC structure( which should have been easy I guess).

My File structure is:

01, field01_1, field01_2
02, field02_1, field02_2,
03, field03_1, field03_2,
03, field03_1, field03_2,
02, field02_1, field02_2,
03, field03_1, field03_2,
03, field03_1, field03_2,
04, field04_1, field04_2

ns0:MT_DATA
HEADER  (01)
  |_Field1
  |_Field2
DATA_HEADER  (02)
  |_Field1
  |_Field2
  DATA_ITEM  (03)
        |_Field1
        |_Field1
TRAILER  (04)
  |_Field1
  |_Field1

My IDOC structure is same as shown above.All fields are getting populated except DATA_ITEM.(03)

I tried changing the Context of DATA_ITEM to MT_DATA instead of default DATA_HEADER, but no success!!

( The incoming XML structure after FCC does not have any hiearchy as mentioned in the weblog )

Where am I going wrong? Any help/advise greatly appreciated.

Many thanks

Shirin

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Shirin,

1) Use RemoveContext function to map DATA_HEADER.

2) Use SplitByValue function to map DATA_ITEM.

3) Use SplitByValue function to map all fields from DATA_ITEM.

Regards,

Rohit.

<removed_by_moderator>

Please read the "Rules of Engagement"

Edited by: Juan Reyes on Jul 29, 2008 12:47 PM

Former Member
0 Kudos

Hi Rohit,

I tried using SPLITBYVALUE value function. It indeed did show the items but all the items were bundled together in the very first header.

I have not used the 2 step approach as mentioned by Santosh so far as it involves Java programming for some of the functions. Since I am not good at Java I am avoiding this approach as I will need to modify Java code of the UDFs provided.

Any other help/suggestions are most welcome.

Many thanks

Shirin

Former Member
0 Kudos

Hi,

I have tried to explain this issue in a simpler Graphical way. Appreciate if you could guide me further.

Incoming file format:

HEADER
DATA_LINE
Item_line
item_line
item_line
DATA_LINE
Item_line
item_line
DATA_LINE
Item_line
item_line
item_line
TRAILER 

This structure needs to be populated into the following IDOC stsructure

HEADER
DATA_LINE
  |_Item_line
  |_Item_line
  |_Item_line
TRAILER

As seen from IDOC and File structure, I need to bundle the items under the data_line tag.

I have a field(ID) whcih has same vale in the Data_line and the Item_line. probably can be used to bundle the 2 things together.

Appreciate any help.

Many thanks

Shirin

Former Member
0 Kudos

Hi Shirin,

You can read the file only upto 2 levels so you can not have item_line as child of data_line when you are reading a file.

However you can convert flat structure to nested structure.

source xml:

<Header>

<field 1/>

<field 2/>

</Header>

<Data Header>

<field 1>

<field 2>

</Data Header>

<Item line1>

<field 1>

<field 2>

</Item line1>

<Item line2>

<field 1>

<field 2>

</Item line2>

<Trailor>

<field 1/>

<field 2/>

</Trailor>

Suppose field 1 of data header and item line has same value.

As the records are in sequence in the source file, the item lines with same value of field 1 will be in sequence.

field 1 ---> remove context --> split by value (value changed) --->target item line

<Header>

<field 1/>

<field 2/>

</Header>

<Data Header>

<field 1>

<field 2>

<Item line1>

<field 1>

<field 2>

</Item line1>

<Item line2>

<field 1>

<field 2>

</Item line2>

</Data Header>

<Trailor>

<field 1/>

<field 2/>

</Trailor>

Thanks,

Beena.

Answers (3)

Answers (3)

santhosh_kumarv
Active Contributor
0 Kudos

Hi,

Check this Blog for converting the flat structure to nested structure.

By Riyaz Sayyad

If you are not able to meet your requirement using graphical mapping then you should go for Java mapping.

Thanks

SaNv...

Former Member
0 Kudos

Hi Santosh,

I tried using the weblog of Riyaz, but it adds all the items to the last adata header and not to individual data headers.

I dont think this is an impossible scenario...but just a lil tricky for mr to crack.

Appreciate if you have any more ideas/suggestions.

Many thanks

Shirin

Former Member
0 Kudos

Hi Shirin,

Did you fix this problem? I am also facing same problem. Could please let me know, how did you solve this problem.

Your help greatly appreciated.

Thanks,

Hari

Former Member
0 Kudos

Hi Shirin,

Can you pls. upload screen shot of your Message mapping.

Also you can test you message mapping in IR using input payload. Click on test tab and with input payload you can check / test mapping.

Also check if you have mapped node "Data_Item" properly.

Hope this will help.

Nilesh

Former Member
0 Kudos

Hi,

You can not convert the flat file to xml where field 3 is child of field 2.

Refer this link:

[http://help.sap.com/saphelp_nw70/helpdata/en/2c/181077dd7d6b4ea6a8029b20bf7e55/content.htm]

Thanks,

Beena.