Rational Developer for System z, Version 7.6

Recorded loop: Iterative case

This topic describes how a recorded loop is implemented in the recorded flow in the iterative case, that is, when you do select the check box Extract data every iteration of the loop in the Select Variable window.

The implementation described in this topic is done in addition to the implementation described in Recorded loop: Non-iterative case.

The loop index variable

The loop index variable (in contrast to the required loop variable described in Recorded loop: Non-iterative case) prevents a While loop from running through more iterations than there are instances of an Extract variable.

The loop recorder (the host editor) creates the loop index variable when you select Extract data every iteration of the loop in the Select Variable window. The data type of the loop index variable is integer. The name is formed by adding the suffix _index to the name of the loop variable that you specified, for example LoopVar_index.

In the recorded flow the following changes are made for the loop index variable (see the example flow in Figure 1):
Figure 1. Example of recorded flow with While loop and loop index variable
Example of output connection from parse node when maximum iterations is exceeded
  • In the init node a second mapping is added to initialize the loop index variable to 0 (see Init node, While node, and parse node).

  • In the While node the loop expression is updated to test not only whether the loop variable contains the string TRUE but also whether the loop index is less than the maximum number of iterations. For example,
    (v_Dfh0xs1_Exmenu_Exmenu.strLoopVar = 'TRUE') AND (v_Dfh0xs1_Exmenu_Exmenu.strLoopVar_index < 8)
    The value for the maximum number of iterations is the value that you specify in the Maximum number of iterations field of the Select Variable window (see Maximum number of iterations).
  • In the parse node another output terminal is added (as the first output terminal) to handle the case in which the While node terminates the loop because the maximum number of iterations is exceeded.

    The flow of control goes out of the parse node through this output terminal if the recognized screen is the Begin Loop screen. (The reasoning for this design is that if the While loop terminates and the Begin Loop screen is displayed, rather than the Exit Loop screen, then the While node must have terminated the loop because the maximum number of iterations was exceeded.)

    Because an error condition exists (the loop is terminated because the maximum number of iterations is exceeded) the connection from the first output terminal goes directly to the Reply node, or to the Assign node immediately preceding the Reply node if any (as in Figure 1).

    Note: This output terminal and connection are not added if the Exit Loop application screen is also the first screen of the loop.

The following changes are made in the invoked flow:

Extract actions for the Exit Loop screen

The subtopic describes the changes that are made to implement the option of adding text from an Extract action in the Exit Loop screen to a variable that you store instances of data into during an iteration of the loop (see the example flow shown in Figure 3):
Figure 3. Example of recorded flow with While loop, loop index variable, and Extract action for the Exit Loop screen
Example of recorded flow with loop index variable and Extract action for the Exit Loop screen


Terms of use | Feedback

This information center is powered by Eclipse technology. (http://www.eclipse.org)