A job to submit a job

  • Post category:JCLUtilities
  • Reading time:1 mins read

A simple trick that is often used in more complex JCL scripts, is to submit a job from a job. z/OS has a facility for this called the Internal Reader. The name Internal Reader stems from the old days when physical devices where used to read input in punch cards. These physical devices where called (external) readers. The Internal Reader is a logical device operating functionally, but virtually, like the physical device from the old days.

Anyway, this is the JCL.

//SUBJOB EXEC PGM=IEBGENER
//SYSIN DD DUMMY
//SYSPRINT DD DUMMY
//SYSUT1 DD DSN=DATASET.NAME.JCL(NEXTJOB),DISP=SHR
//SYSUT2 DD SYSOUT=(A,INTRDR)

With this JCL you copy the JCL script in dataset DATASET.NAME.JCL(NEXTJOB) to the internal reader, which fundamentally submit the content as a job.

Filewatch utility – file triggering

  • Post category:JCLUtilities
  • Reading time:2 mins read

The filewatch utility is not a well known utility, that can be very handy. I have used it especially when I needed process a unix file after it has been copied to a certain directory.

This is the documentation about the filewatch utility:

https://www.ibm.com/support/knowledgecenter/SSRULV_9.3.0/com.ibm.tivoli.itws.doc_9.3/zos/src_man/eqqr1hfszfstrig.htm

Th job below is submitted and then waiting and activated when there is a change in the input directory /yourdirectory/testfileloc

The job itself moves the files in the input directory to a processing directory, starts the next “watch” job and then the processing job for the files in the processing directory.

The setup is clearly to test the mechanism – and not necessarily a model for a production-like situation. In a production situation you might want to use TWS applications etc, but that is up to your application design of course.

I hope this helps.

 //STEP01  EXEC PGM=EQQFLWAT,PARM='/-c wcr -dea 900 -i 20
 //             -r 123 -t 3 -fi /yourdirectory/testfileloc'
 //*
 //* Register and move files
 //RUNSCRPT EXEC PGM=IKJEFT01,REGION=0M
 //STDOUT   DD SYSOUT=*
 //STDERR   DD SYSOUT=*
 //SYSTSPRT DD SYSOUT=*
 //SYSTSIN  DD *
 BPXBATSL SH  -
   mv /yourdirectory/testfileloc* /yourdirectory/testfileloc/processing
 //*
 //* Then kick off separate job
 //* - Next filewatch job
 //*
 //SUBJOB   EXEC PGM=IEBGENER
 //SYSIN    DD DUMMY
 //SYSPRINT DD DUMMY
 //SYSUT1   DD DISP=SHR,DSN=YOURPDS.JCL(EQQFLWAT)
 //SYSUT2   DD SYSOUT=(A,INTRDR)
 //*
 //* - Processing job
 //*
 //SUBJOB   EXEC PGM=IEBGENER
 //SYSIN    DD DUMMY
 //SYSPRINT DD DUMMY
 //SYSUT1   DD DISP=SHR,DSN=YOURPDS.JCL(PROCJOB)
 //SYSUT2   DD SYSOUT=(A,INTRDR)
 //*
 //* 

Code page conversion of a file in a batch job

  • Post category:JCLUtilities
  • Reading time:2 mins read

In this post a sample of how to perform a code page conversion of z/OS Unix files in a batch job. The different iconv utility lines show invocation for different code pages.

//*                                      
//STEP1    EXEC PGM=BPXBATCH   
//STDERR   DD SYSOUT=*  
//STDPARM  DD   *              
 SH  iconv -f UTF-8 -t IBM-1140 < inutf8 > outebc 
/*                                                     
//               
 SH  iconv -f IBM-1140 -t IBM-1252 < inebc > out1252 
//  
 SH  iconv -f IBM-1252 -t IBM-1140 < in1252 > out1140 
//     
 SH  iconv -f IBM-1140 -t UTF-8 < inebc > oututf8  
 //                       

Copying Unix files to MVS Datasets

  • Post category:JCLUtilities
  • Reading time:1 mins read

As mentioned in the previous post, another sample. This one copies a z/OS unix file to an MVS dataset. Also using OCOPY.

//STEP5 EXEC PGM=IKJEFT01 
//INUNIX DD PATH='/mydir/infile.txt',PATHOPTS=(ORDONLY) 
//OUTMVS DD DSN='TEST.MVS.OUTDS',DISP=SHR 
//* 
//SYSTSPRT DD SYSOUT=* 
//SYSTSIN DD * 
//SYSTSIN DD * 
 OCOPY IND(INUNIX) OUTDD(OUTMVS) TEXT CONVERT(YES) PATHOPTS(USE) 
/* 
 

Copying MVS Datasets to Unix files

  • Post category:JCLUtilities
  • Reading time:1 mins read

Recently I had to get some people started with a few utilities. I thought to share this here. They will be in the next few posts for searchability reasons.

There are more ways to Rome, as we say here, so please feel free share you variants in a comment. (I unfortunately need manually curate comments to filter out the spam which is even with this small site overwhelming.)

//STEP1 EXEC PGM=IKJEFT01
//INMVS DD DSN=TEST.TRADMVS.DATA,
// DISP=SHR
//OUTFILE DD FILEDATA=TEXT,
// PATHOPTS=(OWRONLY,OCREAT,OTRUNC),
// PATHMODE=SIRWXU,
// PATH='/mydir/myunixfile.txt’
//SYSTSPRT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*//SYSTSIN DD *
 OCOPY IND(INMVS) OUTDD(OUTFILE)
