How to Perform a Multiple Search and Copy of Members into a second PDS.

Document ID : KB000029453
Last Modified Date : 14/02/2018
Show Technical Document Details

For purposes of this knowledge document, we will be searching for two strings found within the same PDS member. For example, we will look for 'IEBCOPY' and also 'PROD.LOADLIB' found within the same member and then write the found member into a new PDS.  It is assumed obviously that this is a PDS containing JCL.

This will be accomplished using the CA FileMaster Plus batch job CAWABATC.  It would be desirable to construct the control cards in such a way that this job can be done in one step.

It was found after research that this task requires as many job steps running CAWABATC as there are search strings. In the first step search for your first string, i.e., 'IEBCOPY', and copy those members into a new intermediate PDS.  In the second step search for your second search string, i.e. 'PROD.LOADLIB' and copy those members into your second and final result PDS that contains both 'IEBCOPY' and 'PROD.LOADLIB'.  You will need to pre-allocate the two JCL PDSs prior to running your multiple search strings CAWABATC batch job.

The JCL to accomplish this looks like this:

//JOBCARD
//*
//COPYPDS1 EXEC PGM=CAWABATC,REGION=0M
//STEPLIB  DD DSN=CAWABATC.LOAD,DISP=SHR
//SYSOUT   DD *
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSLIST  DD SYSOUT=A
//SYSUT1   DD DSN=YOUR.INITIAL.JCL.PDS,
//            DISP=SHR
//SYSUT1O  DD DSN=FIRST.JCL.PDS,
//            DISP=SHR
//SYSIN    DD *
  COPY,
  REPLACEMEM(Y),
  SELMEMIF(1,0,EQ,C'IEBCOPY')
/*
//COPYPDS2 EXEC PGM=CAWABATC,REGION=0M
//STEPLIB  DD DSN=CAWABATC.LOAD,DISP=SHR
//SYSOUT   DD *
//SYSPRINT DD SYSOUT=*
//SYSUDUMP DD SYSOUT=*
//SYSLIST  DD SYSOUT=A
//SYSUT1   DD DSN=FIRST.JCL.PDS,
//            DISP=SHR
//SYSUT1O  DD DSN=FINAL.JCL.PDS,
//            DISP=SHR
//SYSIN    DD *
  COPY,
  REPLACEMEM(Y),
  SELMEMIF(1,0,EQ,C'PROD.LOADLIB')
/*
//
 
Note that if you desire to search for 3 strings in a PDS member, you will require 3 CAWABATC job steps and 3 result PDSs that will filter down your member list to the final PDS.  Remember that as a rule, each subsequent PDS should be smaller than the previous one, so you should pre-allocate each one with smaller space requirements.  The worst case is all members contain the search strings then each PDS would need to have the same space allocation as the initial PDS, but this is worst case and I would expect that each PDS will be smaller as one filters using the search strings.