Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 4650
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: 4650
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
No new posts Moving a PS file as body of a mail! Vignesh Sid JCL & VSAM 4 Tue Nov 21, 2017 9:23 pm
No new posts unable to set RC = 4 when empty file migusd SYNCSORT 1 Tue Nov 21, 2017 1:21 am
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts Updating data from one file to other!!! Vignesh Sid SYNCSORT 1 Mon Nov 06, 2017 2:42 pm
This topic is locked: you cannot edit posts or make replies. Need help how to pass the ESP variabl... Venkichaitu JCL & VSAM 12 Thu Nov 02, 2017 3:53 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us