Commitment control is a means of grouping file operations as a single unit so that you can synchronize changes to database files in a single job.
Before you can start commitment control, you must ensure that all the database files you want processed as one unit are in a singlecommitment control environment. All the files within this environment must be journaled to the same journal. Use the CL commands Create Journal Receiver (CRTJRNRCV), Create Journal (CRTJRN) and Start Journal Physical File (STRJRNPF) to prepare for the journaling environment.
Once the journaling environment is established, you can use the following commands:
You can use commitment control to define and process several changes to database files as a single transaction.
Example:
The following example uses commitment control. Purchase orders are entered and logged in two files, T1520DD5 for daily transactions, and T1520DD6 for monthly transactions. Journal entries that reflect the changes that are made to T1520DD5 and T1520DD6 are kept in the journal JRN.
CRTPF FILE(QTEMP/T1520DD5) SRCFILE(QCPPLE/QADDSSRC)
This creates the physical file T1520DD5 using the DDS source shown below:
Figure 133. T1520DD5 -- DDS Source for Daily Transactions
|
CRTPF FILE(QTEMP/T1520DD6) SRCFILE(QCPPLE/QADDSSRC)
This creates the physical file T1520DD6 using the DDS source shown below: type:
Figure 134. T1520DD6 -- DDS Source for Monthly Transactions
|
CRTPF FILE(MYLIB/NFTOBJ) RCDLEN(19)
This creates the physical file NFTOBJ for notification text.
CRTDSPF FILE(QTEMP/T1520DD7) SRCFILE(QCPPLE/QADDSSRC)
This creates the display file T1520DD7 using the DDS source shown below:
Figure 135. T1520DD7 -- DDS Source for a Purchase Order Display
|
CRTJRNRCV JRNRCV(MYLIB/JRNRCV)
This creates the journal receiver JRNRCV.
CRTJRN JRN(MYLIB/JRN) JRNRCV(MYLIB/JRNRCV)
This creates the journal JRN and attaches the journal receiver JRNRCV to it.
On the command line, enter:
STRJRNPF FILE(QTEMP/T1520DD5 QTEMP/T1520DD6) JRN(MYLIB/JRN)
IMAGES(*BOTH)
This starts journaling the changes that are made to T1520DD5 and T1520DD6 in the journal JRN.
CRTBNDC PGM(MYLIB/T1520COM) SRCFILE(QCPPLE/QACSRC)
This creates the program T1520COM using the program source shown below:
Figure 136. T1520COM -- ILE C Source to Group File Operations Using Commitment Control
|
The _Ropen() function opens the purchase display file, the daily transaction file, and the monthly transaction file. The _Rindara() function identifies a separate indicator area for the purchase file. The _Rformat() function selects the purchase record format defined in T1520DD7. The _Rwrite() function writes the purchase order display. Data that is entered updates the daily and monthly transaction files T1520DD5 and T1520DD6. The transactions are committed to these database files that use the _Rcommit() function.
STRCMTCTL LCKLVL(*CHG) NFYOBJ(MYLIB/NFTOBJ (*FILE)) CMTSCOPE(*JOB)
CALL PGM(MYLIB/T1520COM)
The display appears as follows:
+--------------------------------------------------------------------------------+ | PURCHASE ORDER FORM | | | | | | | | | | | | | | ITEM NAME : | | | | SERIAL NUMBER : | | | | | | | | | | | | | | | | | | | | | | F3 - Exit | | | +--------------------------------------------------------------------------------+
TABLE 12345
BENCH 43623
CHAIR 62513
After an item and serial number are entered, T1520DD5 and T1520DD6 files are updated. The daily transaction file T1520DD5 file contains the sample data after all three purchase order items are entered.
ENDCMTCTL
The journal JRN contains entries that correspond to changes that are made to T1520DD5 and T1520DD6.
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.