cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping to simplify structure of XML for File Adapter

Former Member
0 Kudos

Hi everybody

Here is a short question regarding the restructuring of an incoming IDoc message to an outgoing file.

The IDoc has the structure:

-IDoc

___-->Segment A1

______--> Segment B1

_________-->Segment C1

_________-->Segment C2

_________-->Segment C3

______--> Segment B2

_________-->Segment C4

_________-->Segment C5

_________-->Segment C6

___-->Segment D1

You can see that Segment A1 occurres only ones, but can have several child nodes B. Also Segment B can have several Child nodes.

To transfer this Idoc to a flat file we have to create a flat structure as I understood form several Threads. So the target should look like this:

-->root

_____-->Segment A1

_____-->Segment B1

_____-->Segment C1

_____-->Segment C2

_____-->Segment C3

_____-->Segment B2

_____-->Segment C4

_____-->Segment C5

_____-->Segment C6

_____-->Segment D1

If I map the structure just one by one, I loose the last segments of C and it look like:

-->root

_____-->Segment A1

_____-->Segment B1

_____-->Segment C1

_____-->Segment C2

_____-->Segment C3

_____-->Segment B2

_____-->Segment D1

How can I manage to get the needed target structure. I thought of using function <i>sortbykey</i> or <i>sort</i>, because I have values in C and B which are equal.

Any help?

Regards Oliver

Accepted Solutions (0)

Answers (3)

Answers (3)

stefan_grube
Active Contributor
0 Kudos

Hi Oliver,

Assuming that BX and CX are always the same tag name, this is not possible. You cannot create alternating tags with the graphical mapping tool.

As a workaround create a structure

root

--> row

_____-->Segment A1

--> row

_____-->Segment B1

_____-->Segment C1

_____-->Segment C2

_____-->Segment C3

--> row

_____-->Segment B2

_____-->Segment C4

_____-->Segment C5

_____-->Segment C6

--> row

_____-->Segment D1

and use the message transform bean for the conversion instead of the file adapter conversion.

https://websmp208.sap-ag.de/~sapdownload/011000358700001186732005E/HowToConveModuleJMS.pdf

Regards

Stefan

Former Member
0 Kudos

Hi Again on this topic

yes stefan, obviously we have to have a flat structure. Based on our frustration we tried to send our structure from an Idoc directly to the file adapter and the following intresting thing came out:

The Idoc structure looked like this

-->root

_____-->EDIC_040

_____-->Segment A1

________-->Segment B1

___________-->Segment C1

___________-->Segment C2

___________-->Segment C3

________-->Segment B2

___________-->Segment C4

___________-->Segment C5

___________-->Segment C6

_____-->Segment D1

After sending this structure to the file adapter and ignoring that the stucture is not flat one we got this in our file:

Segment A1Segment B1

Segment C1

Segment C2

Segment C3

Segment B2

Segment C4

Segment C5

Segment C6

Segment D1

We got nearly what we wanted, just that a new line is missed between Segment A1 and Segment B1. We tried to use 'nl' but it does not work. Any Ideas on how to get Segment B1 into the next row??

Regards Oliver

Former Member
0 Kudos

Hi,

I tried ur scenario and found out three solutions

1.right click on ur

_________-->Segment C1

_________-->Segment C2

_________-->Segment C3

_________-->Segment C4

_________-->Segment C5

_________-->Segment C6

and set ur context to segment A1(it will orginally be segment B1) and set the context of A1 to root.do the mapping.

And the other two are

1.use remove context as bhavesh suggested

2.Or use collapse context.

Former Member
0 Kudos

Hi Jithesch

Yes, using the described changes regarding the context ends up in the same way the remove contex does. But the final Problem left!! As in my answere to Bavesh described. The order of the fields is not yet correct??

Any help?

It would be great to solve this today, because I lost so much time on it.

Regards Oliver

bhavesh_kantilal
Active Contributor
0 Kudos

Hi Oliver,

I think a simple <b>REMOVE CONTEXT</b> should to the trick.

SEGMENT C4 --> Remove Context --> Segment C4.

Regards,

Bhavesh

Former Member
0 Kudos

Hi Bhavesh

Nice to hear from you again. He, thats it I think most of the points you already earned. You found my lost Segments C!!

But a small final task I have vor you. I now have the following structure by using the <i>Remove Context</i>:

-->root

_____-->Segment A1

_____-->Segment B1

_____>Segment B2 <-!!

_____-->Segment C1

_____-->Segment C2

_____-->Segment C3

_____-->Segment C4

_____-->Segment C5

_____-->Segment C6

_____-->Segment D1

But I need the B2, lets say as a Header line and to get this Structure:

-->root

_____-->Segment A1

_____-->Segment B1

_____-->Segment C1

_____-->Segment C2

_____-->Segment C3

_____>Segment B2 <-!!

_____-->Segment C4

_____-->Segment C5

_____-->Segment C6

_____-->Segment D1

Kind of <i>sort</i>???

Please have a look!!

Regards Oliver