When a program that uses commitment control is called, monitor for unexpected errors and perform a rollback operation if an error occurs.
For example, uncommitted records can exist when a program encounters an unexpected error such as an RPG divide-by-zero error.
Depending on the status of the inquiry message reply (INQMSGRPY) parameter for a job, the program sends an inquiry message or performs a default action. If the operator response or the default action ends the program, uncommitted records still exist waiting for a commit or rollback operation.
If another program is called and causes a commit operation, the partially completed transaction from the previous program is committed.
To prevent partially completed transactions from being committed, monitor for escape messages after the CALL command. For example, if it is an RPG program, use the following coding:
CALL RPGA MONMSG MSGID(RPG9001) EXEC(ROLLBACK) /*Rollback if pgm is canceled*/
If it is a COBOL program:
CALL COBOLA MONMSG MSGID(CBE9001) EXEC(ROLLBACK) /*Rollback if pgm is canceled*/