


Look at it the other way around.
Instead of checking "Command attempted while SMTP jobs active", look for "TCP1A0F - SMTP server starting.".
Both those messages can not be monitored using MONMSG but the "TCP1A0F - SMTP server starting." can be captured by the RCVMSG:
DCL VAR(&MSGID) TYPE(*CHAR) LEN(07)
STRTCPSVR *SMTP
RCVMSG MSGTYPE(*LAST) RMV(*NO) MSGID(&MSGID)
IF (&MSGID *EQ 'TCP1A0F') +
CHGVAR VAR(&SMTPON) VALUE('YES')
Hi
You can do this using a CL routine that scans through the active jobs for user QTCP. If job QTSMTPSRVD is active then the SMTP server is running.
The following CL program can be called passing a 10 character return parameter. The parameter will contain *ACTIVE or *INACTIVE when it returns to the calling program:
*************** Beginning of data *********************************
PGM PARM(&RETURN)
DCL VAR(&RETURN) TYPE(*CHAR) LEN(10)
DCL VAR(&MSGID) TYPE(*CHAR) LEN(7)
DCLF FILE(QTEMP/SPLF132)
/* First, assume it’s inactive… */
CHGVAR VAR(&RETURN) VALUE(‘*INACTIVE’)
/* Generate a list of all QTCP jobs running in batch… */
WRKUSRJOB USER(QTCP) STATUS(*ACTIVE) OUTPUT(*PRINT) +
JOBTYPE(*BATCH)
/* Copy the spoolfile to a database file in QTEMP… */
CRTPF FILE(QTEMP/SPLF132) RCDLEN(132)
MONMSG MSGID(CPF0000)
CPYSPLF FILE(QPDSPSBJ) TOFILE(QTEMP/SPLF132) +
SPLNBR(*LAST)
/* Read through the file until either the SMTP server job is found or the end */
/* of the file is reached… */
READ: RCVF
MONMSG MSGID(CPF0864) EXEC(GOTO CMDLBL(ENDPGM))
IF COND(%SST(&SPLF132 4 10) *NE ‘QTSMTPSRVD’) +
THEN(GOTO CMDLBL(READ))
/* Job active, so set return value… */
CHGVAR VAR(&RETURN) VALUE(‘*ACTIVE’)
/* End the program… */
ENDPGM: ENDPGM
Before compiling the program, issue the command:
CRTPF QTEMP/SPLF132 RCDLEN(132)
and then compile the program interactively.
Hope it helps
All the best
Jonathan



