Duplicating Document for OutArray in loop

I have a big structure to map from EDI (855) to IDOC (ORDERS05). It is quite strait forward. Except that the REF segment of the EDI should produce two IDOC segments of the same type ?!?

So I have an array of REF that should produce an array of IDOC segments. But for that IDOC array, each REF should produce TWO IDOC segments. Quite hard to explain. The REF segment contains a lot of info that needs to be split into two docs in the same array of documents with different values. Something like this:

1.EDI PO-----------------------------------------IDOC PO
2.—EDI line item--------------ARRAY---------------IDOC Line item
3.------REF (Part number + Price)-------ARRAY----------IDOC (REF) P/N
3.----------------------------- ------------------------IDOC (REF) Price

So in my loop I out-array on the IDOC REF to obtain my ARRAY of documents but I need two documents per REF EDI segment. Since I loop on the EDI REF, trying to map twice inside the loop is always overwriting the values of the first mapping and creating a one-to-one documents ratio.

I need a loop with a one-to-two document where the values in the two are different. Say two REF segments in EDI under one PO line item will produce four REF segments under the PO Line item of the IDOC. And of course they need be be in sequence.

I think you can duplicate the fields on the idoc side.

For example

EDI PO---------------------------IDOC PO
EDI line item—ARRAY------------IDOC Line Item
REF-------------ARRAY------------IDOC (REF 1)
|-----------------IDOC (REF 2)

Note that IDOC REF 1 and REF 2 are in the same array, and although they use the same fields, they appear twice in the same array.

EG. Say you wanted to map 1 REF segment with 2 E1EDP02 segments, the map would look like this (sorry about the drawing, I had to put the dashes in so the spacing would be kept, please ignore the dashes)

Record List (REF)------RecordList E1EDP02segs
|-Field2---------------| |-Field1
-----------------------| |-Field2
Then REF FIELD1 would map to both E1EDP02-FIELD1 fields.

You can use something like IDOC dummy segment to map the first segment then call appendToRecordlist and drop the dummy segment .sameway do for another IDOC segment.
Hope this will work.

Ajay Arora