Iteration

Iteration is the repeated execution of a set of actions until a desired outcome is achieved. The While shape is used to express such repetition in a business process. The repeated process, also called the while loop, continues until a rule stops the iteration. The rule is based on values of fields in the messages being processed by the schedule.

The While shape contains exactly one rule and a Continue clause. The business process you attach to the While shape's rule is called the body of the while loop. If the While rule evaluates to TRUE, the entire process, the body of the while loop, is executed, and control returns back to the While shape. An attempt to repeat the operation is then made based on the evaluation of the rule. If the rule evaluates to FALSE, no additional repetitions are attempted, and the control flows to the business process attached to the Continue clause.

Figure 9.5 illustrates the things described so far.

Figure 9.5. A business process with While and Decision shapes.


This process flow is from the LineItems XLANG sample provided with the SDK. It is at Program FilesMicrosoft BizTalk ServerSDKXLANG SamplesIterationLineItemsApp, or a similar path, depending on your installation.

Figure 9.5 has been slightly rearranged, and the communication and implementation aspects have been hidden. Figure 9.5 shows a While loop with a rule called ItemsRemaining. The body of the While loop contains the entire process flow emanating from this rule and terminating in the sole End shape toward the bottom. The body of the While loop contains a Decision shape with three rules. The body of the While loop is repeatedly executed while the ItemsRemaining rule returns TRUE.

Note

The body of a While loop must conclude in a single End shape. You cannot have, for example, the process flow commingle with flows emanating from outside the body of the While shape.


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset