Need to search a member in PDS file using JCL

雨燕双飞 提交于 2019-12-11 04:25:24

问题


I need a help to create a JCL to search the current year member (I.e. RPxxxx Where xxxx denote the year 2018) in a PDS file. A new member created on every year by the yearly job which used the PDS file. Hence the member name is not fixed in PDS file I.e. suffix has been changed in every year.

We need to create a JCL which check if the current year member present or not in the PDS file. So the successor job will run successfully.

If the current year member present in the PDS file then the new job will run with RC 0000 which indicate the successor job will be triggered automatically.

If the curr year member is not present in the PDS file then the job will fail with RC 0001 which indicates the next successor job will not trigger until this job recovered successfully.

Please help me to create such JCL.

Your help much appreciated.

Thanks in advance.


回答1:


LISTDS, a TSO function, display data set attributes. You can make use of the IKJEFT01 utility (which allows you to run TSO functions in batch) & run this TSO function. However, the Return codes issued by LISTDS are not what you want.

So, I would suggest to run a REXX script like the below using IKJEFT01 utility to evaluate the presence of member in a PDS.

/* REXX */         
arg dsname         
address tso        
"listds ("dsname")"
if (rc \= 0) then  
exit 1              

The run JCL would look like the below.

//JOBNAME    JOB ('ACCOUNTING INFORMATION'),
//     CLASS=2,MSGCLASS=H,NOTIFY=&SYSUID    
//P1 EXEC PGM=IKJEFT01                      
//SYSPROC DD DSN=YOUR.REXX.LIB,DISP=SHR     
//SYSTSPRT DD SYSOUT=*                      
//SYSTSIN DD *                              
  %EMPTY7 'YOUR.PDS(RPXXXX)'                  
/*    

EMPTY7 in SYSTSIN DD is the name of the REXX script. Library given in the SYSPROC DD is where your REXX script will be stored.

Let me know if you need more details.




回答2:


No need for a REXX script. Simply run LISTDS via IKJEFT1A and the step will end with the return code from the LISTDS command.

Note that the syntax description does not mention a member specification explicitly, but it does work. Use it at your own risk.

//STEP01   EXEC PGM=IKJEFT01
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
  LISTDS ('your.data.set.name(yourmember)')
/*

The step will end with RC=0 if the member exists, otherwise the RC will be non-zero.




回答3:


The following Rexx code will build the member name dynamically based on the current year and does not require hard coding of the dataset / member name. This way you can schedule a job to build a new member without having to edit the job.

/* Rexx */                                
 arg dsname                               

 currDate = Date('S')                     
 currYear = substr( currDate, 1, 4 )      
 fqdsname = dsname||"(RP"||currYear||")"  
 "listds ("fqdsname")"                    
 if (rc \= 0) then                        
 exit 1                                   


来源:https://stackoverflow.com/questions/51418930/need-to-search-a-member-in-pds-file-using-jcl

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!