audit()

The sysLib.audit() system function writes tracking information to the system log or journal in a COBOL environment.

For information about the individual environments where the function is meaningful, see "Compatibility" in this topic.

The sysLib.audit() function is system dependent. If you need portability between supported and unsupported environments, develop a non-EGL program with the same name as the system function (audit) to receive the service call in unsupported environments. When generating for an environment in which the service is not supported, EGL turns the function call into a call to the program with the same name. Alternatively, you can test the value of sysVar.sysType to determine the runtime environment, then invoke sysLib.audit() only where the environment supports it.

Syntax

  sysLib.audit(
    record BasicRecord in
    [, jid SMALLINT in] )
record
The name of a record to be written to a journal file.

The first 2 bytes contain the length of the record to be written. The next 2 bytes contain a code that identifies the source of the journal record; the first byte of that code must be in the range X'A0' to X'FF'.

The first 28 bytes are reserved for containing the record length and record identifier code and for system usage. The first 28 bytes must not contain user data; bytes 29 to 32767 are available for audit data.

jid
An optional parameter that specifies the ID (1-99) of the journal file in which the function writes the record. If jid is omitted, the function writes the record to the system journal by default. The parameter is a 2-byte binary number.

Example

package com.companyb.customer;

Record wrkRecord type basicRecord
  10 length    smallint;
  10 code    char(2);
  10 reserved  char(24);
  10 data     char(32737);
end

Program calc2
  wrkrec wrkRecord;
  jrnlid    smallint;

  Function main()
    wrkrec.length = 32765;
    wrkrec.code = x"A012";
    wrkrec.data = "THIS IS THE DATA TO BE WRITTEN TO JOURNAL NUMBER 2";
    jrnlid = 2;
    sysLib.audit(wrkrec, jrnlid);
  end  // main() 
end  // program

Compatibility

Table 1. Compatibility considerations for audit()
Platform Issue
CICS® The function writes to the CICS journal. If you are in V6 exception mode (see Using V6 exception compatibility), EGL sets sysVar.errorCode as follows:
00000000
Successful completion
00000201
Length error
00000202
User source code error
00000204
Journal identifier error
00000803
I/O error
IMS™ The function writes to the IMS log. EGL automatically converts the record to IMS log format by adding 2 to the length and inserting 2 bytes of binary zeros following the length field. Only the first byte of the record identifier code is used. The second byte of the record identifier code is ignored. The jid parameter is ignored. IMS/VS has a maximum limit of 32,765 bytes.
iSeries® COBOL The sysLib.audit() function is not supported.
Java™ generation sysLib.audit() is not supported.
JavaScript generation sysLib.audit() is not supported.
z/OS® batch To use the sysLib.audit() function in z/OS batch, you must specify a PSB for the program, and the program must meet at least one of the following criteria:
  • Reference a PSB or PCB in any statement in the program
  • Have DL/I databases other than ELAWORK in the PSB definition
  • Use one of the following system functions:
    • dliLib.AIBTDLI()
    • dliLib.EGLTDLI()
    • vgLib.VGTDLI()
  • Associate at least one file or the printer with GSAM
Under these conditions, sysLib.audit() behaves in the z/OS batch environment in the same way as it does in IMS.

Feedback