View previous topic :: View next topic
|
Author |
Message |
kumar_prathap
New User
Joined: 12 Apr 2004 Posts: 5
|
|
|
|
Hi all ,
I want to check a file is empty or not in a JCL in first step and in secod step :
If its not empty
I will take some action
else
I will take some other action.
can u pls tel me the how to do this in Jcl
regds Prathap |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
If you have DFSORT available:
Code: |
//STEP0001 EXEC PGM=ICETOOL
//IN DD DSN=dataset.to.check,..
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//TOOLIN DD DATA
COUNT FROM(IN) EMPTY
/*
//*
// IF (STEP0001.RC) = 0 THEN
//STEP0002 EXEC PGM=NOTEMPTY
// ELSE
//STEP0003 EXEC PGM=EMPTY
//* |
|
|
Back to top |
|
|
imvs
New User
Joined: 12 May 2004 Posts: 33
|
|
|
|
there are couple of ways to find out empty file ..
With SORT tool
Code: |
// EXEC PGM=ICETOOL
// TOOLMSG DD SYSOUT=*
// DFSMSG DD SYSOUT=*
//INDD DD DSN=INPUT FILE,DISP=SHR
//TOOLIN DD *
COUNT FROM(INDD) EMPTY
/*
IF THE FILE IS EMPTY , IT WILL SET RC=12 |
With IDCAMS
Code: |
//INDD DD DSN=INPUT FILE,DISP=SHR
//OUTDD DD DSN=OUTPUT FILE,DISP=SHR
//SYSIN DD *
REPRO INFILE(INDD) OUTFILE(OUTDD) COUNT(1)
/* |
IF THE FILE IS EMPTY IT WILL SET RC=04 |
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
Another IDCAMS option:
Code: |
//STEP0001 EXEC PGM=IDCAMS
//IN DD DSN=thedataset.to.check,...
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(IN) COUNT(1)
/* |
RC=0 if file has at least 1 record, otherwise RC=4. |
|
Back to top |
|
|
kumar_prathap
New User
Joined: 12 Apr 2004 Posts: 5
|
|
|
|
thnx ---all |
|
Back to top |
|
|
Doucky
New User
Joined: 19 May 2005 Posts: 3 Location: france
|
|
|
|
Hello all,
I have a problem with the return code after a empty file test in an IDCAMS :
PRINT INFILE(F1) COUNT(1)
IF LASTCC NE 0 THEN SET LASTCC = 3
I want a return code of the step equal to 3 but ... if file is empty, the return code of the command is RC=4 and my IF seems to be not good.
The solution seems to be SET MAXCC=3 but I don't understand why
If you have an explanation, it's welcome,
thanks in advance |
|
Back to top |
|
|
subhasis_50
Moderator
Joined: 09 Mar 2005 Posts: 363 Location: Earth
|
|
|
|
Hi,
Use the following code it will work. Please change your LASTCC=3 to MAXCC=3.
Code: |
//EMPTYCK EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//FILE1 DD DSN=TEST.ABA01.EXTRACT.SUB1,DISP=SHR
//SYSUDUMP DD SYSOUT=*
//SYSIN DD *
PRINT INFILE(FILE1) -
DUMP COUNT(1)
IF LASTCC NE 0 THEN SET MAXCC=3
/* |
|
|
Back to top |
|
|
Doucky
New User
Joined: 19 May 2005 Posts: 3 Location: france
|
|
|
|
thanks a lot
best regards |
|
Back to top |
|
|
Doucky
New User
Joined: 19 May 2005 Posts: 3 Location: france
|
|
|
|
OK,
I have found an explanation !
In fact, to overide the original return code (4), the writed value of LASTCC must be superior to it.
test :
PRINT INFILE(F1) COUNT(1)
IF LASTCC NE 0 THEN SET LASTCC = 5
the step return code is ... 5 (so cool)
for a return code less than (RC=4) MAXCC must be employed
pfff ... |
|
Back to top |
|
|
|