View previous topic :: View next topic
Author
Message
amalraj_ece New User Joined: 16 Jul 2006Posts: 21 Location: delhi
How I could code a job to check to see if a file exists. If it does, I want to copy it to a new file. If it doesn't, I want to create an empty version of the same file.
Back to top
die7nadal Active User Joined: 23 Mar 2005Posts: 156
Try IDCAMS command,
Code:
//STEP001 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
LISTCAT ENT('DSNAME')
//
If the RC = 4 then the file does not exist, if 0 then it exists. You can copy this file or create an empty file based on this RC.
Back to top
ch.prashant New User Joined: 16 Sep 2006Posts: 27 Location: Hyderabad
You can find if the file exists or not then you can use condition code and create a file.
Code:
//JS0015B EXEC PGM=IEFBR14,COND=(4,NE,JS0015A)
//*********************************************************************
//* THIS STEP RUNS IF FILE1 IS EMPTY.
//*PURPOSE : CREATES EMPTY FILES.
//*********************************************************************
//DD1 DD DSN=ECA311T.GVISIA.EDSHLL,
// DISP=(,CATLG,DELETE),
// UNIT=DISK,
// SPACE=(TRK,(50,50),RLSE),
// RECFM=FB,LRECL=800
Back to top
amalraj_ece New User Joined: 16 Jul 2006Posts: 21 Location: delhi
Creating an empty file and checking the existance of the file is fine, but hw can I code a copy step?. If the file is not existing then it will through JCL error . I'm getting problem here only
Note:
I'm trying for creating a new version of a GDG
Back to top
Anuj Dhawan Superior Member Joined: 22 Apr 2006Posts: 6250 Location: Mumbai, India
amalraj_ece wrote:
I'm getting problem here only
Hello,
Please show the JCL used & the error message you got. Better suggestions will pour in.
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10873 Location: italy
I do not know for what reason I got interested
here is a job stream tested
Code:
****** ***************************** Top of Data **********************
000001 //ENRICO@A JOB (H001),'Z1',NOTIFY=ENRICO,
000002 // CLASS=A,MSGCLASS=X,MSGLEVEL=(1,1)
000003 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
000004 //* DSN=ENRICO.MF.JCLLIB(Z1)
000005 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
000006 // JCLLIB ORDER=(ENRICO.MF.JCLLIB)
000007 //* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
000008 //*
000009 //Z EXEC PGM=ZCLEANUP
000010 //SYSPRINT DD SYSOUT=*
000011 //*
000012 //AMS EXEC PGM=IDCAMS
000013 //*
000014 //NEWDS DD DISP=(NEW,CATLG),DSN=ENRICO.MF.NEW,
000015 // UNIT=SYSDA,
000016 // SPACE=(CYL,(1,1)),DCB=(RECFM=FB,LRECL=80)
000017 //DUMMY DD DUMMY,
000018 // DCB=(RECFM=FB,LRECL=80)
000019 //*
000020 //SYSPRINT DD SYSOUT=*
000021 //*
000022 //SYSIN DD *
000023 PRINT INDATASET(ENRICO.MF.EXISTS) COUNT(1)
000024 IF LASTCC = 0 THEN -
000025 REPRO INDATASET(ENRICO.MF.EXISTS) OUTFILE(NEWDS)
000026 ELSE DO
000027 SET MAXCC = 0
000028 REPRO INFILE(DUMMY) OUTFILE(NEWDS)
000029 END
000030 //*
000031 //AMS2 EXEC PGM=IDCAMS
000032 //*
000033 //NEWDS DD DISP=(NEW,CATLG),DSN=ENRICO.MF.NEW2,
000034 // UNIT=SYSDA,
000035 // SPACE=(CYL,(1,1)),DCB=(RECFM=FB,LRECL=80)
000036 //DUMMY DD DUMMY,
000037 // DCB=(RECFM=FB,LRECL=80)
000038 //*
000039 //SYSPRINT DD SYSOUT=*
000040 //*
000041 //SYSIN DD *
000042 PRINT INDATASET(ENRICO.MF.NXISTS) COUNT(1)
000043 IF LASTCC = 0 THEN -
000044 REPRO INDATASET(ENRICO.MF.EXISTS) OUTFILE(NEWDS)
000045 ELSE DO
000046 SET MAXCC = 0
000047 REPRO INFILE(DUMMY) OUTFILE(NEWDS)
000048 END
****** **************************** Bottom of Data ********************
edited to change involved into interested ( see eggs and bacon )
Back to top
amalraj_ece New User Joined: 16 Jul 2006Posts: 21 Location: delhi
Hi Enrico,
Your solution is the perfect one and it is working fine for me
Thanks for your help!
Back to top
Please enable JavaScript!