cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI7.31 BPM Parallel For Each

former_member183909
Active Participant
0 Kudos

Hi

has anybody done a BPM that receives in a list of records and then for each one calls a WebService and then checks each response ?.

I've got mine calling the web service for each record (that bit works) but don't know how to marry up the resulting response.

I thought this might be done just with two activites; the first one a parallel-for-each to call the webservice and then a second one to process the responses.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Jonny

Are you trying to use sync-async bridge in NWBPM. I mean your source message will have multiple record and for each record you will make a sync call and then finally send the response back to receiver.

You can do this using the following pattern

The BPM will receive the message containing multiple record. Use two integer and one long variable to count record

use condition in the exclusive choice as when loop count = record count the process will end.

in the sync send step use the generic function 'GET' to send one record at a time

Let me know if you have any doubt on any steps.

former_member183909
Active Participant
0 Kudos

Hi

I'm just doing a Synchronous WebService call.    So I will not do a "parallel for each" but rather a simple loop mechanism as you have suggested.

I'll let you know how that goes.

thanks.

former_member183909
Active Participant
0 Kudos

Hi Indrajit

FYI : I've created 2 additional data types.

recordcount that is set on Start by a count of rows

counter that is incremented in the output mapping of Call Service activity

But the BPM fails I think due to the setting of the row based on the index. 

DO_index is defined as a long as I thought that is what get() requires and it's initial value is 0.

get(DO_dt_DBRigStatusEntry/row/ExternalPositionX,DO_index)

Former Member
0 Kudos

Hi Jonny

As I have told you , we need three variables, two integer and one long.

at the start step we need to set the variable as

loopcount (type int ) to 0

totalcount (type int ) to total count of the rows

dindex ( type long ) to 0.

then at the sync send step we need to use the function 'get' which comes under generic section

then in the increment counter step , we need to map the following

dindex = dindex+1

loopcount = loopcount+1

This should work. If possible please provide the error message you are getting.

Answers (1)

Answers (1)

Former Member
0 Kudos

It's even easier that that. Just activate the parallel for each loop over the collection. The input mapping will be done with mapping currentCollectionItem to the Service. In the Output mapping, map the output of the Service Calls to another collection. But make sure to select Assignement append (right click on the arrow, assignement->append).

After the calls the data object DO_Output in my example contains the result of all service calls.

The process looks like that, notice the little arrow on the output mapping:

Former Member
0 Kudos

The difference in both approach is that the first one is a sequential approach which will maintain order but low in performance and is not suited for a huge set of records, second is parallel and good in performance but does not gurantee the order in which service is called.

Thanks

Manish