MainframeSupports
tip week 7/2019:

For many years I have put a lot of effort in avoiding ISPF File Tailoring when generating jobs. I have always found ISPF File Tailoring extremely difficult to use. I have now reached a point where I think I have found the ultimate replacement in a small smart REXX procedure. Everything can be coded in pure REXX which makes it easy to use in batch where File Tailoring is hard to get to work in all situations.

Here is an example showing the generated job in an ISPF EDIT session and thus is not suitable for batch processing. You can simply replace the ADDRESS ISPEXEC line with a SUBMIT command and then it will work in both batch and TSO.

/* REXX */                                                   
ARG PARM                                                     
GENUSER = USERID()                                           
CALL GENJOB                                                  
ADDRESS ISPEXEC 'EDIT DATASET(ISPF.JCL(GENJOB))'             
EXIT                                                         
GENJOB:                                                  
  DROP JCL.                                                  
  JCLNO = 0                                                  
  CALL JL '//'GENUSER'G JOB ,GENERATED,CLASS=E,MSGCLASS=F'   
  CALL JL '// COND=(4,LT),REGION=0M,NOTIFY='GENUSER          
  CALL JL '//*'                                              
  CALL JL '//IDCAMS   EXEC PGM=IDCAMS'                       
  CALL JL '//SYSPRINT DD SYSOUT=*'                           
  CALL JL '//SYSIN    DD *'                                  
  CALL JL ' '                                                
  CALL JL '/*'                                               
  JCL.0 = JCLNO                                              
  ADDRESS TSO                                                
  "ALLOC FI(JCL) DA(ISPF.JCL(GENJOB)) SHR REUSE"             
  "EXECIO * DISKW JCL (STEM JCL. OPEN FINIS)"                
  "FREE FI(JCL)"                                             
RETURN                                                       
JL:                                                          
 ARG JCLLINE                                                 
 JCLNO = JCLNO + 1                                           
 JCL.JCLNO = JCLLINE                                         
RETURN 0                                                     

The example builds a job running a dummy IDCAMS step just to illustrate the readibility of the job you want to generate when you use the procedure JL (for JobLine). To make JL work properly you need to start generating the job by issuing a DROP JCL. followed by JCLNO = 0. When you are finished generating the job remember to set JCL.0 = JCLNO, otherwise the EXECIO statement will not work properly. If you omit DROP JCL. it will also work as long as you only generate one job in the same REXX, but the second time EXECIO is executed it might not work as expected so please remember DROP no matter what.

In the example I save the result of generating the job in dataset userid.ISPF.JCL, but already here yu can submit the job by changing the ALLOC to "ALLOC FI(JCL) SYSOUT WRITER(INTRDR)". And maybe you are wondering why I use RETURN 0 in the JL procedure. This enables you to call JL using ?=JL('//* SOME JCL'). It is shorter to write but then you have to terminate all JL calls with a ) and I am too lazy for that and I think it is less readable, but you may have a different taste.

Previous tip in english        Forrige danske tip        Tip list