IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to Read Empty VSAM file in a cobol program


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Wed May 09, 2007 5:38 pm
Reply with quote

hi,

How can i read a empty VSAM file in a COBOL program.
Is there any special entry to be made in the FD section?

TIA
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 09, 2007 5:43 pm
Reply with quote

If it is empty, then there is nothing there to read.

Is there icon_eek.gif
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Wed May 09, 2007 5:51 pm
Reply with quote

But how will we open the empty file in the cobol program?
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8797
Location: Welsh Wales

PostPosted: Wed May 09, 2007 5:58 pm
Reply with quote

Will this help ???

http://ibmmainframes.com/viewtopic.php?t=16516
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Wed May 09, 2007 6:08 pm
Reply with quote

Expat,

That did not help.
I got the solution ...

it can be done thru OPTIONAL clause...

SELECT OPTIONAL LOGICAL-FILE-NAME ASSIGN TO PHYSICAL-FILE-NAME

This optional clause creates a dummy record in VSAM file through which it can be opened.

TIA
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu May 10, 2007 2:44 pm
Reply with quote

Pinge,
Have you tried it? icon_smile.gif
I had some confusion regarding OPTIONAL clause before.
I have tried to read DUMMY vsam file by giving AMP='amorg', and it works fine but never really tried OPTIONAL clause to read a VSAM.
Back to top
View user's profile Send private message
pingte

Active User


Joined: 03 Dec 2005
Posts: 120
Location: india

PostPosted: Thu May 10, 2007 2:50 pm
Reply with quote

Yes tried it icon_biggrin.gif
Where do u write AMP='amorg'?
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu May 10, 2007 7:07 pm
Reply with quote

IN JCL.
Back to top
View user's profile Send private message
rz061m

New User


Joined: 03 Mar 2006
Posts: 48
Location: Chennai

PostPosted: Fri May 11, 2007 11:59 am
Reply with quote

Hi,

Open the file in OUTPUT mode and CLOSE the file immediately.

then open the file in INPUT mode, it will not abend this time, rather will set the VSAM status code to 10 - end-of file.

thanks,
Rz061m.
Back to top
View user's profile Send private message
Pete Eagleton

New User


Joined: 14 Feb 2007
Posts: 11
Location: Chicago

PostPosted: Tue May 15, 2007 3:38 am
Reply with quote

BEST IDEA. open the file for input and test your status code for a 35. if you get a 35 file is empty.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Compare 2 files and retrive records f... DFSORT/ICETOOL 3
No new posts FTP VB File from Mainframe retaining ... JCL & VSAM 8
No new posts Extract the file name from another fi... DFSORT/ICETOOL 6
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
Search our Forums:

Back to Top