Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
VSAM - Accessing beyond record size

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: VSAM - Accessing beyond record size
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: 8378
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 11, 2018 9:31 pm    Post subject: Reply to: VSAM - Accessing beyond record size
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    Post subject:
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: 8378
Location: Dubuque, Iowa, USA

PostPosted: Wed Apr 11, 2018 11:57 pm    Post subject:
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    Post subject:
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: 8378
Location: Dubuque, Iowa, USA

PostPosted: Thu Apr 12, 2018 1:27 am    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts TSO Region Size Martin Wickenden TSO/ISPF 7 Wed Aug 15, 2018 11:26 pm
No new posts Add Comma to each record until find t... naveensrimf DFSORT/ICETOOL 6 Sat Jul 28, 2018 12:25 am
No new posts How to manage VSAM file update confli... ocjohnh JCL & VSAM 2 Sat Jul 21, 2018 6:04 am
No new posts Need Help to Create 4 Output Records ... satish.ms10 DFSORT/ICETOOL 5 Thu Jul 19, 2018 1:55 am
No new posts Remove duplicate record with condition rajiv rengasamy DFSORT/ICETOOL 4 Wed Jul 11, 2018 3:55 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us