EMS Manual
Reporting Events
EMS Manual—426909-005
8-13
Example: Writing an EMS Interface Into a Program
CALL OPEN ( COLNAME,
FILENUM);
In COBOL85, use ENTER COBOL85^SPECIAL^OPEN, rather than the OPEN verb, to
open the FD when you are using messages containing tokens. Do not use this
statement when you are using ASCII text.
Step 2: Build Event Messages
Because an event message has a specialized header and other unique characteristics,
building one requires a different set of procedures than building a command or
response message. (Because the two message types are similar, however, it is
instructive to learn the way command-response messages are created. For this
information, see the SPI Programming Manual.)
These EMS routines provide assistance in building event messages:
Most information to be added to the event message is passed to the EMS routines as
parameters, but the routines can derive some information themselves (such as the
caller’s system, PIN, and process descriptor).
For a detailed description of the EMS routines, see Section 15, EMS Procedures
.
Step 3: Send an Event Message
To send an event message to a primary or alternate collector, use the WRITEREAD
procedure. Pass to the WRITEREAD procedure the file number returned from your
OPEN call, the event-message buffer you created using the preceding EMS routines,
and the length of the buffer. This TAL example illustrates this WRITEREAD call:
! INT FILENUM is assumed from OPEN example above
INT .EVENT^BUF [0:MAX^EVENT];
INT EVENT^SIZE;
! Call EMSINIT, EMSADDTOKENS, and so on.
...
! Call SSGETTKN to determine buffer length--
CALL SSGETTKN ( EVENT^BUF,
ZSPI^TKN^USEDLEN,
EVENT^SIZE );
EMSINIT Initializes the event-message buffer, inserting information such as
the subsystem ID, the event number, and the subject of the event.
EMSADDTOKENS Adds up to four tokens to an event-message buffer that has already
been initialized by EMSINIT.
EMSADDSUBJECT Inserts an additional subject in an initialized event-message buffer.
You must use this procedure, not EMSADDTOKENS, to add more
subject tokens to an event message.