Usage / DIALOG control blocks |
The AFTER ROW block is executed when a DISPLAY ARRAY or INPUT ARRAY list loses the focus, or when the user moves to another row in a list. This trigger can also be executed in other situations, for example when you delete a row, or when the user inserts a new row.
AFTER ROW is executed after the AFTER FIELD, AFTER INSERT and before AFTER DISPLAY or AFTER INPUT blocks.
When called in this block, the DIALOG.getCurrentRow() method returns the index of the of the row that you are leaving.
For both INPUT ARRAY and DISPLAY ARRAY sub-dialogs, a NEXT FIELD executed in the AFTER ROW control block will keep the focus in the list and stay in the current row. Use this feature to implement row validation and prevent the user from leaving the list or moving to another row.
INPUT ARRAY p_items FROM s_items.* ... AFTER ROW LET r = DIALOG.getCurrentRow("s_items") IF r <= DIALOG.getArrayLength("s_items") THEN IF NOT item_is_valid_quantity(p_item[r].item_quantity) THEN ERROR "Item quantity is not valid" NEXT FIELD item_quantity' END IF END IF
INPUT ARRAY p_items 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 quantity 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 ...