cancel
Showing results for 
Search instead for 
Did you mean: 

Exit loop in BPM?

Former Member
0 Kudos

Based on sap's documentation, loop in bpm works as While, Can anybody explain how to exit a loop in bpm similar to break statement in While loop? Is cancel the right step to use? will it cause potential issues then terminte the bpm normally(Stop)?

Thanks,

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi,

The "cancel process" option of the control step abruptly terminates the entire process and sets the status to "logically deleted" as per the documentation. Moorthy - if you have found a way to limit the scope of the control step to a block please advise - it does not work for me nor to I see any option for it (I am on SP16 so maybe it is in later SP).

Anyway - when a bpm completes normally the status is set to "completed".

I would suggest that the use of the "cancel process" in a control step is an extreme reaction to a catastrophic failure in your BPM that is unrecoverable. Not the situation that you have. Surely you can make use of local variables, switch statements and loop control to define the proper logical path through your BPM without resorting to canceling the process.

Anyway - the short answer to your original question is this - There is nothing similar to a break statement in a loop control. Cancel process (or cancel step) is not the right way to terminate a loop or step in normal behaviour. It will most likely NOT cause any problems and it WILL terminate the BPM.

Former Member
0 Kudos

On the assumption that your "break" condition occurrs in the middle of the processing that you are doing in the loop and is not something that you can simply add to the loop condition, and that the condition to cause your "break" is not actually an exception, you could simply just keep processing in another branch of your switch and set a loop terminator condition in the "break" branch which you then add to your loop conditions.

example:

loop while x == 'y' {

if (a==b) then x = 'n' // effective break

else {

continue processing

}

}

Former Member
0 Kudos

Hi

The break I want is an normal exit, not an exception, basically I used an switch inside my loop, in otherwise branch, I do nothing and want to continue looping, in the first branch(equal to if statement), I want to exit the loop and go to the end of bpm(exit), so to rephrase my question, is it same to use control to cancel bpm than normally end the bpm(stop)? will it affect the send step before the control to cancel bpm?

Thanks,

moorthy
Active Contributor
0 Kudos

Using control step, you can come out of the loop. Even using BLOCK step, you can define the scope of the steps. If you use Control step inside the block, then this will come out from the block only. It will not give any problem to other steps

Regards,

moorthy

bhavesh_kantilal
Active Contributor
0 Kudos

Hi,

Adding to moorthy's answer, Control Step is the answer to the Break in a LOOP.

When you need to break out of a loop, use the Control Step and throw an Exception or Alert or Exit the process.

Regards,

Bhavesh

moorthy
Active Contributor
0 Kudos

Hi,

You can think of using Control Step to terminate the process, or come out from the loop with exception.

For this check out this-http://help.sap.com/saphelp_nw2004s/helpdata/en/bb/e1283f2bbad036e10000000a114084/content.htm

Regards,

Moorthy