Example Automation Procedure
This section provides an example of an application program that handles a z/OS message. The automation procedure uses a subset of the SA z/OS automation routines.
/* Example SA z/OS Automation Procedure */
1 Signal on Halt Name Aof_Error; Signal on Failure Name Aof_Error
Signal on Novalue Name Aof_Error; Signal on Syntax Name Aof_Error
2 Parse source . . ident .
3 "GLOBALV GETC AOFDEBUG AOF."||ident||".0DEBUG AOF."||ident||".0TRACE"
If AOFDEBUG = 'Y' Then
"AOCMSG "||ident||",700,LOG,"||time()||","||opid()||","||Arg(1)
loc.0debug = AOF.ident.0DEBUG
loc.0trace = AOF.ident.0TRACE
loc.0me = ident
If loc.0trace <> '' Then Do
loc.0debug = ''
Trace Value loc.0trace
End
4 save_msg = msgid()
save_text = msgstr()
lrc = 0
5 /* This procedure can only be called for msg IEA099A */
If save_msg <> 'IEA099A' Then Do
"AOCMSG "||loc.0me||",203,"||time()||","||opid()
Exit
End
6 "GLOBALV GETC AOFSYSTEM"
cmd = 'AOCQRY '||save_msg||' RECOVERY '||AOFSYSTEM
cmd
svretcode = rc
If loc.0debug = 'Y' Then
"PIPE LIT /Called AOCQRY; Return Code was "||svretcode||"/" ,
"| LOGTO NETLOG" /* -------------------------------------------------------------- **
** Check return code from AOCQRY **
** 0 = ok 1 = global flag off **
** 2 = specific flag off 3 = resource not in ACF **
** 4 = bad parms 5 = errors/timeout **
** -------------------------------------------------------------- */
Select
7 When svretcode >= 3 Then Do
"AOCMSG "loc.0me",206,,"time()",,,"cmd",RETCODE="svretcode
lrc = 1
End
8 When svretcode > 0 Then Do
"GLOBALV GETT AUTOTYPE SUBSAPPL SUBSTYPE SUBSJOB"
"AOCMSG "loc.0me",580,,"time()","SUBSAPPL","SUBSTYPE"," ,
SUBSJOB","AUTOTYPE","save_msg
lrc = 1
End
Otherwise Do
9 Parse Var save_text With . 'JOBNAME=' save_job 'ASID=' save_asid .
10 ehkvar1 = save_job
ehkvar2 = save_asid
"GLOBALV PUTT EHKVAR1 EHKVAR2"
11 cmd = 'ACFCMD ENTRY='||AOFSYSTEM||',MSGTYP='||save_msg
cmd
svretcode = rc
If loc.0debug = 'Y' Then
"PIPE LIT /Called ACFCMD; Return Code was "||svretcode||"/" ,
"| LOGTO NETLOG"
/* ---------------------------------------------------------- **
** Check return code from ACFCMD **
** 0 = ok 1 = no commands found in ACF **
** 4 = bad parms 5 = errors/timeout **
** ---------------------------------------------------------- */
12 If svretcode > 1 Then Do
"AOCMSG "loc.0me",206,,"time()",,,'"cmd"',RETCODE="svretcode
lrc = 1
End
End
End /* End of Select svretcode */
13 Exit lrc
14 Aof_Error:
Signal Off Halt; Signal Off Failure
Signal Off Novalue; Signal Off Syntax
errtype = condition('C')
errdesc = condition('D')
Select
When errtype = 'NOVALUE' Then rc = 'N/A'
When errtype = 'SYNTAX' Then errdesc = errortext(rc)
Otherwise Nop
End
"AOCMSG "errtype",760,,"loc.0me","sigl","rc","errdesc
Exit -5