This XFD directive indicates that a COBOL trigger is to be executed.
The following three parameters are passed to the COBOL program:
01 OPCODE. 88 READ-BEFORE VALUE "r". 88 READ-AFTER VALUE "R". 88 WRITE-BEFORE VALUE "w". 88 WRITE-AFTER VALUE "W". 88 REWRITE-BEFORE VALUE "u". 88 REWRITE-AFTER VALUE "U". 88 DELETE-BEFORE VALUE "d". 88 DELETE-AFTER VALUE "D". 01 FILE-RECORD PIC X(MAX-RECORD-SIZE). 01 ERROR-CODE PIC 99.
You can use C$PARAMSIZE to determine the size of the record passed, in case you have variable-length records.
In cases in which the record size is known, the actual record is passed [READ-AFTER (all), WRITE-BEFORE, WRITE-AFTER, REWRITE-BEFORE, REWRITE-AFTER].
In cases in which the record size is not known, the maximum record size is passed [READ-BEFORE (all), DELETE-BEFORE, DELETE-AFTER].
The contents of this field are identical to the record area given to the file operation. The BEFORE images have the value before the file operation, and the AFTER images have the value after the file operation.
Use the ERROR-CODE parameter to signal that an error occurred:
Also, if you set an error in the REWRITE-AFTER or DELETE-AFTER, the record does not return to its prior state — the record is modified or deleted in the database. We suggest that you use transactions if this behavior is not acceptable.
Please note that if the COBOL program cannot be called (for any reason), it is treated as having succeeded.