cancel
Showing results for 
Search instead for 
Did you mean: 

multiple headers and details

Former Member
0 Kudos

Dear all,

My souce file may get n number of header records and detail records.I don't know the exact count of how many headers and details may come in the file.

I need to group as the below file structure.

My file structure is

H(Header Detail record),D(Detail Record)

<ROOT>

H1

D1,D2,D3.......

H2

D1,D2,D3,...

...

...

...

...

HN

D1,D2...

</ROOT>

my question is can this structure handled in SAP PI?

in my present design,if the input is h1,h2,h3......hn,
                                                                d1,d2...........dn(d may belong to h1 or h2) it is working fine.

my requirement is h1 f1,a,b
                                  d1 f1,z,c,b( details belonging to h1)
                                  h2 f1,x,y
                                  d2 f1,z,c,b( details belonging to h1)

                                   hn f1

                          dn

ie need to segregate header and detail record.

if i place the file structure as

in my present design,if the input is h1,h2,h3......hn
     d1,d2...........dn(d may belong to h1 or h2) it is working fine.(ie i get all the records displayed in the payload)

if the file structure is h1 f1
                              d1 f1,a,d,f
                              h2 f1
                              d2 f1 ,q,w,e

                              hnf1

                              dnf1p,a,a,s

only the first record is displayed.ie with details of h1 and d1

if yes give me pointers on how to handle .

Thanks,

Srinivas

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184681
Active Contributor
0 Kudos

Hi,

I don't think you need a custom adapter/adapter module for that. Use the set of FCC parameters I provided you in your previous question (http://scn.sap.com/message/13151425#13151425), just change Recordset Sequence to Variable. This will produce the following XML for you for mapping:

<Root>
<Header>...</Header>
<Item>...</Item>
<Header>...</Header>
<Item>...</Item>
<Item>...</Item>
...
</Root>

So as a rule, all Headers and Items will be grouped under a single Root. You will simply have an XML reflection of your input file. Then you use a simple rule in the mapping, to place Items under respective Headers:

Item -> sortByKey(keyField*) -> SplitByValue(ValueChange) -> TargetItem
Item.Field1 -> sortByKey(keyField*) -> SplitByValue(ValueChange) -> TargetItem.Field1
...

* the keyField here is a field that you use to choose, whether some Item belongs to header1, header2 and so on. You might also need to sort the Headers themselves, so that their order matched the one used in Items.

Advantage, comparing to the solution described by Rajeev Gupta? You stay with 100% PI standard

Hope this helps,
Greg

Former Member
0 Kudos

to handle this req, you will need to create a custom J2EE adapter module and then use it in your sender file adapter. in your custom J2EE adapter module in process method, you will handle your req using loops on Header and Detail records and then you can group these based on your req.

http://scn.sap.com/docs/DOC-16014