The ROLLBACK statement provides a way to cancel one or more changes to database records when the changes should not remain permanent.
ROLLBACK Statement - Format >>-ROLLBACK----------------------------------------------------><
When the ROLLBACK statement is executed, any changes made to files under commitment control since the last commitment boundary are removed from the database. Note that when a file is cleared while being opened for OUTPUT, execution of a ROLLBACK statement does not restore cleared records to the file.
A commitment boundary is the previous occurrence of a ROLLBACK or COMMIT statement. If no COMMIT or ROLLBACK has been issued, the commitment boundary is the first OPEN of a file under commitment control. Removal of changes takes place for all files under commitment control and not just for files under commitment control in the COBOL program that issues the ROLLBACK.
Once the ROLLBACK is successfully executed, all record locks held for files under commitment control are released and the records become available to other jobs. Commitment control can be scoped at the job level or the activation group level. (Commitment control is scoped at the activation group level by default.)
The ROLLBACK has no effect on files not under commitment control. If a ROLLBACK is executed and there are no files under commitment control, the ROLLBACK is ignored.
A file under commitment control can be opened or closed without affecting the status of changes made since the last commitment boundary. A COMMIT must still be issued to make the changes permanent. A ROLLBACK, when executed, leaves files in the same open or closed state as before execution.
If commitment control is scoped at the job level, an implicit ROLLBACK of uncommitted records is automatically done for all files under commitment control at the end of every job. Any uncommitted changes to the database are cancelled.
If commitment control is scoped at the activation group level, an implicit commit occurs when the activation group ends normally. If the activation group ends abnormally, an implicit ROLLBACK occurs.
For more information on commitment control, see the IBM Rational Development Studio for i: ILE COBOL Programmer's Guide.