cancel
Showing results for 
Search instead for 
Did you mean: 

creating multiple idocs for the unique field in Record

Former Member
0 Kudos

Hi Experts,

We have 1 requirement in our new PI Interface :

We need to generate multiple idocs based on the value of this first field of the record and for the value change of the first field we need to create multiple IDocs .Our structure is like :

Record :

        VendorNo

        VendorType

        Posting Key

       AccountNo

       POSTING_DATE

       TRANSACTION_TYPE

So based on the change value for VendorNo , we need create multiple IDocs .So in this case :

123,PS,40,20105452,20160715,CN

123,PS,50,20103492,20160715,CN

456,PS,40,20105452,20160715,CN

456,PS,50,20103492,20160715,CN

789,PS,40,20105452,20160715,CN

789,PS,50,20103492,20160715,CN

In this case ,  3 IDocs will be created  and that i have achieved by the mapping :

VendorNo :-- Remove Context -- > SplitByValue(ValueChange) --- > IDoc

But the issue is that , for each idoc (if the same VendorNo comes multiple times) we need to create different segment for the different values .

Here it does not come .In the IDoc it took only the first value and it create only 1 IDoc segment .

So the posting is not done successfully in the functional end .

So can you please help me how can i solve this problem and generate multiple segments also in the same IDocs.

Thanks and Regards ,

Anik

Accepted Solutions (1)

Accepted Solutions (1)

former_member190293
Active Contributor
0 Kudos

Hi Anik!

The rest items mapping is the same.

Result:

In case your source records are not sorted by default, use Sort and SortByKey functions.

Regards, Evgeniy.

Answers (3)

Answers (3)

helmut_skolaut3
Active Participant
0 Kudos

Hi all,

this is the point where I am saying graphical mapping will become too complicated. I suggest here to use XSLT mapping and and use muenchian grouping 

https://en.wikipedia.org/wiki/XSLT/Muenchian_grouping

http://stackoverflow.com/questions/2146648/how-to-apply-group-by-on-xslt-elements

Here it would be absolutely easy to achieve what you want and the code is absolutely easy to understand and maintain.

Regards

  Helmut

turmoll
Active Contributor
0 Kudos

Hello,

Usually you can change context of source field but in your case you need to write UDF. As input you should have VendorNo (to add context change once values change) and other field that should be returned based on index.

I do recommend you to sort date before e.g. like

VendorNo :-- Remove Context -- > SORT -> SplitByValue(ValueChange) --- > IDoc


otherwise you will not be able to handle


123,PS,40,20105452,20160715,CN

789,PS,50,20103492,20160715,CN

123,PS,50,20103492,20160715,CN

456,PS,40,20105452,20160715,CN

456,PS,50,20103492,20160715,CN

789,PS,40,20105452,20160715,CN


You will get 4 IDocs instead of 3.


/k

former_member186851
Active Contributor
0 Kudos

Hello Anik,

The same logic u used for root node should help for segments as well or try with format by example