cancel
Showing results for 
Search instead for 
Did you mean: 

Sort incoming XML message

Former Member
0 Kudos

Hi

Is there a standard way in PI to sort the incoming XML message within the message mapping before doing the mapping itself?

The scenario would be an incoming Flat file with header and item data records, and we will be mapping it in PI to create IDOC messages based on the same Header segment. So for the same Header Data I would like to create a single IDOC. But the incoming file would be unsorted, so I would need to sort it first based on the header segment some way.

Ideally, we would like to do all of the mapping in the graphical mapping tool and not use a UDF.

Thanks

Edited by: MxG on Nov 20, 2008 5:04 PM

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

HI

Yes you can sort using standard Node function Sort.

Set the input data to same context and use Sort.

Thanks

Gaurav

Former Member
0 Kudos

I already tried Sort, but it doesnt work the way I want.

Say I have inbound XML as

<hdr1>

<hdr2>

<itm1>

<itm2>

<itm3>

it needs to be mapped to an IDOC as

<hdrsegment>

<itmsegment>

I mapped XML header data to IDOC after sorting, and that works fine. The issue comes on assigning the inbound XML Item data to IDOC Item segment. It is creating the correct Number of segments, but when assiging the fields to IDOC fields, it is using unsorted data ie the data as received, not the sorted one which I did for IDOC Node, and for Header fields.

What I really want is to sort the data once, and then use that in the mapping.

Former Member
0 Kudos

Hi

Try doing multimapping. Sort the data and pass it to one target then i think you will not face this. As once you sort data it is not holding that sorted values.

Thanks

Gaurav

Former Member
0 Kudos

Thats what I am trying but no luck so far. The Target is sorted for only the fields I am mapping after sort. Other fields are coming as is.

Former Member
0 Kudos

Hi

for sorting all the fields make them same context. Lets say parent node. then use sort for all.

Try doing one more thing. Apply sort on the parent node like MT_XX and check the result of it. then try again.

Without using Java it will not be easy

Thanks

Gaurav

Former Member
0 Kudos

Yep, using Java it can be done, but I would like to use that only as the last option.

I changed the context on the field I am sorting. That sorts fine and that target field is fine. The is with the other fields. other fields are being mapped as they came in the Input message ie unsorted.

The Target root node is fine when I see the Queue, but the individual fields are issue.

is there a way in file adaptor or some other way to just sort the input file based on a key field?

Edited by: MxG on Nov 20, 2008 9:54 PM

Former Member
0 Kudos

HI

Even if changing context is not helping then you need to use sort at all nodes to achieve sorting.

Standard adapter will not do sort on key basis. You need to develop modules to do it.

Other method is scripts. Before adapter picks up the file you can execute OS command basically unix script that can help on this.

Thanks

Gaurav

Former Member
0 Kudos

HI

Target node is fine?

Does it show the sorted fields under display queue?

Then the you need to set all context to target and it should be sorted.

Thanks

Gaurav

Former Member
0 Kudos

I meant Target Root node, when I view it using display queue, it has the data in sorted order. But the actual fields are still messed up.

I dont see the option to set context on target fields. Is there one?

Former Member
0 Kudos

HI

No we can set context to sender fields only. When it sorted the target parent node and all the source node context is set to parent node then it should be sorted values during mapping.

Check if you are missing something in this

Thanks

Gaurav

Answers (0)