Previous Topic Next topic Print topic


COBOL-TRIGGER XFD directive

This XFD directive indicates that a COBOL trigger is to be executed.

Note: This XFD directive must come immediately before the file descriptor of the file for which the trigger is defined. It uses the standard XFD directive syntax.

Syntax

XFD COBOL-TRIGGER=program-name

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.

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.

Previous Topic Next topic Print topic