Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Check a file is empty or not in JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
kumar_prathap

New User


Joined: 12 Apr 2004
Posts: 6

PostPosted: Wed May 12, 2004 5:53 pm    Post subject: Check a file is empty or not in JCL
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

Moderator Team Head


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

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

If you have DFSORT available:

//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    Post subject:
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

Moderator Team Head


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

PostPosted: Wed May 12, 2004 6:19 pm    Post subject:
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: 6

PostPosted: Wed May 12, 2004 6:25 pm    Post subject:
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    Post subject:
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    Post subject: Re: empty file
Reply with quote

Hi,

Use the following code it will work. Please change your LASTCC=3 to MAXCC=3.
//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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Fetching data from BAI File arunsoods JCL & VSAM 1 Wed Jul 19, 2017 4:28 pm
No new posts Write out NODUPS but just from one file Jay Villaverde DFSORT/ICETOOL 8 Fri Jul 14, 2017 12:44 am
No new posts How to add header with Date(YYMMDD) i... Rajan Moorthy DFSORT/ICETOOL 2 Thu Jul 06, 2017 11:44 pm
No new posts How to generate a new unique Input fi... for1ranjith CLIST & REXX 11 Sat Jul 01, 2017 12:09 pm
No new posts Writing a file using online program grvtomar PL/I & Assembler 3 Fri Jun 30, 2017 1:06 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us