Need Help in mapping from IDoc to an XML format.

Hi I am mapping from IDoc to an XML format. The IDoc is a PO Documnet and has the following structure.

I need help in mapping OrderLineItems

Suppose, for line-num 1 the ordered-qty is 50 and we have to ship them in two ( first schedule date 30, next schedule 20 ) installments i.e., we have two schedules, schedule id 1, req-qty 30, schedule-dates schedule-date is 2013Jan01, and the remaining 20 items we have to ship them in next schedule i.e., schedule id 2, req-qty 20, schedule-date schedule-date is 2013Feb01.

And for line-num 2 say we have only one schedule and the ordered-qty is 30, schedule 1, req-qty 30 , schedule-dates schedule-date is 2013Jan01.

Sample data in Idoc is
PO
Sender
Receiver
Line-item
Line-item[0]
line-num 1
ordered-qty 50
Schedule
Schedule[0]
id 1
req-qty 30
Schedule-dates
Schedule-dates[0]
Schedule-date 2013Jan01
Schedule[1]
id 2
req-qty 20
Schedule-dates
Schedule-dates[0]
Schedule-date 2013Feb01
Line-item[1]
line-num 2
ordered-qty 30
Schedule
Schedule[0]
id 1
req-qty 30
Schedule-dates
Schedule-dates[0]
Schedule-date 2013Jan01

My requirement is:

For each shedule ship date a new OrderLineItem needs to be created. The line information will repeat each time. One OrderLineItem group should be sent per unique Line Number and Line Item Schedule.

The output should be.

1 30 2013Jan01 1 20 2013Feb01 2 30 2013Jan01

Any help is appriciated.

Hi,
It is just a logic that you need to write… Your req. is straight forward…

Loop over PO/line-item
----Loop over schedule
--------Loop over schedule-dates

In the first run, you have all information that you want at this point to map to target…

Line item Id - /PO/line-item[0]/line-num
Quantity - /PO/schedule[0]/req-qty
Date - /PO/schedule[0]/schedule-dates[0]/date-qualifier

Line item Id - /PO/line-item[0]/line-num
Quantity - /PO/schedule[0]/req-qty
Date - /PO/schedule[1]/schedule-dates[0]/date-qualifier

Do you face any problem in your mapping?

-Senthil

Hi Senthil,

Thanks for looking into this. Yes I am facing problem while mapping. I am getting the output like this which is not in an expected format.

1 [color=red]30 20[/color] [color=red]2013Jan01 2013Feb01 [/color] 2 30 2013Jan01

For each schedule date I need to create a new order line Item. Line Item information will repeat each time (for schedule ).

You need to have in the output array of Loop over schedule-dates.

Or you need to have a variable as indices that will be incremented whenevar a OrderLineItem is created.

Or you can have a single OrderLineItem doc mapped and then it can be appended to the output structure using

appendToDocumentList service as required.

Can you please share us the structure of XML so that you can have a look.

Yes these 3 options should cover the mapping ease for the req you mentioned →

You need to have in the output array of Loop over schedule-dates.

Or you need to have a variable as indices that will be incremented whenevar a OrderLineItem is created.

Or you can have a single OrderLineItem doc mapped and then it can be appended to the output structure using via appendToDocumentList with in the loop (make sure you drop the temp items here) a close debugging the pipeline is required on this before/ after step…

HTH,
RMG

Thanks all for your suggestions. I have used appendToDocumentList, now I am able to process the records. :slight_smile:

Glad to hear suggestions worked out well…