Use this directive to indicate that a COBOL trigger is to be executed.
$XFD COBOL-TRIGGER=program name
*(( XFD COBOL-TRIGGER=program-name ))
This XFD must be located immediately before the FD of the file for which the trigger is defined.
Three parameters are passed to the COBL 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.
The contents of this field will be identical to the record area given to the file operation. The BEFORE images will have the value before the file operation, and the AFTER images will have the value after the file operation.
Use the ERROR-CODE parameter to signal to Acu4GL that an error occurred.
This means that, for sequential access (next or previous), the file position has changed and a subsequent next or previous will act as if the prior file operation succeeded. Also, setting an error in the REWRITE-AFTER or DELETE-AFTER will not actually return the record to its prior state — the record will be modified or deleted in the database. We suggest using transactions if this behavior is not acceptable.
If the COBOL program can not be called (for any reason), it is treated as having succeeded.