Ok..looks like I have put the ask in wrong manner.
But in case of nested loop only one loop should execute in my case it is going into 2nd else if then going to error.
I will put the whole code in some time.
/*--------------------------------------------------------------------*/
/* CAPGHLTC - Capgemini Health Check. */
/* Checks Operations from DD JOBS and Applications from */
/* DD APPS and emails report to Capgemini. */
/* Input */
/* ----- */
/* */
/* JOBS DD - list of jobs */
/* ------- */
/* Word 1 - Day of week matrix MTWTFSS, replace day of week with */
/* a full stop to skip checking on that day. i.e. */
/* MTWTFS. Will not do that check on Sundays. */
/* Word 2 - TWS Application name. */
/* Word 3 - TWS Job name or ALL to check and list all jobs in an */
/* Application. ALL should not really be necessary as */
/* ZLAST will check the last job. */
/* */
/* APPS DD - list of applications */
/* ------- */
/* Word 1 - Day of week matrix MTWTFSS, replace day of week with */
/* a full stop to skip checking on that day. i.e. */
/* MTWTFS. Will not do that check on Sundays. */
/* Word 2 - TWS Application name. */
/* Word 3 - IA date in relation to the schedule of this job. */
/* 0 - same as this jobs IA date. */
/* n - number of days before this job IA date so is -n. */
/* Word 4+ - Description of check for to go on the report. */
/* */
/* HDR DD - HTML Header */
/* ------ */
/* The code in here is put at the front of the report produced to */
/* define the email sent as being in HTML format. */
/* */
/* TLR DD - HTML Trailer */
/* ------ */
/* The code in here is put at the end of the report produced to */
/* define the email sent as being in HTML format. */
/* */
/* Parameters */
/* ---------- */
/* PHASE should be set by the WAPL code calling the include member. */
/* */
/* Output */
/* ------ */
/* REPORT DD */
/* --------- */
/* The HTML report that this code then emails */
/* */
/* Date Who Description */
/* ---------- ------ ------------------------------------------------ */
/* 14/05/2020 BBARED New WAPL code */
/* 18/05/2020 BBARED replaced object OBJ with OJOBS and OAPPS, */
/* refined code. */
/* 19/05/2020 BBARED Moved loop of OJOBS to pevent duplicate entries. */
/* 06/12/2020 SHUBHAM CHAUHAN */
/* added logic to calculate time for delay and early run . */
/* of prpmd045 and prpmd220 schedule. */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Get todays day number 1 = Monday */
/*--------------------------------------------------------------------*/
VARSET TODAY = DATE('O')
VARSET DOWNUM = DATE('B',"!TODAY",'O')//7 + 1
/*--------------------------------------------------------------------*/
/* Set mail server */
/*--------------------------------------------------------------------*/
OPTIONS MAILSERVER(royalmail.com)
/*====================================================================*/
/* Part 1 - Check jobs */
/*====================================================================*/
/*--------------------------------------------------------------------*/
/* Read the JOBS DD into object JOBS then loop through it issuing a */
/* list command for each job to list the jobs. */
/*--------------------------------------------------------------------*/
READ JOBS OBJECT(JOBS) COUNT(0)
/* Loop input jobs */
DO J = 1 TO !@JOBS
VARSET DAYS = WORD("@V(@JOBS-!J.)",1)
VARSET ADID = WORD("@V(@JOBS-!J.)",2)
VARSET JOBNAME = WORD("@V(@JOBS-!J.)",3)
IF "!JOBNAME" = "ALL" THEN /* List all jobs in appl? */
VARSET JOBNAME = "*" /* Set jobname to wildcrd*/
VARSET RUNCHECK = SUBSTR("!DAYS","!DOWNUM",1)
IF "!RUNCHECK" /= "." THEN /* Do we check job today? */
DO
/* List jobs, labelled CHKJOB for later test */
CHKJOB: LIST CPOPCOM ADID(!ADID) JOBNAME(!JOBNAME)
IF @CMD(CHKJOB.EQ.4) THEN /* Not found, tell us */
DO
WRITE REPORT " <tr style=""background-color: red;"">"
WRITE REPORT " <td>!ADID</td>"
WRITE REPORT " <td> </td>"
WRITE REPORT " <td> </td>"
WRITE REPORT " <td>!JOBNAME</td>"
WRITE REPORT " <td>Not found</td>"
WRITE REPORT " <td> </td>"
WRITE REPORT " </tr>"
END
IF @CMD(CHKJOB.EQ.0) THEN /* Found, list to object */
DO
LIST CPOPCOM ADID(!ADID) JOBNAME(!JOBNAME) OBJECT(OJOBS)
END
SETMAX POLICY(0) /* Set RC back to 0 */
END /* End runcheck */
END /* End J loop */
/*--------------------------------------------------------------------*/
/* Loop object OJOBS to produce report of jobs */
/*--------------------------------------------------------------------*/
DO X = 1 TO !@OJOBS
VARSET ADID @V(@OJOBS!X.-CPOPADI)
VARSET IA @V(@OJOBS!X.-CPOPIA)
VARSET IAD = TRANSLATE('EF/CD/AB GH:IJ',"!IA",'ABCDEFGHIJ')
VARSET OPNO @V(@OJOBS!X.-CPOPNO)
VARSET JOBNAME @V(@OJOBS!X.-CPOPJBN)
VARSET STATUS @V(@OJOBS!X.-CPOPST)
VARSET AE @V(@OJOBS!X.-CPOPAE)
VARSET AED = TRANSLATE('EF/CD/AB GH:IJ',"!AE",'ABCDEFGHIJ')
/*------------------------------------------------------------------*/
/* When status is C the job is complete so add a green row into the */
/* HTML table. If any other status add a red row. */
/*------------------------------------------------------------------*/
IF "!STATUS" = "C" THEN
DO
WRITE REPORT " <tr style=""background-color: lime;"">"
WRITE REPORT " <td>!ADID</td>"
WRITE REPORT " <td>!IAD</td>"
WRITE REPORT " <td>!OPNO</td>"
WRITE REPORT " <td>!JOBNAME</td>"
WRITE REPORT " <td>Complete</td>"
WRITE REPORT " <td>!AED</td>"
WRITE REPORT " </tr>"
END
ELSE
DO
WRITE REPORT " <tr style=""background-color: red;"">"
WRITE REPORT " <td>!ADID</td>"
WRITE REPORT " <td>!IAD</td>"
WRITE REPORT " <td>!OPNO</td>"
WRITE REPORT " <td>!JOBNAME</td>"
WRITE REPORT " <td>!STATUS</td>"
WRITE REPORT " <td> </td>"
WRITE REPORT " </tr>"
END
END /* END DO X LOOP */
/*--------------------------------------------------------------------*/
/* Add an HTML tag to end the table definition */
/*--------------------------------------------------------------------*/
WRITE REPORT "</table>"
WRITE REPORT "<br>"
/*====================================================================*/
/* PART 2 - CHECK APPLICATIONS */
/*====================================================================*/
/*--------------------------------------------------------------------*/
/* Read the APPS DD into object APPS then loop through it issuing a */
/* select commadn for each application, then build report table rows. */
/*--------------------------------------------------------------------*/
READ APPS OBJECT(APPS) COUNT(0)
DO X = 1 TO !@APPS
VARSET COLOR = "LIME"
VARSET DAYS = WORD("@V(@APPS-!X.)",1)
VARSET INADID = WORD("@V(@APPS-!X.)",2)
VARSET DAY = WORD("@V(@APPS-!X.)",3)
VARSET DESCR = SUBWORD("@V(@APPS-!X.)",4)
VARSET RUNCHECK = SUBSTR("!DAYS","!DOWNUM",1)
IF "!RUNCHECK" /= "." THEN
DO
IF "!DAY" = "0" THEN
DO
VARSET FINDIA = "!OYMD1"||"*"
END
ELSE
DO
VARSET OFFSET = "-"||"!DAY"
VARDATE FINDIA BASE(!OYMD1) OFFSET(!OFFSET)
VARSET FINDIA = "!FINDIA"||"*"
END
SELECT CPOC ADID(!INADID) IA(!FINDIA) STATUS(*) OBJECT(OAPPS)
IF @CMD(EQ.0) THEN
DO
VARSET ADID @V(@OAPPS-CPOCADI) /* ADID OF OBJECT */
VARSET IA @V(@OAPPS-CPOCIA) /* IA OF OBJECT */
VARSET IAD = TRANSLATE('EF/CD/AB GH:IJ',"!IA",'ABCDEFGHIJ')
VARSET STATUS @V(@OAPPS-CPOCST) /* STATUS OF OBJCT */
VARSET AC @V(@OAPPS-CPOCAC) /* COMPLETE DT/TM */
VARSET ACD = TRANSLATE('EF/CD/AB GH:IJ',"!AC",'ABCDEFGHIJ')
VARSET AA @V(@OAPPS-CPOCAA) /* COMPLETE DT/TM */
VARSET AAS = TRANSLATE('EF/CD/AB GH:IJ',"!AA",'ABCDEFGHIJ')
/*----------------------------------------------------------*/
IF "!ADID" = "PRPMD045" THEN
DO
VARSET DATE = SUBSTR("!AC",5,2)
VARSET CDATE = DATE('S')
VARSET CDAY = SUBSTR("!CDATE",3,6)
VARSET JDAY = SUBSTR("!AC",1,6)
VARSET HOUR = SUBSTR("!AC",7,2)
VARSET MINT = SUBSTR("!AC",9,2)
IF "!CDAY" > "!JDAY" THEN DO
IF "!MINT" = '00' THEN DO
VARSET H1 = 24-"!HOUR"
VARSET M1 = "!MINT"
VARSET ACD = "!ACD FILES SENT !H1 HR !M1 MIN EARLY"
END
ELSE DO
VARSET H1 = 23-"!HOUR"
VARSET M1 = 60-"!MINT"
VARSET ACD = "!ACD FILES SENT !H1 HR !M1 MIN EARLY"
END
END
ELSE DO
VARSET H1 = "!HOUR"
VARSET M1 = "!MINT"
VARSET ACD = "!ACD FILES DELAYED BY !H1 HR !M1 MIN"
VARSET COLOR = "#FFBF00"
END
END
/*--------------------------------------------------------------------*/
/* CALCULATE THE TIME BY WHICH ER FILES HAS BEEN SENT WITHER DELAYED */
/* OR EARLY , THE TIME IS DIFFERENT FOR MONDAY/TUESDAY I.E 01:30 HRS */
/* BST AND FOR REST DAYS IT IS 0000 HRS BST. */
/*--------------------------------------------------------------------*/
IF "!ADID" = "PRPMD220" THEN
DO
VARSET DATE = SUBSTR("!AC",5,2)
VARSET CDATE = DATE('S')
VARSET CDAY = SUBSTR("!CDATE",3,6)
VARSET JDAY = SUBSTR("!AC",1,6)
VARSET HOUR = SUBSTR("!AC",7,2)
VARSET MINT = SUBSTR("!AC",9,2)
IF "!DOWNUM" = "2" | "!DOWNUM" = "3" THEN
DO
/*--------------------------------------------------------------------*/
/* CASE WHEN FILES ARE SENT ON THE PREVIOUS DATE AS THE DATE ON WHICH*/
/* THE JCL WHICH CALL THIS WAPL RUNS. */
/*--------------------------------------------------------------------*/
IF "!CDAY" > "!JDAY" THEN DO
IF "!MINT" = "00" THEN DO
VARSET H1 = 25-"!HOUR"
VARSET M1 = "!MINT" + 30
VARSET ACD = "!ACD FILES SENT !H1 HR !M1 MIN EARLY"
END
ELSE DO
VARSET H1 = 24-"!HOUR"
VARSET M1 = 60-"!MINT" + 30
IF "!M1" > "60" THEN DO
VARSET H1 = "!H1" + 1
VARSET M1 = "!M1" - 60
END
VARSET ACD = "!ACD FILES SENT !H1 HR !M1 MIN EARLY"
END
END
/*--------------------------------------------------------------------*/
/* CASE WHEN FILES ARE SENT ON THE SAME DATE AS THE DATE ON WHICH */
/* THE JCL WHICH CALL THIS WAPL RUNS. */
/*--------------------------------------------------------------------*/
ELSE DO
VARSET H1 = "!HOUR"
VARSET M1 = "!MINT"
IF (("!H1" = "01") & ("!M1" <= "30")) THEN DO
VARSET M1 = 60- "!M1"
VARSET ACD = "!ACD FILES 0!M1 MIN EARLY"
END
ELSE IF (("!H1" = "00") & ("!M1" <= "30")) THEN DO
VARSET M1 = 30 - "!M1"
VARSET ACD = "!ACD FILES 01 HR !M1 MIN EARLY"
END
ELSE IF "!H1" = "00" & "!M1" > "30" THEN DO
VARSET M1 = 60 - "!M1"
VARSET ACD = "!ACD FILES 00 HR !M1 MIN EARLY"
END
ELSE IF "!H1" = "01" & "!M1" > "30" THEN DO
VARSET M1 = 30 - "!M1"
VARSET ACD = "!ACD FILES DELAYED BY 0 HR !M1 MIN"
VARSET COLOR = "#FFBF00"
END
ELSE IF "!H1" >='2' & "!M1" > '30' THEN DO
VARSET M0 = "!M1" - 30
VARSET COLOR = "#FFBF00"
VARSET H0 = "!H1" - 1
VARSET ACD = "!ACD FILES ARE DELAYED BY
!H0 HR !M0 MIN"
END
ELSE IF "!H1" >='2' & "!M1" <= '30' THEN DO
VARSET M0 = "!M1" + 30
VARSET H0 = "!H1" - 2
VARSET COLOR = "#FFBF00"
VARSET ACD = "!ACD FILES DELAYED BY
!H0 HR !M0 MIN"
END
END
END
/*--------------------------------------------------------------------*/
/* CASE WHEN FILES ARE SENT ON THE DAYS OTHER THAN MONDAY AND TUESDAY */
/* THE TIME HANDSHAKED IS 0000 HRS BST. */
/*--------------------------------------------------------------------*/
ELSE DO
IF "!CDAY" > "!JDAY" THEN DO
IF "!MINT" = "00" THEN DO
VARSET H1 = 24-"!HOUR"
VARSET M1 = "!MINT"
VARSET ACD = "!ACD FILES SENT !H1 HR !M1 MIN EARLY"
END
ELSE DO
VARSET H1 = 23-"!HOUR"
VARSET M1 = 60-"!MINT"
VARSET ACD = "!ACD FILES SENT !H1 HR !M1 MIN EARLY"
END
END
ELSE DO
VARSET H1 = "!HOUR"
VARSET M1 = "!MINT"
VARSET COLOR = "#FFBF00"
VARSET ACD = "!ACD FILES DELAYED BY !H1 HR !M1 MIN"
END
END
END
/*----------------------------------------------------------*/
/* WHEN THE STATUS IS C THE APPLICATION IS COMPLETE SO ADD */
/* A GREEN ROW TO OUR HTML TABLE. ANY OTHER STATUS ADD A */
/* RED ROW. */
/*----------------------------------------------------------*/
IF "!STATUS" = "C" THEN
DO
WRITE REPORT " <TR STYLE=""BACKGROUND-COLOR: !COLOR;"">"
WRITE REPORT " <TD>!DESCR</TD>"
WRITE REPORT " <TD>!ADID</TD>"
WRITE REPORT " <TD>!IAD</TD>"
WRITE REPORT " <TD>!STATUS</TD>"
WRITE REPORT " <TD>!AAS</TD>"
WRITE REPORT " <TD>!ACD</TD>"
WRITE REPORT " </TR>"
END
ELSE
DO
WRITE REPORT " <TR STYLE=""BACKGROUND-COLOR: RED;"">"
WRITE REPORT " <TD>!DESCR</TD>"
WRITE REPORT " <TD>!ADID</TD>"
WRITE REPORT " <TD>!IAD</TD>"
WRITE REPORT " <TD>!STATUS</TD>"
WRITE REPORT " <TD> </TD>"
WRITE REPORT " </TR>"
END
END
ELSE
DO
/*---------------------------------------------------------*/
/* If the application was not found add a red row to the */
/* HTML table */
/*---------------------------------------------------------*/
SETMAX POLICY(0) /* Set RC back to 0*/
VARSET FINDIAD = TRANSLATE('EF/CD/AB G',"!FINDIA",'ABCDEFG')
WRITE REPORT " <tr style=""background-color: red;"">"
WRITE REPORT " <td>!DESCR</td>"
WRITE REPORT " <td>!INADID</td>"
WRITE REPORT " <td>!FINDIAD</td>"
WRITE REPORT " <td>Not found</td>"
WRITE REPORT " <td> </td>"
WRITE REPORT " </tr>"
END
END
END
/*--------------------------------------------------------------------*/
/* Add an HTML tag to end the table definition */
/*--------------------------------------------------------------------*/
WRITE REPORT "</table>"
/*--------------------------------------------------------------------*/
/* Close the REPORT DD to ensure report records are written to it */
/* before sending the report. */
/*--------------------------------------------------------------------*/
CLOSE REPORT
/*--------------------------------------------------------------------*/
/* Turn off variable scanning as WAPL tries to replace @ and ! with */
/* values. */
/*--------------------------------------------------------------------*/
VARSUB NOSCAN
/*--------------------------------------------------------------------*/
/* Send the report by email concatentating the HDR,REPORT and TLR DD's*/
/* together to make the content of the mail. */
/*--------------------------------------------------------------------*/
SENDMAIL FROM(RMG-POH7@ROYALMAIL.COM)
TO(cg_itst_lot2b_mainframe.in@capgemini.com)
CC(roopa.a.sharma@capgemini.com
shubham.chauhan@capgemini.com richard.dealtry@atos.com)
SUBJECT(POH7 - Daily Health Check)
TEXTDD(HDR)
TEXTDD(REPORT)
TEXTDD(TLR)
10/28 11.23.54 EQQI200I ELSE
10/28 11.23.54 EQQI221F Unexpected THEN or ELSE <===
10/28 11.23.54 EQQI299I Statement completed - RC=12
10/28 11.23.54 EQQI107I Number of files written = 1
10/28 11.23.54 EQQI104I Records written to file REPORT = 167
10/28 11.23.54 EQQI099I WAPL complete - highest return code 12 - 6.96 (0.96) sec
READY
END
I haven't analyzed the whole thing, but looking at indentations it sems that you are missing an END after the block starting with
IF "!ADID" = "PRPMD220" THEN
DO
Thanks for taking a look .The PRPMD220 end completed at just before status = 'C'.
It does not have a else part, i am trying to do processing within one if for prpmd220. the problem occurs at when hours is 1 . there it is going in all loops of nested if rather than one loop
Joined: 10 May 2007 Posts: 2454 Location: Hampshire, UK
Some languages are picky about indentation - I do not know if this one, whatever it is, is one of those. Just in case it is, there is one block where the code has not been indented. I would also standardise the coding - you have some IF/THEN/DOs on one line whilst on others you have IF THEN on one line and the DO on the next. Ensure you indent by the same amount each time.
Once you have done that use ISPF editor facilities to exclude everything then find all your IFs, THENs, DOs, ENDs and ELSEs. Then, working from the deepest nesting out, exclude complete sets of IF/THEN/ELSEs.
yes Nic absolutely.. this work load automation programming is very much concerned about indentation ..else lot of parsing errors. Meanwhile I have changed the and condition with nested if.. let see if it is good to run.