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

VSAM - Accessing beyond record size


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Benchwarmer

New User


Joined: 16 Jul 2016
Posts: 22
Location: desk

PostPosted: Wed Apr 11, 2018 9:20 pm
Reply with quote

A VSAM file is received from a external source. The layout of the VSAM file is as below

Code:
01  VSAM-FILE                                           
    05  VSAM-RECORD-KEY              PIC X(10).         
    05  VSAM-OCCUR-CT                PIC 9(2) VALUE 1. 
    05  VSAM-DATA-SEG OCCURS  1 TO 10 TIMES             
           DEPENDING ON VSAM-OCCUR-CT.                 
        10  VSAM-NAME                PIC X(45).         


For some reason, the program consuming the VSAM file is looking at all occurrences to verify data exist and match against the count provided in input.

I expected the program will fail with return code '14 - Attempted to READ a relative record outside file boundary'

I tried debugging the code by reading the file and see the values for occurrences beyond the count is Null.

I searched in google and but did not find anything relative. Any pointers on how this works?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 11, 2018 9:31 pm
Reply with quote

Are you talking about a COBOL program (I assume this since the provided CODE is COBOL)? If so, is the program doing a READ or READ INTO? Based upon your comment, I assume your program is doing READ. In such a case, when COBOL does the READ, the VSAM-RECORD-KEY and VSAM-OCCUR-CT are read from the data set, then the VSAM-DATA-SEG occurrences are read (limited to VSAM-OCCUR-CT occurrences). I'm not sure why you expect the file status 14, since it only applies to relative record data sets and a KSDS is not RRDS. You would be more likely to get file status 92 (or possibly 34 depending upon how the KSDS was opened) but as long as VSAM-OCCUR-CT is between 01 and 10 you should get a file status 00.
Back to top
View user's profile Send private message
Benchwarmer

New User


Joined: 16 Jul 2016
Posts: 22
Location: desk

PostPosted: Wed Apr 11, 2018 10:24 pm
Reply with quote

File is READ in a COBOL program. Lets say the record has the count of 2 and there is no data exists after the second occurrence in input. But the program is checking the occurrence beyond 2 to verify the data exist. I was under the assumption that it will throw an error. In file aid when I open the VSAM file it does not show any values (Not even null) beyond the second occurrence.

Based on your answer, I assume the VSAM data will hold null values for other occurrences and File aid is not showing data because it may use RDW to control the data to be shown.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 11, 2018 11:57 pm
Reply with quote

You are defining a variable length record in COBOL. You REALLY need to read up in the Language Reference and Language Guide manuals how COBOL handles variable length records. If VSAM-OCCUR-CT has 02 in it, the record will have 2 occurrences of VSAM-DATA-SEG and hence of VSAM-NAME; there will be no data read after those 2 occurrences since no data exists in the VSAM data set for occurrences 3 through 10. One of the differences between FD 01 and WORKING-STORAGE 01 is that WORKING-STORAGE will reserve memory for all 10 occurrences even if only 2 are defined; FD 01 only has the amount of memory required for the actual number of occurrences.
Back to top
View user's profile Send private message
Benchwarmer

New User


Joined: 16 Jul 2016
Posts: 22
Location: desk

PostPosted: Thu Apr 12, 2018 1:12 am
Reply with quote

Quote:
You REALLY need to read up in the Language Reference and Language Guide manuals how COBOL handles variable length records


Yes, I definitely do need to read the manual.



Quote:
FD 01 only has the amount of memory required for the actual number of occurrences.


VSAM layout is defined in FD and still the program refers to occurrence beyond the count.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8700
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 12, 2018 1:27 am
Reply with quote

Quote:
still the program refers to occurrence beyond the count.
Change the code! The Language Reference manual tells you
Quote:
After a READ statement is executed, only those data items within the range of the current record are replaced; data items stored beyond that range are undefined
In other words, your program may refer to occurrences 3 through 10 when VSAM-OCCUR-CT is 02; however, the data being referenced is undefined. You could potentially get storage abends (although that is not likely in this case) but you could definitely get incorrect data in those occurrences! What I've seen in such cases (through Enterprise COBOL 3.4 -- I haven't seen any such case in the more recent COBOL versions) is that generally the first 5 READ statements will have the next record or records in the extra occurrences; after the first 5 READ statements the extra occurrences will have either data from the 5th previous READ or data from the next record or records (depending upon the specific values for VSAM-OCCUR-CT in the various records). This is for sequential data sets; I don't recall ever seeing this for VSAM so I don't know what it would use.
Back to top
View user's profile Send private message
Benchwarmer

New User


Joined: 16 Jul 2016
Posts: 22
Location: desk

PostPosted: Thu Apr 12, 2018 3:06 am
Reply with quote

Thank you. It helps.
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 -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Copy only TEXT or String from a record SYNCSORT 4
No new posts combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts SORT on detail record, then repeat he... DFSORT/ICETOOL 3
No new posts how to complete the end of a record w... DFSORT/ICETOOL 2
No new posts Sort based on the record type DFSORT/ICETOOL 1
Search our Forums:

Back to Top