Example: Loop

This scenario uses the looping feature of the View function. It calls the input function and runs multiple times.

Input: VI - Result Table
Input Number Divisible by 3
1 NO

In a normal modeling scenario, the iteration is handled by calling a chain of functions ending with a writer. A simple scenario has been created to highlight the looping mechanism provided by the View function.

Prerequisite: The model table has one input record.

Initial Input Table
Input Number Divisible
1 NO
2 NO
3 YES
  1. The model table acts as a repository for both input (join) and output (writer), which will then be used in the loop.

    Assuming that there are already three records in the model table:

  2. The Join acts as the process that must be run on the records before the result is written back to the model table. In this scenario, the join has been set up to perform the following three steps:

    1. Step 1: All records from the model table are collected and the maximum record is marked. Marking is done by performing Iteration Counter = MAX (Input Number) OVER (), giving the result on the left.

      Input Number Dibisible by 3 Iteration Counter
      3 YES 3
    2. Step 2: Select only the record that has the same iteration counter and input number. This can be configured by using complex selections tab: WHERE Iteration Counter = Input Number. In this case, the result of step 2 is on the left.

      Input Number Divisible by 3
      4 NO
    3. Step 3:

      1. ZQA_INPNO is incremented by 1, the formula is Input Number = Input Number +1, so Input Number = 3+1.

      2. The record should be assessed if divisible by 3. The formula for this is as follows:

        DIVISIBLE = CASE WHEN MOD ((Input Number +1),3) = 0 THEN "YES"
        ELSE "NO"
        END

        so

        DIVISIBLE = CASE WHEN MOD ((3+1),3) = 0 THEN "YES"
        ELSE "NO"
        END

        In this case, the condition statement provides a “NO” since 4 MOD 3 = 1.

      3. The iteration counter must also be set to “Not Used” to prepare the writing to the model table. The result of step 3 is on the left.

        Input Number Divisible by 3
        1 NO
        2 NO
        3 YES
        4 NO
  3. The final result from step 2 is inserted in the model table using a writer. If the model table is checked, it must have a result like the one on the left after the iteration.

    If the process needs to be run multiple times, it can be done via view.

  4. A view with active looping functions must be used to call the writer multiple times. The main steps 1 to 3 are executed multiple times based on what has been defined on the Advance tab of the view.