EMS Manual

Example of Retrieving Event Messages
EMS Manual426909-005
A-23
COBOL Source File
* Protect against a longer buffer in the distributor
ENTER "SSPUT" USING distr-rec,
zspi-tkn-reset-buffer,
zems-val-buflen GIVING error-flag
IF error-flag NOT = ZERO
ENTER "DEBUG"
END-IF
* Check return code in GETEVENT command response
ENTER "SSGET"
USING distr-rec, zspi-tkn-retcode, ems-err
GIVING error-flag
IF error-flag NOT = ZERO
ENTER "DEBUG"
END-IF
IF ems-err NOT = ZERO
ENTER "DEBUG"
END-IF
* Get the offset of the event-message
* in the response buffer
ENTER "SSGET"
USING distr-rec, zspi-tkn-offset,
zems-tkn-event, 1, offset
GIVING error-flag
IF error-flag NOT = ZERO
ENTER "DEBUG"
END-IF
* Move the event message to a buffer of its own.
* (+2 reflects that event is a variable-length
* token; +1 adjusts for the COBOL counting offset
* from 1 rather than from 0)
MOVE distr-rec(offset + 2 + 1:) TO event-buf
* Get the display text for the event
ENTER "EMSTEXT" USING event-buf,
evt-text-buf,
evt-text-len,
num-evt-lines,
actual-len-g,
OMITTED,
2
GIVING text-stat
IF text-stat-high = 0
AND text-stat-low NOT = 0
ENTER "DEBUG"
END-IF
* Display the display text
PERFORM VARYING ind FROM 1 BY 1
UNTIL ind > num-evt-lines
OR actual-len (ind) = -1