Looping on IDOCS and map it to external format

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,

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

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.

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

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.

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.

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

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.

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

your welcome…

WmUsers are there to help out everyone…

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)


ORDERSxCBL.xml (9.2 k)

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

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

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