View previous topic :: View next topic
|
Author |
Message |
i413678 Currently Banned Active User
Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
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 |
|
|
Rupesh.Kothari
Member of the Month
Joined: 27 Apr 2005 Posts: 463
|
|
|
|
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 |
|
|
i413678 Currently Banned Active User
Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
|
priyesh.agrawal
Senior Member
Joined: 28 Mar 2005 Posts: 1448 Location: Chicago, IL
|
|
|
|
Quote: |
one more thing I want to clear whether this technique works for VSAM files also....... |
Yes.
Regards,
Priyesh. |
|
Back to top |
|
|
gowtham_1982 Warnings : 1 Active User
Joined: 02 Dec 2005 Posts: 109
|
|
|
|
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 |
|
|
i413678 Currently Banned Active User
Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
|
Rupesh.Kothari
Member of the Month
Joined: 27 Apr 2005 Posts: 463
|
|
|
|
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 |
|
|
i413678 Currently Banned Active User
Joined: 19 Feb 2005 Posts: 112 Location: chennai
|
|
|
|
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 |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
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 |
|
|
|