How can I add lines to the end of each member in a PO/PDS?

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

How can I add lines to the end of each member in a PO/PDS using CAWABATC - CA File Master in batch?

Answer:

Up to now there is no possibility in CA File Master to add lines directly to each member in a Partitioned Organized Data Set (PO/PDS).

Therefore, you have to use sequential work files (PS) to meet that goal.

The following job is doing this all together. See comments in the ADDRECS step at SYSIN DD, please.

 

 

//*------------------------------------------------------------------* 

//   EXPORT SYMLIST=(OUTFILE)                                          

//   SET    STORCLS='TSO'                                              

//   SET     FMLOAD='your.File_Master.CDBILOAD'                             

//   SET     INFILE='your.PO.DSN'                             

//   SET    OUTFILE='your.new.PO.DSN'                        

//   SET    WRKCYLS='1'            primary and secondary work space    

//   SET    OUTCYLS='1'            primary and secondary output space  

//   SET    OUTBLKS='100'          output directory blocks             

//   SET    SYSOUTC='*'            SYSOUT class                        

//*------------------------------------------------------------------* 

//ADDRECS   EXEC PGM=CAWABATC,REGION=3M                                 

//STEPLIB   DD DISP=SHR,DSN=&FMLOAD                                    

//INFILE    DD DISP=SHR,DSN=&INFILE                                    

//SYSLIST   DD SYSOUT=&SYSOUTC                                         

//SYSPRINT  DD SYSOUT=&SYSOUTC                                         

//WORK01   DD DSN=&&WORK01,SPACE=(CYL,(&WRKCYLS,&WRKCYLS))             

//WORK02   DD DSN=&&WORK02,SPACE=(CYL,(&WRKCYLS,&WRKCYLS))             

//WORK03   DD DSN=&&WORK03,SPACE=(CYL,(&WRKCYLS,&WRKCYLS))             

//WORKPS   DD DSN=&&WORKPS,SPACE=(CYL,(&WRKCYLS,&WRKCYLS)),            

//            DISP=(NEW,CATLG,DELETE)                                  

//EOFLINE  DD *                                                        

***** EOF                                                               

