cancel
Showing results for 
Search instead for 
Did you mean: 

Mapping to a multiple record structure

Former Member
0 Kudos

Hello, I'm working on a scenario that requires me to map source message (with 1 structure) to a target message with only 1 header record, multiple detail records and 1 trailer record at the end. All the records in the source message has to go to the target (file) as one message. The source and target message structure are similar to what is shown below:

-


Source Message:

<Source>

<Order>

<OrderNo>1</OrderNo>

<Description>This is Order 1</Description>

</Order>

<Order>

<OrderNo>2</OrderNo>

<Description>This is Order 2</Description>

</Order>

<Order>

<OrderNo>n</OrderNo>

<Description>This is Order n</Description>

</Order>

</Source>

-


Target (File) Record structure:

H This is the Header Record

D 1 This is Order 1

D 2 This is Order 2

D n This is Order n

T number of records n

-


I'm wondering how to map from the source structure to the target structure. Any input in this regard is appreciated.

If there is a blog detailing how this scenario has to be handled, please let me know.

Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Create ur Target Structure as

Record

-


Header 1..1 occ

-


Detail 0..unbounded

-


Trailer 1..1

While mapping,

1. Map constant(1) ot Header, as it need to occur only once

2. map order to Detail. (make sure all the records are in single context changes)

3. for count use sum function

Former Member
0 Kudos

Hi,

Use the target structure defined by Chandra Sekhar above.

For the Detail mapping, map Order node in the source structure to the Detail node of receiver. Either keep the context of Order node as Source or use a RemoveContext function to remove the context changes. This is create as many Detail records as there are order records in the source.

The fields under order would be mapped directly to the fields under Detail.

Regards

Answers (2)

Answers (2)

markangelo_dihiansan
Active Contributor
0 Kudos

Hello,

Target (File) Record structure:

H This is the Header Record

D 1 This is Order 1

D 2 This is Order 2

D n This is Order n

T number of records n

You still need to design your target XML similar to this:


<Target>
  <Header />
  <Details>
    <Order>
     <OrderNo>1</OrderNo>
     <Description>This is Order 1</Description>
    </Order>
    <Order>
     <OrderNo>n</OrderNo>
     <Description>This is Order n</Description>
    </Order>
  </Details>
  <Trailer />
</Target>

And then do the content conversion as stated by Baskar.

Hope this helps,

Mark

Edited by: Mark Dihiansan on Jun 29, 2011 4:11 AM

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Simple. You dont require complex structure.

Use File on the sender side and FIle (FCC) on the receiver side

Recordset Structure   H, 1, D, * , T,1
H.fieldNames
H.fieldSeparator   
H.endSeparator
D.fieldNames       orderNo, Description
D.fieldSeparator    ,
D.endSeparator    'nl'
T.fieldNames
T.fieldSeparator
T.endSeparator

http://help.sap.com/saphelp_nwpi71/helpdata/en/44/6830e67f2a6d12e10000000a1553f6/content.htm