Ok, we all have our own coding methods, and this is the one that I prefer to use when playing with tables.
I build a variable into the table, usually
O for operation, and use that in my processing code. This stores the required action code in the table and does not do anything until the user has hit PF3 to quit the table selection process. This allows for a review of what has been requested and also allows corrections to be made before processing. Let's face it, the option of not to delete a selected record sure beats deleting the record immediately without asking questions.
Basically our code is very similar, the initial panel display - if no records selected it bypasses the table process, if rows are selected the DO FOREVER loop happens until the user is satisfied with the options entered and only when they hit PF3 to exit the table displays does the program actually do the requested work.
I appreciate you have your own coding preferences and if the code below helps you ...........
"ISPEXEC TBDISPL ENVLIST PANEL(TABLTEST)"
IF RC <> 8 THEN DO
DO FOREVER
DO WHILE ZTDSELS > 0
UPPER O
IF O = 'S' THEN DO
"ISPEXEC TBPUT ENVLIST"
END
ELSE IF O = 'U' THEN DO
O = ' '
"ISPEXEC TBPUT ENVLIST"
END
"ISPEXEC TBDISPL ENVLIST"
END
"ISPEXEC TBDISPL ENVLIST"
IF RC = 8 THEN LEAVE
END
END
Logic to process requested actions against the table goes here.