/*                                                                     

//SYSIN    DD *                                                        

*--------------------------------------------------------------------* 

*                                                                      

*   The following COPY and READ commands are going to:                 

*                                                                       

*   1. COPY the PO/PDS members from INFILE to WORK01 (PS).             

*                                                                      

*   2. Copy WORK01 to WORK02 via READ and adding an '***** EOF' line   

*      to the end of each "member" by using two IF statements          

*      (when the second IF is true, File Master first writes the       

*       new lines and lastly writes the lines from INFILE(WORK01)).    

*                                                                       

*   3. COPY WORK02 to WORK03 to correctly position the '***** EOF'

*      record for the first and last "members".

*                                                                      

*   4. COPY WORK03 to the final PS data set (WORKPS), removing      

*      '***** EOF' and adding the lines you would like to add        

*      to the end of each PO member.                                    

*                                                                       

*   In the last job step of this job, WORKPS is being copied back      

*   to a new PO/PDS by using IEBGENER.                                 

*                                                                      

*--------------------------------------------------------------------* 

  COPY INFILE(INFILE),OUTFILE(WORK01)                                  

  READ INFILE(WORK01),                                                 

    IF(1,14,NE,T'./  ADD  NAME='),                                      

      WRITE(WORK02),                                                   

    IF(1,14,EQ,T'./  ADD  NAME='),                                     

      PADCHAR(C' '),                                                   

      MOVE(CLEAR),                                                     

      MOVE(1,T'***** EOF'),                                            

      WRITE(WORK02),                                                   

      MOVE(CLEAR),                                                      

      MOVE(1,0,1),                                                     

      WRITE(WORK02)                                                    

  COPY INFILE(WORK02),RID(2),OUTFILE(WORK03,NOCLOSE)                   

  COPY INFILE(EOFLINE),OUTFILE(WORK03,CLOSE)                           

  READ INFILE(WORK03),                                                 

    IF(1,9,NE,T'***** EOF'),                                           

      WRITE(WORKPS),                                                    

    IF(1,9,EQ,T'***** EOF'),                                           

      PADCHAR(C' '),                                                   

      MOVE(CLEAR),                                                     

*                                                                       

*  change following set of lines according to your needs -->           

*                                                                      

      MOVE(1,T'//*** NEW LINE 1 ADDED TO THE END OF THIS MEMBER ***'), 

      WRITE(WORKPS),                                                   

      MOVE(CLEAR),                                                     

      MOVE(1,T'//*** NEW LINE 2 ADDED TO THE END OF THIS MEMBER ***'), 

      WRITE(WORKPS),                                                   

      MOVE(CLEAR),                                                     

      MOVE(1,T'//*** NEW LINE 3 ADDED TO THE END OF THIS MEMBER ***'), 

      WRITE(WORKPS)                                                     

/*                                                                     

//*------------------------------------------------------------------* 

//DELETE   EXEC PGM=IDCAMS                                             

//SYSPRINT DD SYSOUT=&SYSOUTC                                          

//SYSIN    DD DATA,SYMBOLS=JCLONLY,DLM=##                            

  DELETE   &OUTFILE      PURGE                                       

  IF LASTCC=8 THEN SET MAXCC=0                                        

##                                                                   

//*------------------------------------------------------------------*

//*   Copy WORKPS to a new PO/PDS                                    

//*------------------------------------------------------------------*

//PS2PDS    EXEC   PGM=IEBUPDTE,PARM=NEW                             

//SYSUT2    DD DSN=&OUTFILE,                                         

//             SPACE=(CYL,(&OUTCYLS,&OUTCYLS,&OUTBLKS)),              

//             LIKE=&INFILE,                                         

//             DISP=(NEW,CATLG,DELETE),STORCLAS=&STORCLS             

//SYSPRINT  DD SYSOUT=&SYSOUTC                                       

//SYSIN     DD DISP=SHR,DSN=&&WORKPS                                  

 

 

Before running the job above - this is one member from the INFILE:

 

BROWSE    EUADG.T1603254.TESTPO(MBR00001)          Line 0000000000 Col 001 080

Command ===>                                                  Scroll ===> CSR

********************************* Top of Data **********************************

//JOB00001 JOB (999999999),XXXXXXXXXXXX,                                       

//      CLASS=B,MSGCLASS=X,REGION=0M,                                          

//      MSGLEVEL=(1,1),NOTIFY=&SYSUID                                          

//*------------------------------------------------*                           

//ST00001   EXEC  PGM=PGM00001                                                 

//DD00001   DD   DISP=SHR,DSN=HLQ.I00001.LLQ                                   

//DD00002   DD   DISP=SHR,DSN=HLQ.I00002.LLQ                                   

//DD00003   DD   DISP=SHR,DSN=HLQ.I00003.LLQ                                   

//DD00004   DD   DISP=SHR,DSN=HLQ.I00004.LLQ                                   

//DD00005   DD   DISP=SHR,DSN=HLQ.I00005.LLQ                                   

******************************** Bottom of Data ********************************

 

After running the job above - new PO/PDS - the green lines are added to each member in the PDS:

 

BROWSE    EUADG.T1603254.TESTPO.NEW(MBR00001)      Line 0000000000 Col 001 080

Command ===>                                                  Scroll ===> CSR

********************************* Top of Data **********************************

//JOB00001 JOB (999999999),XXXXXXXXXXXX,                                       

//      CLASS=B,MSGCLASS=X,REGION=0M,                                          

//      MSGLEVEL=(1,1),NOTIFY=&SYSUID                                           

//*------------------------------------------------*                           

//ST00001   EXEC  PGM=PGM00001                                                 

//DD00001   DD   DISP=SHR,DSN=HLQ.I00001.LLQ                                    

//DD00002   DD   DISP=SHR,DSN=HLQ.I00002.LLQ                                   

//DD00003   DD   DISP=SHR,DSN=HLQ.I00003.LLQ                                   

//DD00004   DD   DISP=SHR,DSN=HLQ.I00004.LLQ                                   

//DD00005   DD   DISP=SHR,DSN=HLQ.I00005.LLQ                                   

//*** NEW LINE 1 ADDED TO THE END OF THIS MEMBER ***                           

//*** NEW LINE 2 ADDED TO THE END OF THIS MEMBER ***                           

//*** NEW LINE 3 ADDED TO THE END OF THIS MEMBER ***                           

******************************** Bottom of Data ********************************

Additional Information:

The JCL above is build the way that you usually only have to change the values of the variables at the SET statements in the beginning of the job, and of course, the line(s) you would like to add to each member (the green lines in the ADDRECS job step).  

EXPORT is required if you would like to use a variable within SYSIN too (see IDCAMS DELETE step).