//*

Here’s a link to the IBM documentation on OCOPY.

Execute an operator command via JCL

  • Post category:JCL
  • Reading time:1 mins read

In my previous post I shared a way to execute operator command from a batch job using Rexx and SDSF. That is of course a bit cumbersome if you just want to fire off a fixed operator command.

Therefore here the simplest way to execute an operator command:

https://github.com/execpgm/execpgm-assets/blob/master/Tools/OperatorCommandJCL.txt

//...jobcard                     
//EXECCMD EXEC PGM=IEFBR14                        
// COMMAND 'D A,L'  

Executing operator command froms batch – using Rexx and SDSF

  • Post category:JCLRexxSDSF
  • Reading time:2 mins read

One of the many way to execute an operator command from a batch rexx program.

With this solution here, with Rexx and SDSF, you can embed the commands in more complex business logic, and use Rexx variables to dynamically establish values for the commands to be issued.

By the way I have started a repository on GitHub on which I will share assets in the future.

https://github.com/execpgm/execpgm-assets

I have added this tool here:

https://github.com/execpgm/execpgm-assets/tree/master/Tools

Direct link:

https://github.com/execpgm/execpgm-assets/blob/master/Tools/OperatorCommandSDSFbatch.txt

//GENER   EXEC PGM=IEBGENER 
//SYSPRINT DD SYSOUT=* 
//SYSIN DD ,BLKSIZE=800,LRECL=80 
 GENERATE 
 LABELS DATA=ALL 
/*
//SYSUT1  DD *  
/* REXX /  
RC=ISFCALLS('ON')  
YOURSTC = "MYSTC"  
ADDRESS SDSF "ISFEXEC '/P "YOURSTC"'"  
ISFDELAY="5"  /* REPLY IS IN STEM ISFULOG. */ 
/*
//SYSUT2  DD  DSNAME=&&DS1(CMD),DISP=(NEW,PASS), 
//       UNIT=SYSDA,SPACE=(TRK,(5,,2)) 
//* 
//RDWRJ    EXEC PGM=IKJEFT01 
//SYSPRINT DD SYSOUT=* 
//SYSPROC  DD DISP=SHR,DSN=&&DS1 
//SYSTSPRT DD SYSOUT=* 
//SYSTSIN DD * 
 CMD 
/* 
//

Db2 SQL in batch

  • Post category:JCL
  • Reading time:1 mins read

Again a simple solution for a common problem: how to run a Db2 query from a batch script. Here we use the utility DSNTEP2 that is provided for this purpose with the Db2 installation.

In the STEPLIB, specify your names for Db2 runtime libraries.

In the SYSTEM (xxxx) clause specify your Db2 subsystem.

The SQL in the SYSIN label can be taken from in-stream, or from a dataset as below.

//GO EXEC PGM=IKJEFT01,DYNAMNBR=20 
//STEPLIB DD DSN=SYS2.SDSNEXIT,DISP=SHR 
//        DD DSN=SYS2.SDSNLOAD,DISP=SHR     
//SYSTSPRT DD SYSOUT=*  
//SYSTSIN DD * 
 DSN SYSTEM (xxxx)                                       
 RUN PROG (DSNTEP2)
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//*SYSIN    DD DISP=SHR,DSN=YOURDSN.DB2.SQL(YOURSQL) OR
//SYSIN    DD *
 SELECT * FROM YOURTABLE
/*

//Dean

Change the volume of the entry for a dataset in a catalog

  • Post category:JCLUtilities
  • Reading time:1 mins read

When you have defined a dataset in the wrong catalog – in this case a master catalog – and you want to correct this you can use this technique.The DELETE NOSCRATCH option assures only the catalog entry is deleted. If you would omit this, the entire dataset would be deleted, so be cautious.

//DEFCAT   EXEC PGM=IDCAMS          
//STEPCAT DD DISP=SHR,DSN=SYS1.MSTRCTLG           
//SYSPRINT DD SYSOUT=*                          
//SYSIN    DD *                  
DELETE (SYS1.DATASET) NVSAM NOSCRATCH CAT(SYS1.MSTRCTLG)     
DEFINE NVSAM (NAME(SYS1.DATASET) DEVT(3390) VOL(VOL123)) - 
            CAT(SYS1.MSTRCTLG)   

//Pierre G

Allocate a page dataset / page space for new system, in a second master catalog

  • Post category:JCL
  • Reading time:1 mins read

This job shows you how you can define a page dataset in another master catalog than the currently active master catalog. This technique is typically used when you are building a new system from a driver system. The master catalog referred to via the CATALOG statement below is the to-be master catalog of the new system you are building.

//DEFPAGE EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//PAGE2    DD UNIT=3390,VOL=SER=PSYS1B,DISP=OLD
//SYSIN    DD *
  DEFINE PAGESPACE( -
      FILE(PAGE2) -
      NAME(SYS1.MVST.PLPA2) -
      CYLINDERS(300) -
      VOLUME(PSYS1B) ) -
    CATALOG(SYS1.MSTRCAT0)
/* 

//Pierre G.