Posted: Thu Dec 11, 2008 2:16 pm Post subject: Check for the existence of the dataset process the next
Here is my req.
I have a dataset TEST1 which I am not sure if it existing or not in the mainframe. My req is if TEST1 existing in the mainframe then copy it to TEST2 else use the a DUMMY file to copy it to TEST2. Either way I need to create TEST2.
But the catch is, I cannot create a Dummy file dataset is TEST1 dataset is not existing. How can I achieve this. Here are my steps that I am using but the problem is if TEST1 is not existing, then the job is failing with a JCL error stating "DATASET NOT FOUND ON MAIN PROCESSOR M207".
Code:
//************************************************
//* SETS RC=00 IF DATASET HAS ATLEAST 1 RECORD *
//* SETS RC=04 IF DATASET IS EMPTY *
//* SETS RC=12 IF DATASET IS NOT FOUND *
//************************************************
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
PRINT IDS('TEST1') COUNT(1)
IF LASTCC=12 THEN SET MAXCC=4
/*
//*
//* EXECUTE THE FOLLOWING STEP IF THE DATASET IS NOT THERE
//*
// IF (STEP0100.RC EQ 12) THEN
//STEP010 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DUMMY
//SYSUT2 DD DSN=TEST2,
// DISP=(NEW,CATLG,DELETE),
// Rest of the properties follow
//SYSIN DD *
COPY ALL
//*
//* EXECUTE THE FOLLOWING STEP IF THE DATASET IS THERE
//*
// ELSE
//STEP020 EXEC PGM=SORT
//SYSPRINT DD SYSOUT=*
//SYSUT1 DD DSN=SHR,DSN=TEST1
//SYSUT2 DD DSN=TEST2,
// DISP=(NEW,CATLG,DELETE),
// Rest of the properties follow
//SYSIN DD *
COPY ALL
//*
// ENDIF
//*
//Continue with the rest of the steps.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum