Example of Using Commitment Control
This example illustrates the specifications and CL commands required for a program to operate under commitment control.
To prepare for using commitment control, you issue the following CL commands:
- CRTJRNRCV JRNRCV (RECEIVER)
This command creates a journal receiver RECEIVER.
- CRTJRN JRN(JOURNAL) JRNRCV(RECEIVER)
This command creates a journal JOURNAL and attaches the journal receiver RECEIVER.
- STRJRNPF FILE(MASTER TRANS) JRN(JOURNAL)
This command directs journal entries for the file MASTER and the file TRANS to the journal JOURNAL.
In your program, you specify COMMIT for the file MASTER and the file TRANS:
Figure 1. Example of Using Commitment Control
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++
FMASTER UF E K DISK COMMIT
FTRANS UF E K DISK COMMIT
F*
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
C :
C :
*
* Use the COMMIT operation to complete a group of operations if
* they were successful or rollback the changes if they were not
* successful.
*
C UPDATE MAST_REC 90
C UPDATE TRAN_REC 91
C IF *IN90 OR *IN91
C ROLBK
C ELSE
C COMMIT
C ENDIF
To operate your program (named REVISE) under commitment control, you issue
the commands:
- STRCMTCTL LCKLVL(*ALL)
This command starts commitment control with the highest level of locking.
- CALL REVISE
This command calls the program REVISE.
- ENDCMTCTL
This command ends commitment control and causes an implicit Roll Back operation.