cancel
Showing results for 
Search instead for 
Did you mean: 

Foreach and Parforeach

Former Member
0 Kudos

Hi experts,

Please provide the examples for Foreach and Parforeach properties in block step

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

While Designing Integration Process in IR we may use block in Default or ForEach or ParForEach mode.

When we use block in ForEach or ParForEach mode it means the block will work dynamically.

In any of these two case you will get two extra properties in a block those are: MultiLine Element and Current Element.

In Dynamic mode we send a msg through a block by send step and receive response by the receive step.

So here the block waits for a response for the msg sent.

If you use ForEach then the block will send msg only after it receives a response.

and in ParForEach the block will send all messages parallely without waiting for one's response.

Reward points if helpful.

Regards,

Soumya

GabrielSagaya
Active Contributor
0 Kudos

The main difference between the two is the scenarios where they are used,

parforeach : is mainly used in places where you have to fork for seperate requests, and have to collect individual responses into a single message.

foreach : is maily used in places where sequencial processing is important or the order of the message has to be preserved by executing.

As for which is better you could probably judge interms of cost(memory) vs performance. Parforeach forks a seperate flow for each path(thread on java stack + work flow on abap stack), and if your message is huge, you will be having n*message+BPM initialization cost, where n is the number of paths.

the very nature of Foreach enables recycling of memory and there by for each execution it uses only message+BPM initialization cost.

Bottom line, use parforeach where you need to use fork-collect pattern.

Former Member
0 Kudos

Hi,

Foreach : It takes multiple messages and sent to receivers one after the other, here it maximum handle 999999 messages at a time.

Suppose we take mobile at a time we can call to one person, but parallaly we can send the messages to many one.

ParForEach: It takes multiple messages and sent to receivers simultaneously, it handle 999 messages at a time.

Former Member
0 Kudos
former_member193376
Active Contributor
0 Kudos

Hi

Foreach mode : Multiple messages are sent to individual receivers one after the other.

ParForEach mode : Multiple messages are sent to individual receivers simultaneously.

A ParForEach is not a means of improving performance. A ParForEach will not result in a split into threads.

A ParForEach has a high resource consumption rate because one work item is created for every loop.

A ParForEach is recommended if:

● The messages are processed further in the parallel processing branches.

● The individual processing branches are not dependent on each other on a business level.

● The number of parallel processing branches is less than 999 (the multiline table element that is processed in the ParForEach contains less than 999 lines).

A ParForEach would be beneficial in the following example:

You want to send a message to multiple receivers, wait for the respective answers, and then edit each one independently of the others in a separate context. Once the messages have been sent asynchronously in the ParForEach, the step can wait for an acknowledgment or some kind of business confirmation, for example.

A ParForEach is not recommended if:

● The messages are not processed further in the processing branches.

If, for example, you want to send a message to multiple receivers, but do not want the step to wait for a response or acknowledgment, use a ForEach instead of a ParForEach.

● There are more than 999 processing branches.

Check whether you can use a ForEach instead of a ParForEach. In the case of a ForEach you can set the maximum number of processing branches as part of the absolute upper limit (transaction SWPA). The absolute upper limit is set to 999999.

http://help.sap.com/saphelp_nw04/helpdata/en/11/13283fd0ca8443e10000000a114084/frameset.htm

Thanks

Saiyog