Specifying Conditional Commitment Control

You can write a program so that the decision to open a file under commitment control is made at run time. By implementing conditional commitment control, you can avoid writing and maintaining two versions of the same program: one which operates under commitment control, and one which does not.

The COMMIT keyword has an optional parameter which allows you to specify conditional commitment control. You enter the COMMIT keyword in the keyword section of the file description specifications for the file(s) in question. The ILE RPG compiler implicitly defines a one-byte character field with the same name as the one specified as the parameter. If the parameter is set to '1', the file will run under commitment control.

The COMMIT keyword parameter must be set prior to opening the file. You can set the parameter by passing in a value when you call the program or by explicitly setting it to '1' in the program.

For shared opens, if the file in question is already open, the COMMIT keyword parameter has no effect, even if it is set to '1'.

Figure 183 is an example showing conditional commitment control.

Figure 183. Example of Using Conditional Commitment Control
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
FFilename++IPEASFRlen+LKlen+AIDevice+.Keywords+++++++++++++++++++++++
FMASTER    UF   E      K      DISK    COMMIT(COMITFLAG)
FTRANS     UF   E      K      DISK    COMMIT(COMITFLAG)
*.. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 ...+... *
CL0N01Factor1+++++++Opcode(E)+Factor2+++++++Result++++++++Len++D+HiLoEq....
 *  If COMITFLAG = '1' the files are opened under commitment control,
 *  otherwise they are not.
C     *ENTRY        PLIST
C                   PARM                    COMITFLAG
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.  You only issue the COMIT or ROLBK if the files
 *  were opened for commitment control (ie. COMITFLAG = '1')
 *
C                   UPDATE    MAST_REC                             90
C                   UPDATE    TRAN_REC                             91
C                   IF        COMITFLAG = '1'
C                   IF        *IN90 OR *IN91
C                   ROLBK
C                   ELSE
C                   COMMIT
C                   ENDIF
C                   ENDIF
C*


[ Top of Page | Previous Page | Next Page | Contents | Index ]