cancel
Showing results for 
Search instead for 
Did you mean: 

Split and batch message by Max_count in SAP PO 7.5

former_member607993
Contributor
0 Kudos

Hello Experts,

Requirement is to split message and batch the records(id) with max_count '5'.

For example: from source, 'key' occurs multiple times(say 25 times) and same should be split into 5 different messages with each message holding 5 records(id's). If 'key' is holding 26 ids the 6th message should hold one record extra.

Source:

<messagetype>

<refs/> 1...1

<key/> 0...unbounded

<id/>.... 1.1

Expected target:

<messagetype1>

<refs/> 1...1

<key/> 0...unbounded

<id/><id/><id/><id/><id/>...

Accepted Solutions (1)

Accepted Solutions (1)

former_member607993
Contributor
0 Kudos

Hello,

I used the below user defined function to partition a list containing with partition size of 5 yields i.e. outer list containing 5 records, all in the original order.

UDF:

public void SplitMessage(String[] id, ResultList result, Container container) throws StreamTransformationException{

AbstractTrace trace;

trace = container.getTrace();

int k=0; trace.addWarning("ID Length" + id.length);

for(int i=0;i<id.length;i++)

{

if(k<5)

{

result.addValue(id[i]);

}

else

{

k=0;

result.addContextChange();

result.addValue(id[i]);

}

k++;

}

Thanks - Rajesh PS

Answers (1)

Answers (1)

sugata_bagchi2
Active Contributor
0 Kudos

Hi Rajesh can you share a sample source and expected target XML ?

is ID a child node of Key?

I think you can do that using Multimapping. But the interface has to be async one.

Thanks

Sugata

former_member607993
Contributor
0 Kudos

Hi Sugata Bagchi Majumder

Below is the structure:

screenshot-2019-11-06-at-125918-pm-1.png

Yes 'id' is the child node of 'key' and this is an async scenario wherein I'm carrying out the multimapping and sending to BPM process with split message of batched records.

Thanks and Regards,

Rajesh PS