IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Can i use JCL to check whether a batch files are exist?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
David_Li

New User


Joined: 05 Apr 2006
Posts: 10

PostPosted: Mon Aug 28, 2006 8:04 pm
Reply with quote

1. More than 1000 records in a dataset (PS), each record is VSAM file name. like this:
*******************************************************
SERS.MSI.FTRSF.TEST1
SERS.MSI.FTRSF.TEST2
SERS.MSI.FTRSF.TEST3
SERS.MSI.FTRSF.TEST4
SERS.MSI.FTRSF.TEST5
SERS.MSI.FTRSF.TEST6
........ .......
SERS.MSI.FTRSF.T1000
*******************************************************
2. I want to know whether these files exist in system. And print the files name which are not in system in dataset 'SERS.MSI.OUTPUT'.

How do i do?

High appreciate with any response.
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Tue Aug 29, 2006 1:26 am
Reply with quote

Using IDCAMS, you could take every dataset name and format LISTCAT control cards to see if a dataset exists:

Code:

//DELETE  EXEC PGM=IDCAMS               
//SYSPRINT DD SYSOUT=*                   
//SYSIN    DD *                         
 LISTCAT ENTRY(HLQ.DATASET.NAME.FILE1)
 LISTCAT ENTRY(HLQ.DATASET.NAME.FILE2)
/*                                       


If it exists, the output would look like:
Code:

 LISTCAT ENTRY(HLQ.DATASET.NAME.FILE1) NAME   
NONVSAM ------- HLQ.DATASET.NAME.FILE1


If it does not exist, the output would look like:
Code:

  LISTCAT ENTRY(HLQ.DATASET.NAME.FILE2)
IDC3012I ENTRY HLQ.DATASET.NAME.FILE2 NOT FOUND   


You could write the SYSPRINT output from the IDCAMS step to a permanent dataset, so it could be later edited to identify the "NOT FOUND" files.
Back to top
View user's profile Send private message
crrindia

Active User


Joined: 02 Jul 2005
Posts: 124
Location: Gurgaon

PostPosted: Tue Aug 29, 2006 1:03 pm
Reply with quote

Hi, Here you are providing the Syntax to check individual one by using the LISTCAT parameter. But as per David's note Suppose if we want to check only that PS file(all of the VSAM files exists in that file), and from there it should check all of those VSAM files. For that how to verify it? Please provide sample Syntax also.

Thanks!
Rathna.
Back to top
View user's profile Send private message
cpuhawg

Active User


Joined: 14 Jun 2006
Posts: 331
Location: Jacksonville, FL

PostPosted: Tue Aug 29, 2006 10:35 pm
Reply with quote

My suggestion was to take the complete list of datasets, format a LISTCAT command using each dataset, and finally run an IDCAMS and write the SYSPRINT results to a dataset.

If you are looking for a single LISTCAT command for listing all datasets that match a specific pattern, you could use:

Code:

 LISTCAT LEVEL('SERS.MSI')


This command will not list missing datasets, only existing ones. If you took the list of existing datasets and placed them sequentially in a dataset starting in position 1. Then take the list of datasets from your original dataset and place them sequentially in a dataset starting in position one.

You could then sort them all together using ICETOOL or SYNCTOOL using the NODUPS option and the output file would be every dataset that didn't match the datasets on your original file.
Back to top
View user's profile Send private message
David_Li

New User


Joined: 05 Apr 2006
Posts: 10

PostPosted: Thu Aug 31, 2006 7:14 pm
Reply with quote

Thanks, Guys.

Yeah, That is a way to figure out the question with single dataset or a group datasets which have the same High qualify.

I found another way. use REXX. This way also can verify that. Share with you.



Code:
/*REXX*/
    DSNAME = 'SERS.BSP.ERSCICI2.CSD(ERSI2CSD)'
    "ALLOC FI(MYINDD1) DA('"DSNAME"') SHR REUSE"
    "EXECIO * DISKR MYINDD1 (STEM NEWVAR. FINIS"
    "FREE FI(MYINDD1)"
    DO I1 = 1     TO NEWVAR.0
       IF INDEX(NEWVAR.I1,"DEFINE FILE(") > 0 THEN
       DO
          POS2 = INDEX(NEWVAR.I1,")")
          FILE_LENG = POS2 - 13
          FILENAME = SUBSTR(NEWVAR.I1,13,FILE_LENG)
          I1 = I1 + 1
          IF INDEX(NEWVAR.I1,"DSNAME(") > 0 THEN
          DO
             POS2 = INDEX(NEWVAR.I1,")")
             FILE_LENG = POS2 - 15
             PHYFILE   = SUBSTR(NEWVAR.I1,15,FILE_LENG)
       /*    SAY LEFT(FILENAME,12) PHYFILE  */
             XX = SYSDSN("'"PHYFILE"'")
             IF XX \= 'OK' THEN
             DO
                 SAY LEFT(FILENAME,12) PHYFILE
             END
          END
       END
    END
EXIT


Original file: 'SERS.BSP.ERSCICI2.CSD(ERSI2CSD)
************************************************************
..... ......... ............. .............
DEFINE FILE(file name1)

..... ......... ............. .............

DEFINE FILE(file name2)

DEFINE FILE(file name3)
.............................
DEFINE FILE(file name4)

DEFINE FILE(file nameN)
************************************************************
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Write line by line from two files DFSORT/ICETOOL 7
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts How to get a stack trace on a looping... ABENDS & Debugging 5
No new posts SCOPE PENDING option -check data DB2 2
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
Search our Forums:

Back to Top