Skip to Content

Split and batch message by Max_count in SAP PO 7.5

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/>...

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    Posted on Nov 06, 2019 at 12:49 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 05, 2019 at 10:43 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.