View previous topic :: View next topic
|
Author |
Message |
vivek_elx
New User
Joined: 18 Feb 2009 Posts: 4 Location: India
|
|
|
|
If the VSAM file is opened in I-O mode and it is newly created by the JCL we submit..then a read is being performed in cobol program to check whether it has existing records then the program fails as there are no records in the VSAM file..plz suggest how to handle this situation.
How the status codes should be managed to do a successful first time read of empty file...sample read statements are given below
Code: |
READ VSAM-FILE
IF RECORD-FOUND
ADD +1 TO XXX
REWRITE VSAM-FILE-RECORD
ELSE
IF RECORD-NOT-FOUND
MOVE AAA
TO BBB
MOVE 1 TO XXX
WRITE VSAM-FILE-RECORD
END-IF
END-IF |
|
|
Back to top |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
If you are usig that VSAM file for first time in cobol, please have a dummy progam to just open that file in I-O mode and close the file.
Next time, you can use it in your program for processing and start writing the file and the job should not abend. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From the COBOL Programming Guide (link at the top of the page):
Quote: |
1.10.3.2.1 Opening an empty file
To open a file that has never contained records (an empty file), use a form of the OPEN statement.
Depending on the type of file that you are opening, use one of the following statements:
* OPEN OUTPUT for ESDS files.
* OPEN OUTPUT or OPEN EXTEND for KSDS and RRDS files. (Either coding has the same effect.) If you coded the file for random or dynamic access and the file is optional, you can use OPEN I-O.
Optional files are files that are not necessarily available each time a program is run. You can define files opened in INPUT, I-O, or OUTPUT mode as optional by defining them with the SELECT OPTIONAL clause in the FILE-CONTROL paragraph. |
An empty VSAM file needs to be opened for OUTPUT (or EXTEND) before opening for INPUT or I-O. If you do SELECT OPTIONAL and open it for I-O, there can be performance implications. |
|
Back to top |
|
|
|