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
 

 

how to handle if input file is empty

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Tue Jan 03, 2006 2:00 pm    Post subject: how to handle if input file is empty
Reply with quote

Hi,

My requirement is:

my program is reading and file and after doing some manipulations and writing into a output file.

I dont want to abend the program even if the input file is empty.......

means my input file is empty but I dont want to abend the program....how to handle this condition......

thx in advance............

pavan
Back to top
View user's profile Send private message

gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Tue Jan 03, 2006 2:14 pm    Post subject: Re: how to handle if input file is empty
Reply with quote

hai pavan,

hope this logic helps you. after reading the input file just check the file status. if it is not zero( in your case if there are no records the file status after the first read will be 10) move zero to the return code register. this is the way to save the job from abend.

like:

if ws-inpfile-fs not = 0

move zero to return-code

else
continue

end-if.


corrections welcomed..

gowtham
Back to top
View user's profile Send private message
Rupesh.Kothari

Member of the Month


Joined: 27 Apr 2005
Posts: 464

PostPosted: Tue Jan 03, 2006 3:15 pm    Post subject: Re: how to handle if input file is empty
Reply with quote

Hi,

Quote:
my input file is empty but I dont want to abend the program....how to handle this condition......


This can be done by two ways
First one as Gowtham_1982 mentioned

Second you can use following Code to check is file empty? IF yes yhen do not run the step ( Program) else run.

Code:
//STP0010  EXEC PGM=IDCAMS                               
//SYSPRINT DD SYSOUT=*                                   
//IFILE    DD DSN=fILE NAME
//SYSIN    DD *                                         
 PRINT INFILE(IFILE) COUNT(1)                           
//*   
//IF STP0010.RC EQ 00 THEN                                                     
PROGRAM STEP
//IFMAFEND ENDIF


Hope this helps

Regards
Rupesh
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Tue Jan 03, 2006 5:01 pm    Post subject:
Reply with quote

Hi ,

Thank you rupesh and gowtham.

one more thing I want to clear whether this technique works for VSAM files also.......

cheers............

pavan
Back to top
View user's profile Send private message
priyesh.agrawal

Senior Member


Joined: 28 Mar 2005
Posts: 1452
Location: Chicago, IL

PostPosted: Tue Jan 03, 2006 5:41 pm    Post subject: Re: how to handle if input file is empty
Reply with quote

Quote:
one more thing I want to clear whether this technique works for VSAM files also.......


Yes.

Regards,

Priyesh.
Back to top
View user's profile Send private message
gowtham_1982
Warnings : 1

Active User


Joined: 02 Dec 2005
Posts: 109

PostPosted: Tue Jan 03, 2006 5:57 pm    Post subject:
Reply with quote

i413678 wrote:
Hi ,

Thank you rupesh and gowtham.

one more thing I want to clear whether this technique works for VSAM files also.......

cheers............

pavan



hai pavan.

yes this logic can also work for VSAM files...

corrections welcomed...

gowtha
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Tue Jan 03, 2006 6:33 pm    Post subject:
Reply with quote

Hi Rupesh,


//SYSIN DD *
PRINT INFILE(IFILE) COUNT(1)
//*
//IF STP0010.RC EQ 00 THEN
PROGRAM STEP
//IFMAFEND ENDIF

I am not clear these control cards..........

in SYSIN we are printing......will it return 0 if file is empty

and if this return code is 0 no need to proceed otherwise we have to prroceed......

is my understanding is right.....let me know.....

thx once again......

pavan
Back to top
View user's profile Send private message
Rupesh.Kothari

Member of the Month


Joined: 27 Apr 2005
Posts: 464

PostPosted: Tue Jan 03, 2006 7:08 pm    Post subject: Re: how to handle if input file is empty
Reply with quote

Hi,

Code:
/STP0010  EXEC PGM=IDCAMS                               
//SYSPRINT DD SYSOUT=*                                   
//IFILE    DD DSN=fILE NAME
//SYSIN    DD *                                         
PRINT INFILE(IFILE) COUNT(1)                           
//*   
//IF STP0010.RC EQ 00 THEN                                                     
PROGRAM STEP
//IFMAFEND ENDIF


If File name contain atleast 1 record (i.e. Non empty) then Steo will return 0 and you can run your program else not.

Hope this is clear now.

Regards
Rupesh
Back to top
View user's profile Send private message
i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Tue Jan 03, 2006 9:03 pm    Post subject:
Reply with quote

Hi Rupesh,

thank you once again

ok, then normally for VSAM files we will insert one low level record and we will run the job in order not to abend the job......

in that case there will be 1 record......but there is no actual data records....then if we use this logic the program will execute...

how to handle this condition

am i clear

pavan
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Tue Jan 03, 2006 10:58 pm    Post subject: Re: how to handle if input file is empty
Reply with quote

i413678,

For the VSAM file, when you create the VSAM file, it is in a non initialized state, and you will get an abend if you try to read from it. Inserting the 'dummy' record puts it into an initialized state. You can Delete the dummy record and the VSAM file will then be in an Initialized, Empty state. A read from this will get you a not found status '23' (EOF).

In our shop, when an empty file in encountered, we simply perform the EOF routine for that file, the program does not abend. We need to put special coding in the program to abend if the first read attempt is an EOF, if an abend is desired.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts Issue with NDM process to transmit ES... chetanambi All Other Mainframe Topics 6 Wed May 03, 2017 10:52 am
No new posts File processing vishwakotin Mainframe Interview Questions 9 Fri Apr 28, 2017 11:38 am


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