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

How to check a file is Empty or not?


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

New User


Joined: 12 Apr 2004
Posts: 5

PostPosted: Wed May 12, 2004 5:53 pm
Reply with quote

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 emty
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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed May 12, 2004 6:14 pm
Reply with quote

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
View user's profile Send private message
imvs

New User


Joined: 12 May 2004
Posts: 33

PostPosted: Wed May 12, 2004 6:17 pm
Reply with quote

there are couple of ways to find out empty file ..

With SORT tool
// 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
//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
View user's profile Send private message
superk

Global Moderator


Joined: 26 Apr 2004
Posts: 4652
Location: Raleigh, NC, USA

PostPosted: Wed May 12, 2004 6:19 pm
Reply with quote

Another IDCAMS option:

//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
View user's profile Send private message
kumar_prathap

New User


Joined: 12 Apr 2004
Posts: 5

PostPosted: Wed May 12, 2004 6:25 pm
Reply with quote

thnx ---all
Back to top
View user's profile Send private message
Doucky

New User


Joined: 19 May 2005
Posts: 3
Location: france

PostPosted: Thu May 19, 2005 2:32 pm
Reply with quote

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
View user's profile Send private message
subhasis_50

Moderator


Joined: 09 Mar 2005
Posts: 363
Location: Earth

PostPosted: Thu May 19, 2005 2:52 pm
Reply with quote

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
View user's profile Send private message
Doucky

New User


Joined: 19 May 2005
Posts: 3
Location: france

PostPosted: Thu May 19, 2005 3:03 pm
Reply with quote

thanks a lot

best regards
Back to top
View user's profile Send private message
Doucky

New User


Joined: 19 May 2005
Posts: 3
Location: france

PostPosted: Thu May 19, 2005 3:23 pm
Reply with quote

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 icon_wink.gif

pfff ...
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 FTP VB File from Mainframe retaining ... JCL & VSAM 1
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top