Page 1 of 1

use conditional codes

PostPosted: Tue Feb 28, 2012 5:33 am
by dn2012
Hello,

I have been requested to use conditional codes in the Job attached. Currently our Job do not stop at an abend step.They want job should stop at an abend.
I am new to JCL.
I do have some programing experience in other languages (PL/SQL, SQL).

//*-----------------------------------------------------------------*       
//*                   DELETE/DEFINE IMFTABLE VSAM FILE              *       
//*-----------------------------------------------------------------*       
//*                                                                         
//IMF1     EXEC PGM=IDCAMS                                                 
//DD1 DD DISP=OLD,DSN=IMSTESTA.IMFTABLE                                 
//SYSPRINT DD SYSOUT=*                                                     
//SYSIN    DD *                                                             
  DELETE  (IMSTESTA.IMFTABLE) CLUSTER PURGE                             
  DEFINE CLUSTER(                   -                                       
               NAME(IMSTESTA.IMFTABLE) -                                 
               FREESPACE(0 0)     -                                         
               INDEXED              -                                       
               KEYS(24 0)           -                                       
               RECORDSIZE(80 80)    -                                       
               SHAREOPTIONS(3 3)    -                                       
               ERASE                -                                       
               UNIQUE               -                                       
               CYLINDERS(40 10)     -                                       
                        )           -                                       
         DATA(                             -                                   
              NAME(IMSTESTA.IMFTABLE.DATA) -                                 
              CONTROLINTERVALSIZE(8192)    -                                   
             )                             -                                   
         INDEX(                            -                                   
               NAME(IMSTESTA.IMFTABLE.INDEX) -                               
             CONTROLINTERVALSIZE(8192))                                         
