# Looping on IDOCS and map it to external format

**URL:** <https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543>\
**Category:** Forum\
**Tags:** EDI\
**Created:** [February 1, 2005, 9:06pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543 "2005-02-01T21:06:33Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![roni](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@roni](https://techcommunity.softwareag.com/u/roni)\
**Post date:** [February 1, 2005, 9:06pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/1 "2005-02-01T21:06:33Z")

</div>

I had this question posted on the wrong thread. Since I did not get any replies, I realized that I need to post this question here.

I am sending DELVRY03 type IDOC from SAP 4.6C to third party as an XML document using Business Connector. My mapping is as follows  
LOOP over ‘DELVRY03/DELVRY03/IDOC’  
–MAP (Header fields from E1EDL20)  
–LOOP over ‘DELVRY03/DELVRY03/IDOC/E1EDL20’  
----MAP (E1EDL24 fields occurs many times - Items)  
----LOOP over ‘DELVRY03/DELVRY03/IDOC/E1EDL20/E1EDL24’  
------MAP (E1ADRM1 fields - Shipto )

My External format requires data in the following format  
DocHeader  
Request (Record List)  
–Shipto (address)  
–Items (Record List)

Simple example  
\<?xml\>  
\<als\>  
–\<docheader\>  
----\<request\>  
------\<shipto\>  
------\</shipto\>  
------\<orderline\>  
------\</orderline\>  
------\<orderline\>  
------\</orderline\>  
----\</request\>

So far I have not been successful in mapping two line items under one request. I am very new to BC. I have tried several combinations by mapping my segments into temporary record lists etc. without any success. I would appreciate if someone can point me in the right direction. This will help me to proceed further.

Thanks,

---

<div class="post-metadata">

**Author:** ![tylerpl](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tylerpl](https://techcommunity.softwareag.com/u/tylerpl)\
**Post date:** [February 1, 2005, 11:24pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/2 "2005-02-01T23:24:28Z")

</div>

The key to formatting a complex document is the correct use of AppendDocumentToList service. In your case you need to build two document list one of shipto the other of orderlines. Then at the end of your looping map the list to the request document. Below is a sample of the mapping I used to create a very complex xml document.

\<!–\>

- \<prcreport\_cnsm\>
  - \<prcreport\_cnsm\_row\>
    - \<cnsm\_categoryset\>
      - \<cnsm\_categoryset\_row\>
        - \<cnsm\_details\>
          - \<cnsm\_details\_row\>  
\</cnsm\_details\_row\>  
\</cnsm\_details\>  
\</cnsm\_categoryset\_row\>  
\</cnsm\_categoryset\>  
\</prcreport\_cnsm\_row\>  
\</prcreport\_cnsm\>

\<!–\>

5.14 SEQUENCE  
5.141 SEQUENCE  
5.1411 LOOP OVER ‘/StagingArea/CNSM\_ROW\_TAB’  
5.14111 MAP  
5.14112 MAP  
5.14113 LOOP OVER ‘/StagingArea/CNSM\_CATEGORYSET\_TAB’  
5.141131 MAP  
5.141132 MAP  
5.141133 MAP  
5.141134 BRANCH on  
5.1411341 %Pricing\_Catalog\_Class% = %StagingArea/CatalogClassHold% && %Product\_Line\_Cd% = %StagingArea/ProdLineCdHold%: SEQUENCE  
5.14113411 MAP  
5.14113412 MAP  
5.14113413 LOOP OVER ‘/XY\_WebPriceReport.Docs:Reply/Reply/ET\_Report’  
5.141134131 MAP  
5.141134132 BRANCH on  
5.1411341321 (%XY\_WebPriceReport.Docs:Reply/Reply/ET\_Report/ZZCTCL% = %StagingArea/CatalogClassHold% && %XY\_WebPriceReport.Docs:Reply/Reply/ET\_Report/ZZPRODLN% = %StagingArea/ProdLineCdHold% ) && (%XY\_WebPriceReport.Docs:Reply/Reply/ET\_Report/ZZCTGR% = %StagingArea/CatCdHold%): SEQUENCE  
5.14113413211 MAP  
5.14113413212 MAP  
5.14113413213 INVOKE appendToDocumentList  
5.14113413214 MAP  
5.14113414 BRANCH on ‘/AppendCnsmDetals’  
5.141134141 1: SEQUENCE  
5.1411341411 INVOKE appendToDocumentList  
5.1411341412 MAP  
5.1411341413 MAP  
5.1411341414 INVOKE appendToDocumentList  
5.1411341415 MAP  
5.14113415 MAP  
5.141135 BRANCH on ‘/AppendCatagorySet’  
5.1411351 1: SEQUENCE  
5.14113511 MAP  
5.14113512 INVOKE appendToDocumentList  
5.14113513 MAP

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [February 1, 2005, 11:27pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/3 "2005-02-01T23:27:03Z")

</div>

Roger,

Please try to do this way,

LOOP over ‘DELVRY03/DELVRY03/IDOC’  
–MAP (Header fields from E1EDL20)  
–LOOP over ‘DELVRY03/DELVRY03/IDOC/E1EDL20’  
inside this loop add a map step as shown below,  
-----MAP the segment/Individual fields to a temporary document (temp\_orderline) and finally using appendToRecordList (input map the temp\_orderline to fromItem and map orginal documentlist(Request/orderline) to toList and output toLust Request/OrderLine).Finally exit the loop you should see all the lineitems data extracted in Request document.

HTH,  
RMG.

---

<div class="post-metadata">

**Author:** ![roni](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@roni](https://techcommunity.softwareag.com/u/roni)\
**Post date:** [February 2, 2005, 1:44am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/4 "2005-02-02T01:44:48Z")

</div>

RMG and Page,  
Thanks for your reply.

I tried the approach suggested by RMG. May be I am missing something here. Do I need to specify the out-array in my loops. I did not specify anything in out-array.  
My flow looks like this.

transformFlatToHierarchy  
Loop over ‘/DELVRY03\_copy/DELVRY03/IDOC’  
–MAP (E1EDL20-VBELN to DocHeader-DocID) (Record Reference)  
–Loop over ‘/DELVRY03\_copy/DELVRY03/IDOC/E1EDL20’  
----MAP (E1EDL24 fields to tmp\_orderline)  
…(tmp\_orderline is a record structure)  
…(Required fields from E1EDL24 are mapped here to tmp\_orderline)  
----appendToRecordList (Note-at the same level as above MAP)  
recordToDocument

Details on appendToRecordList.  
Pipeline In Service-In Service-Out PipelineOut  
3rdparty toList --------\>3rdParty  
-ALS  
–Request  
—Orderline----\>toList  
…fromList  
tmp\_orderline—\>fromItem

My output looks like this.  
\<?xml\>  
\<als\>  
\<docheader\>  
\<clientid\>192761\</clientid\>  
\</docheader\>  
\<request\>  
\<orderline\>  
\</request\>  
\</als\>

As you can see it did not pick up any values from my IDOC. I have verified that IDOC has data in it since I see the values in pipeline.

RMG, I sincerely appreciate your help. Though this task should have been such a simple one, it has taken more time than I ever imagined. I cannot find any examples in any of the packages. In other postings, I have seen someone post about a package called wmEDIsample. Please let me know how we can import this package, if there is any such package.

Thanks,  
R

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [February 2, 2005, 1:54am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/5 "2005-02-02T01:54:33Z")

</div>

Roger,

WMEDISamples package comes with the EDI Adapter module,do you have EDI stuff installed on your SAP BC server?

And also make sure in the appendToRecordList you have to drop the temporary document(temp\_orderline) in the pipelineIn itself.

The append service is very critical in loops nested mapping but if it works then it makes life easier.  
HTH,  
RMG.

---

<div class="post-metadata">

**Author:** ![tylerpl](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tylerpl](https://techcommunity.softwareag.com/u/tylerpl)\
**Post date:** [February 2, 2005, 2:40am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/6 "2005-02-02T02:40:20Z")

</div>

I find it best to also have a tmp\_orderline\_List this will allow you to better see your list as it is being created. it should be named orderline and be a independent Doc list. I do my append like so;

ALS  
–Request  
—Orderline----\>toList  
—Orderline----\>fromList  
tmp\_orderline—\>fromItem

Once this list is completed in the standalone Orderline list map it to the target Orderline in your output document. This will allow you to place the code in its own service later and remove it form your main logic. You will be able to send in IDOC get out Doc List

Oh don’t feel bad if this was ease there would be examples all over the place.

Trace to just pass your loop and see what your results look like. As RMG said make sure you drop the tmp\_orderline as the last statement inside the loop.

---

<div class="post-metadata">

**Author:** ![roni](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@roni](https://techcommunity.softwareag.com/u/roni)\
**Post date:** [February 2, 2005, 6:03am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/7 "2005-02-02T06:03:56Z")

</div>

Page and RMG,  
We had not installed EDI Adapter module on our BC server. Once we installed the package I looked at examples in wmEDIsamples package. They are not helpful with respect what I am trying to do.

Page, I did not understand where you have asked me to append tmp\_orderline to fromItem. I tried this in appendToRecordList and I haven’t had any success.

In meantime, I tried a different approach and this seems to be working without using appendToRecordList. Please let me know if I should be using this approach or not.

Loop Over ‘/DELVRY03/DELVRY03/IDOC’  
–Loop Over ‘/DELVRY03/DELVRY03/IDOC/E1EDL20’  
----Loop Over ‘/DELVRY03/DELVRY03/IDOC/E1EDL20/E1ADRM1’  
------MAP (E1ADRM1 fields to tmp\_shipto record)  
Loop Over ‘/DELVRY03/DELVRY03/IDOC’  
–MAP (E1EDL20-VBELN to ALS-\>DocHeader-\>DocId)  
–Loop Over ‘/DELVRY03/DELVRY03/IDOC/E1EDL20’  
----MAP (E1EDL20 fields to ALS-\>Request-\>Orderline)  
MAP tmp\_shipto fields to ALS-\>Request-\>shipto  
recordToDocument

This is working fine. Is this approach correct?  
Here is the resulting XML document.  
\<?xml\>  
\<als\>  
\<docheader\>  
\<clientdocid\>0080162856\</clientdocid\>  
\</docheader\>  
\<request\>  
\<shipto\>  
\<companyname\>XXX, INC.\</companyname\>  
\<attnname\>Regular Shipments\</attnname\>  
\<street1\>1234 Main Street\</street1\>  
\<city\>Timbacto\</city\>  
\<state\>NJ\</state\>  
\<zipcode\>07011\</zipcode\>  
\<country\>US\</country\>  
\<phone\>800 123 4567\</phone\>  
\</shipto\>  
\<orderline\>  
\<clientline\>000010\</clientline\>  
\<itemid\>555551\</itemid\>  
\<warehouseid\>SFO\</warehouseid\>  
\<shipqty\>1.000\</shipqty\>  
\</orderline\>  
\<orderline\>  
\<clientline\>000020\</clientline\>  
\<itemid\>555552\</itemid\>  
\<warehouseid\>SFO\</warehouseid\>  
\<shipqty\>2.000\</shipqty\>  
\</orderline\>  
\</request\>  
\</als\>

Thanks,  
Roger

---

<div class="post-metadata">

**Author:** ![tylerpl](https://avatars.discourse-cdn.com/v4/letter/t/6f9a4e/32.png) [@tylerpl](https://techcommunity.softwareag.com/u/tylerpl)\
**Post date:** [February 2, 2005, 8:33am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/8 "2005-02-02T08:33:04Z")

</div>

This method will work fine as long as you do not have to use a transform service. Some transforms can not loop over a multiple document list.

Everyone that I have trained here has had the same problem and a picture is worth a 1000 words. There will come a time when you will have to use the append to list. When you get there maybe I can email you a screen shot of the way I use it.

---

<div class="post-metadata">

**Author:** ![roni](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@roni](https://techcommunity.softwareag.com/u/roni)\
**Post date:** [February 2, 2005, 7:58pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/9 "2005-02-02T19:58:49Z")

</div>

Page and RMG,  
Thanks for your help. Thanks to this forum which provides a way to find a solution to almost every problem.

It is nice to know that there are helpful people out there.

Roger

---

<div class="post-metadata">

**Author:** ![gupta\_r.17495](https://avatars.discourse-cdn.com/v4/letter/g/9fc348/32.png) [@gupta\_r.17495](https://techcommunity.softwareag.com/u/gupta_r.17495)\
**Post date:** [February 2, 2005, 10:16pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/10 "2005-02-02T22:16:34Z")

</div>

your welcome…

WmUsers are there to help out everyone…

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [May 18, 2005, 11:21am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/11 "2005-05-18T11:21:33Z")

</div>

Hi RMG,  
Thanks for ur reply . I changed the mapping and i’m getting the values in Xcbl format . One more issue is the data in Xcbl i’m getting as per mappings. but when there is more than one line item in an order i’m not getting the data correctly i.e . for the first item the data is populated properly . But for the next items i’m getting the repeated values. I have attached the Xcbl file . Can u please guide me . Shall i upload the mapping steps in the flow service.

Thanks in advance,  
shankar

ORDERSxCBL.xml (9.2 k)

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [May 19, 2005, 10:42am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/12 "2005-05-19T10:42:57Z")

</div>

![](http://www.wmusers.com/wmusers/icons/attachment_icon.gif)  
[ORDERSxCBL.xml](http://www.wmusers.com/wmusers/messages/117/ORDERSxCBL-49912.unk) (9.2 k)

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [May 19, 2005, 10:47am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/13 "2005-05-19T10:47:13Z")

</div>

Hi RMG/All  
The item number and item description is not changing for different line items and if we see the pricing values, those are same for all the line items.RMG will u please help me what i have to do.  
Thanks in advance  
Shankar

---

<div class="post-metadata">

**Author:** ![somasekhark](https://avatars.discourse-cdn.com/v4/letter/s/90db22/32.png) [@somasekhark](https://techcommunity.softwareag.com/u/somasekhark)\
**Post date:** [May 19, 2005, 11:00am UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/14 "2005-05-19T11:00:10Z")

</div>

Hi Shankar,

May be the initial values are being overridden by the last values.  
When you are looping over the line items, keep the ItemIdentifiers in the OutArray Property of that loop.  
Then that way your values will not be overridden and also drop the value from which you are mapping ItemDecription inside the loop.

Thanks,  
Somu

---

<div class="post-metadata">

**Author:** ![Guest](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/guest/32/75_2.png) [@Guest](https://techcommunity.softwareag.com/u/Guest)\
**Post date:** [June 10, 2005, 2:20pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/15 "2005-06-10T14:20:52Z")

</div>

Hi Sekhar,  
It worked for me and thanks a lot for ur help.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 3:05pm UTC](https://techcommunity.softwareag.com/t/looping-on-idocs-and-map-it-to-external-format/108543/16 "2021-04-02T15:05:16Z")

</div>

Closed on April 2, 2021, 3:05pm UTC


