How to check if file is empty in cobol without reading???



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Re: How to check if file is empty in cobol without reading??

Postby Ramana0693 » Tue Dec 27, 2011 2:46 pm

Hi,

U can take an empty file and compare this empty file with your input file in the first step of a JOB, If your Input file is empty, Then the RC wub be 28, if so, u can abend the JOB. if not, go to the next step in which your prg is executed to read the non-empty files.

P010 EXEC PGM=ISRSUPC,PARM=('LINECMP,OVSUML,UPDCNTL')
NEWDD DD DSN=InputFile,DISP=SHR
OLDDD DD DSN=An Empty File,Disp=shr
OUTDD DD SYSOUT=*
DELDD DD DUMMY
//SYSIN DD *
CMPCOLM 1:80
/*
***********************************************************
* RETURN CODE CHECK
***********************************************************
IF P010.RC not = 28 THEN
....
Ramana0693
 
Posts: 1
Joined: Tue Dec 27, 2011 2:29 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Re: How to check if file is empty in cobol without reading??

 

Re: How to check if file is empty in cobol without reading??

Postby dick scherrer » Wed Dec 28, 2011 2:45 am

Hello,

I found solution for my qn,,
The posted process is Not a solution - there are several ways it can fail, making it unacceptable to most organizations.

U can take an empty file and compare this empty file with your input file in the first step of a JOB,
No. Did you not read the "requirement"? The file is not to be opened. . .

Personally, i believe the entire approach is a design flaw and some other approach should be investigated.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: How to check if file is empty in cobol without reading??

Postby Dilip_M_G » Wed Dec 28, 2011 10:27 am

Hi Biily,

ya thats true i could have been more clear in defining my qn earlier.. so i briefed once i found the solution..

And to add to your prev comment, if u chk my code in prev comment after the first read, first dataset is read and wtever is the record is copied to ws-1st4data and similarly after second read ws-2nd4data will hv 2nd dataset records. I have tested and its working..

Since i'm working on enhancement proj , i couldn't change the concatenated DD step in JCL.

Thanks for all the support from all.
Dilip_M_G
 
Posts: 12
Joined: Wed Nov 02, 2011 10:45 am
Has thanked: 0 time
Been thanked: 0 time

Re: How to check if file is empty in cobol without reading??

Postby NicC » Wed Dec 28, 2011 12:46 pm

So how do you know for sure that the second read reads from the second file and not the first? If, by accident, the first file has 2 records in it then the second file does not get read - at least, not at this stage.

If it is an enhancement project then you can enhance the JCL by removing the concatenation.

And the words are "yes", "question", "previous", "you", "have", "project" - you seem to have no idea how annoying it is to have these non-standard abbreviations in a post. You have a full keyboard - use it, please.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2690
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisys (almost)
Has thanked: 4 times
Been thanked: 105 times

Re: How to check if file is empty in cobol without reading??

Postby Anuj Dhawan » Wed Dec 28, 2011 4:46 pm

I'm late to the party so I might miss the actual requirement, however, with what I've understood - may be you can use two dummy files in the existing concatnation like this:
//FILE1 DD DSN=date.dataset.one,DISP=SHR
//      DD DSN=dummy.dataset.one,DISP=SHR
//      DD DSN=date.dataset.two,DISP=SHR
//      DD DSN=dummy.dataset.two,DISP=SHR

where dummy.dataset.one and ... .two might have some indicator to show the end of respective files. E.g.: dummy.dataset.one might have @@@@ (or EOF1), in program when the first-four-charcters are these you know the program is at the end of the file.
Anuj
Anuj Dhawan
 
Posts: 274
Joined: Mon Feb 25, 2008 3:53 am
Location: Mumbai, India
Has thanked: 6 times
Been thanked: 4 times

Previous

Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post