Skip to Content
author's profile photo Former Member
Former Member

Foreach and Parforeach

Hi experts,

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

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Posted on May 28, 2008 at 04:14 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 04:14 PM
    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 04:21 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on May 28, 2008 at 04:29 PM

    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.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on May 28, 2008 at 05:05 PM

    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

    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.