AFTER ROW block

The AFTER ROW block is executed each time the user moves to another row, before the current row is left. This trigger can also be executed in other situations, such as when you delete a row, or when the user inserts a new row.

A NEXT FIELD instruction executed in the AFTER ROW control block will keep the user entry in the current row. Use this behavior to implement row validation and prevent the user from leaving the list or moving to another row.

When called in this block, the ARR_CURR() function return the index of the row that you are leaving.

Important: After creating a temporary row at the end of the list, if you leave that row to a previous row without data input (setting the touched flag), or when the cancel action is invoked, the temporary row will be automatically removed. The AFTER ROW block will be executed for the temporary row, but ui.Dialog.getCurrentRow()/ARR_CURR() will be one row greater than ui.Dialog.getArrayLength()/ARR_COUNT(). In this case, you should ignore the AFTER ROW event. For example, you should not try to execute a NEXT FIELD or CONTINUE INPUT instruction, nor should you try to access the dynamic array with a row index that is greater than the total number of rows, otherwise the runtime system will adapt the total number of rows to the actual number of rows in the program array.
In this example, the AFTER ROW block checks a variable value and forces the user to stay in the current row if the value is wrong:
INPUT ARRAY p_items WITHOUT DEFAULTS
      FROM s_items.*
  ...
  AFTER ROW
    IF arr_curr()>0 AND arr_curr() <= arr_count() THEN
      IF NOT item_is_valid_quantity(p_item[arr_curr()].item_quantity) THEN
        ERROR "Item quentity is not valid"
        NEXT FIELD item_quantity
      END IF
    END IF
...
Another way to handle the case of temporary rows in AFTER ROW is to use a flag to know if the AFTER INSERT block was executed: The AFTER INSERT block is not executed if the temporary row is automatically removed. By setting a first value in BEFORE INSERT and changing the flag in AFTER INSERT, you can detect if the row was permanently added to the list:
INPUT ARRAY p_items WITHOUT DEFAULTS
      FROM s_items.*
   ...
   BEFORE INSERT
     LET op = "T"
     ...
   AFTER INSERT
     LET op = "I"
     ...
   AFTER ROW
     IF op == "I" THEN
       IF NOT item_is_valid_quantity(p_item[arr_curr()].item_quantity) THEN
         ERROR "Item quentity is not valid"
         NEXT FIELD item_quantity 
       END IF
       WHENEVER ERROR CONTINUE
       INSERT INTO items (item_num, item_name, item_quantity)
                  VALUES ( p_item[arr_curr()].* )
       WHENEVER ERROR STOP
       IF SQLCA.SQLCODE<0 THEN
         ERROR "Could not insert the record into database!"
         NEXT FIELD CURRENT
       ELSE
         MESSAGE "Record has been inserted successfully"
       END IF
     END IF
 ...