I referred to many topics on this forum on creating a return code checker program, found a lot of useful information (Thanks to contributors).
After a lot of trial & error and testing, Using the info I collected from this forum I customized and created below code.
I need to modify this code so that none of the TSO services are used. Could someone please give some ideas to tackle these changes ?
/* REXX */
X=MSG(OFF)
ADDRESS TSO
X=MSG(ON)
"EXECIO * DISKR INFILE ( FINIS STEM MYFILE."
"FREE F(INFILE)"
I = 1
J = 1
SAY "HELO SYSA"
SAY "MAIL FROM: <ABC@DEF.COM>"
DO WHILE I <= MYFILE.0
SAY "RCPT TO:" MYFILE.I
I = I + 1
END
SAY "DATA"
SAY "FROM: <ABC@DEF.COM>"
DO WHILE J <= MYFILE.0
SAY "TO:" MYFILE.J
J = J + 1
END
SAY "SUBJECT: Bad Return Code found in Jobs"
SAY "MIME-VERSION: 1.0"
SAY "CONTENT-TYPE: TEXT/HTML;" "BOUNDARY=""DEF"""
SAY "<PRE> <FONT FACE=""COURIER NEW"" SIZE=2> "
SAY "Hi,"
SAY " "
JOBNAME = MVSVAR('SYMDEF','JOBNAME')
SAY 'Step(s) failed in JOBNAME =' JOBNAME
SAY " "
SAY "Details of failed step(s) are as below..."
SAY "<FONT SIZE=2 COLOR=""BLUE""> "
/* REXX GETRC */
GET_CODE = "0"
DUMP_OPT = "N"
PARM_OPT = "N"
DGTS = "0123456789"
PARSE ARG GETRC_OPT GETRC_OPTS
DO WHILE GETRC_OPT \= ""
GETRC_OPT = TRANSLATE(GETRC_OPT)
IF GETRC_OPT = "DUMP" THEN
DUMP_OPT = "Y"
ELSE
IF GETRC_OPT = "PARM" THEN
PARM_OPT = "Y"
PARSE VAR GETRC_OPTS GETRC_OPT GETRC_OPTS
END
NUMERIC DIGITS(32) /* Ensure Max Precision */
TCB = STORAGE(D2X(540),4) /* PSATOLD IN PSA */
JSCB = STORAGE(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */
JCT = STORAGE(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */
THIS_STEP_NO = X2D(C2X(STORAGE(D2X(C2D(JSCB)+228),1)))
/* THIS STEP NO. */
FSCT = STORAGE(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */
/* IS FIRST SCT */
TEMP_SCT = FSCT
HIGH_RC = 0
ABEND = "N"
SAY " JOB STEP PROCSTEP PROGRAM RC"
SAY "<FONT SIZE=2 COLOR=""PURPLE""> "
DO I = 1 TO THIS_STEP_NO - 1
JSTEP = STORAGE(D2X(C2D(TEMP_SCT)+60),8)
PSTEP = STORAGE(D2X(C2D(TEMP_SCT)+68),8)
PGMNAME = STORAGE(D2X(C2D(TEMP_SCT)+124),8)
RCSTEP = X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+24),2)))
SCTX = STORAGE(D2X(C2D(TEMP_SCT)+84),3)
STEP_PARM = STRIP(STORAGE(D2X(C2D(SCTX)+20),100),"T","00"X)
/* SCTSEXEC IN SCT */
BYPASS = STORAGE(D2X(C2D(TEMP_SCT)+188),1)
IF DUMP_OPT = "Y" THEN
"DYDUMP" STORAGE(D2X(C2D(TEMP_SCT)),512)
/* Check if step has not executed or FLUSHed */
IF X2D(C2X(BYPASS)) = 80 THEN DO
RCSTEP = "FLUSHED"
END
ELSE
IF X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+176),1))) = 4 THEN DO
IF X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+176),1))) = 4 THEN DO
ABEND = "Y"
IF DUMP_OPT = "Y" THEN
"DYDUMP" STORAGE(D2X(C2D(SCTX)),256)
ABEND_CODE = X2D(C2X(STORAGE(D2X(C2D(SCTX)+130),2)))
IF ABEND_CODE >= 4096 THEN DO
ABEND_CODE = LEFT(C2X(STORAGE(D2X(C2D(SCTX)+129),2)),3)
ABEND_CODE = " S" || ABEND_CODE
END
ELSE
ABEND_CODE = "U" || ABEND_CODE
IF STEP_PARM = "" THEN
RCSTEP = "ABEND" || ABEND_CODE "PARM =" STEP_PARM
ELSE
RCSTEP = "ABEND" || ABEND_CODE "PARM =" STEP_PARM
END
ELSE
HIGH_RC = MAX(HIGH_RC,RCSTEP)
IF PARM_OPT = "Y" THEN
RCSTEP = RCSTEP " " STEP_PARM
IF RCSTEP = "0" | RCSTEP = "1" | RCSTEP = "98" |,
RCSTEP = "99" | RCSTEP = "FLUSHED" | RCSTEP = "FLUSH" THEN
TYPE = " "
ELSE
TYPE = " (BAD RC)"
IF RCSTEP ¬== "0" & RCSTEP ¬== "98" & RCSTEP ¬== "99" &,
RCSTEP ¬== "1" & RCSTEP ¬== "FLUSHED" & RCSTEP ¬== "FLUSH" THEN
GET_CODE = "01"
SELECT
WHEN JSTEP = "" & VERIFY(RCSTEP,DGTS) = 0 THEN
SAY RIGHT(I,3) PSTEP COPIES(" ",8) PGMNAME RCSTEP,
|| " <FONT SIZE=2 COLOR=""RED"">",
|| TYPE "</FONT>"
WHEN JSTEP = "" THEN
SAY RIGHT(I,3) PSTEP COPIES(" ",8) PGMNAME RCSTEP,
|| " <FONT SIZE=2 COLOR=""RED"">",
|| TYPE "</FONT>"
WHEN VERIFY(RCSTEP,DGTS) = 0 THEN
SAY RIGHT(I,3) JSTEP PSTEP PGMNAME RCSTEP,
|| " <FONT SIZE=2 COLOR=""RED"">",
|| TYPE "</FONT>"
OTHERWISE
SAY RIGHT(I,3) JSTEP PSTEP PGMNAME RCSTEP,
|| " <FONT SIZE=2 COLOR=""RED"">",
|| TYPE "</FONT>"
END
TEMP_SCT = STORAGE(D2X(C2D(TEMP_SCT)+36),3)
END
IF ABEND = "Y" THEN DO
END
ELSE DO
END
/* REXX */
ADDRESS TSO
SAY " <FONT SIZE=2 COLOR=""BLACK"">"
SAY "Regards,"
SAY "ABC Team"
SAY "</FONT>"
IF GET_CODE = "01" THEN
GET_CODE = 01
EXIT GET_CODE