Page 2 of 2

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

PostPosted: Tue Dec 27, 2011 2:46 pm
by Ramana0693
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
....

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

PostPosted: Wed Dec 28, 2011 2:45 am
by dick scherrer
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.

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

PostPosted: Wed Dec 28, 2011 10:27 am
by Dilip_M_G
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.

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

PostPosted: Wed Dec 28, 2011 12:46 pm
by NicC
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.

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

PostPosted: Wed Dec 28, 2011 4:46 pm
by Anuj Dhawan
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.