/*                                                                             
//*                                                                             
//*-----------------------------------------------------------------*           
//*                   DO LISTCAT OF IMFTABLE VSAM FILE              *           
//*-----------------------------------------------------------------*           
//*                                                                             
//LISTCAT   EXEC  PGM=IDCAMS                                                   
//SYSPRINT  DD    SYSOUT=*                                                     
//SYSIN     DD    *                                                             
         LISTCAT ENTRIES(IMSTESTA.IMFTABLE) ALL                             
//*                                                                             
//*-----------------------------------------------------------------*           
//*            SORT DATA BEFORE REPRO INTO VSAM FILE                *           
//*-----------------------------------------------------------------*     
//*                                                                       
//SORT    EXEC PGM=SORT                                                   
//SORTIN   DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE(DEFAULT)             
//         DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE(CWS)                 
//         DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE(TCIS0223)           
//         DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE(PDB) ## 10/28/11     
//         DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE(ETRS1211)           
//SORTOUT  DD DISP=(,CATLG,DELETE),                                     
//            DSN=IMSTESTA.IMF310.ITD.SOURCE.DATA.GDG(+1),                 
//            SPACE=(CYL,(10,10)),UNIT=SYSDA                       
//SYSOUT   DD SYSOUT=*                                                                                   
//*    SORT FIELDS=(1,32,CH,A)                                             
//SYSIN    DD *                                                           
  SORT FIELDS=(1,32,CH,A)                                                 
  SUM FIELDS=NONE                                                         
/*                                                                         
//*-----------------------------------------------------------------*     
//*              PRINT SORTED DATA (FOR VALIDATION)                 *     
//*-----------------------------------------------------------------*     
//*                                                                       
//*PRINT   EXEC PGM=IEBGENER                                               
//*SYSUT1   DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE.DATA.GDG(0)         
//*SYSUT2   DD SYSOUT=*             
//*SYSPRINT DD SYSOUT=*                                                   
//*SYSIN    DD DUMMY                                                       
//*                                                                       
//*                                                                       
//*-----------------------------------------------------------------*     
//*                    BUILD IMFTABLE VSAM FILE                     *     
//*-----------------------------------------------------------------*     
//*                                                                       
//STEP01  EXEC PGM=IDCAMS                                               
//SYSPRINT DD SYSOUT=*                                                   
//SYSUDUMP DD SYSOUT=*                                                   
//PRINTO   DD SYSOUT=*                                                   
//INPUT    DD DISP=OLD,DSN=IMSTESTA.IMF310.ITD.SOURCE.DATA.GDG(0)       
//OUTPUT   DD DISP=OLD,DSN=IMSTESTA.IMFTABLE                         
//SYSIN    DD  *                                                         
   REPRO INFILE(INPUT) OUTFILE(OUTPUT)                                   
   END                                                                   
/*                                                                       
//*-------------------------------------------------------*             
//*    TELL OPERATIONS THAT THIS JOB FAILED DUE TO ABEND  *             
//*-------------------------------------------------------*             
//ABEND1   EXEC PGM=ITDWTOR,COND=ONLY                                   
//STEPLIB  DD  DSN=IMSB.PGMLIB,DISP=SHR                                 
//SYSUDUMP DD  SYSOUT=*                                                 
//SYSIN    DD  DSN=IMSTESTA.CNTRL(IMFTBLE),DISP=SHR                     
//*                                                                     
   REPRO INDATASET(IMSTESTA.IMF310.ITD.SOURCE(IMFTABLE)) -               
                 OUTDATASET(IMSTESTA.IMFTABLE)                       
        END                                                         

Re: use conditional codes

PostPosted: Tue Feb 28, 2012 7:09 am
by steve-myers
You do realize, I hope, that the second IDCAMS step - the one that does the REPRO - is not using the same dataset that is the output from the sort step? Or did this step come from a second job that was run if the first job completed OK?

Re: use conditional codes

PostPosted: Tue Feb 28, 2012 11:03 am
by NicC
A job will ALWAYS stop at a step that abends UNLESS you provide condition codes on subsequent steps to ignore the abend. However, a non-zero return code is not an abend so execution continues UNLESS condition codes say otherwise.
You do not need to program to use JCL condition codes as JCL is not a programming language. (Neither are PL/SQL or SQL - they are query languages. JCL is a Job Control language).
You need to refer to the JCL Reference manual and User Guide manuals - look up COND parameter and IF/THEN/ELSE/ENDIF in the Reference manual index and the chapter on Processing Control in the User Guide (chapter 10 in my version).
One way to get execution to stop is to try and execute a non-existent program (EXEC PGM=NOTFOUND) when you get an unsatisfactory return code.

Re: use conditional codes

PostPosted: Tue Feb 28, 2012 4:16 pm
by Akatsukami
To enlarge on NicC's reply: most shops have -- and have had for decades -- tiny little programs written in-house that provide a controllable abend. The TS should overcome his fear of talking to his senpai about anything save cricket and Bollywood and ask how this is done at heesh site.

Re: use conditional codes

PostPosted: Tue Feb 28, 2012 8:47 pm
by dn2012
I am thinking to use following code in LISTCAT step.

//LISTCAT EXEC PGM=IDCAMS, COND=(0,NE,IMF1)

what do you think? Will it work with IDCAMS

Thanks

Re: use conditional codes

PostPosted: Tue Feb 28, 2012 9:28 pm
by enrico-sorichetti
the JCL condition code checking logic does not depend on the programs being executed, just on the return code

Re: use conditional codes

PostPosted: Wed Feb 29, 2012 7:07 am
by dick scherrer
Hello,

The jcl posted and the question have nothing to do with an "abend". . .

You need to understand the difference between an abend (System or User) and the intention to control processing due to some return-code(s).

Re: use conditional codes

PostPosted: Wed Feb 29, 2012 8:56 pm
by dn2012
I have used following logic:

EXEC PGM=IDCAMS,COND=(0,NE,IMF1) --- If previous job IMF1 not equal to zero, it will not run.
EXEC PGM=SORT,COND=(0,NE,LISTCAT)
EXEC PGM=IEBGENER,COND=(0,NE,SORT)

Does it make sense?

Thanks

Re: use conditional codes

PostPosted: Wed Feb 29, 2012 10:50 pm
by dn2012
COND Codes where not working in your Job.

000C,00000000,NONZERO,D120229,T0856,IDCAMS
#(001) PGM(IDCAMS ) ELAPSED(00:00:00) COMP(00012)
0000,00000000,FLUSHED,D120229,T0856,IDCAMS
#(002) PGM(IDCAMS ) NOT EXECUTED
#(003) PGM(SORT ) ELAPSED(00:00:01) COMP(00000)
000C,00000000,NONZERO,D120229,T0856,IDCAMS
#(004) PGM(IDCAMS ) ELAPSED(00:00:01) COMP(00012)
0000,00000000,FLUSHED,D120229,T0856,ITDWTOR
#(005) PGM(ITDWTOR ) NOT EXECUTED

) ELAPSED(00:00:02) TURNAROUND(00:00:02)

Any help will be appreciated

Re: use conditional codes

PostPosted: Wed Feb 29, 2012 11:49 pm
by NicC
Stop duplicate posting.

You cannot use a condition code to refer to another job. Also, show the full EXEC statements from the // to end of statement.