use conditional codes



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

use conditional codes

Postby dn2012 » Tue Feb 28, 2012 5:33 am

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                                                         
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: use conditional codes

 

Re: use conditional codes

Postby steve-myers » Tue Feb 28, 2012 7:09 am

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?
steve-myers
Global moderator
 
Posts: 1885
Joined: Thu Jun 03, 2010 6:21 pm
Has thanked: 4 times
Been thanked: 197 times

Re: use conditional codes

Postby NicC » Tue Feb 28, 2012 11:03 am

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: use conditional codes

Postby Akatsukami » Tue Feb 28, 2012 4:16 pm

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.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1053
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: use conditional codes

Postby dn2012 » Tue Feb 28, 2012 8:47 pm

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
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: use conditional codes

Postby enrico-sorichetti » Tue Feb 28, 2012 9:28 pm

the JCL condition code checking logic does not depend on the programs being executed, just on the return code
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: use conditional codes

Postby dick scherrer » Wed Feb 29, 2012 7:07 am

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).
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: use conditional codes

Postby dn2012 » Wed Feb 29, 2012 8:56 pm

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
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: use conditional codes

Postby dn2012 » Wed Feb 29, 2012 10:50 pm

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
dn2012
 
Posts: 114
Joined: Thu Feb 16, 2012 6:10 am
Has thanked: 0 time
Been thanked: 0 time

Re: use conditional codes

Postby NicC » Wed Feb 29, 2012 11:49 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post