Cobol-VSAM question

This is a Mainframe COBOL forum - you can post your queries on Mainframe COBOL, VS COBOL II, COBOL/370 , Enterprise COBOL

Moderators: dbzTHEdinosauer, Moderator Group

Post Reply
radhika
Member
Posts: 1
Joined: Fri Mar 17, 2006 11:14 am

Cobol-VSAM question

Post by radhika » Fri Mar 17, 2006 11:21 am

Hi,

I would like to know how do we find out that the programis using VSAM file?

Thanks
Radhika

User avatar
arrbee
Active Member
Posts: 144
Joined: Fri Feb 24, 2006 11:33 am

This is the way.

Post by arrbee » Fri Mar 17, 2006 11:59 am

Hi,

If it is using a KSDS then the SELECT statement would look like as shown below:

Code: Select all

SELECT I-XXXXXXX              ASSIGN TO XXXVSAM        
                              ORGANIZATION IS INDEXED  
                              ACCESS IS RANDOM         
                              RECORD KEY IS XXXXXX-KEY.
HTH.
Arr Bee
-------------
?My joy in learning is partly that it enables me to teach? - Seneca(Roman philosopher, mid-1st century AD)

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Thu Nov 27, 2008 7:10 am

Or some thing like this might needs to be remembered:

Changes in the ENVIRONMENT DIVISION:

Code: Select all

SELECT file-name ASSIGN TO ddname
   ORGANIZATION IS type
   ACCESS MODE IS access
   RECORD KEY IS key1  /  RELATIVE KEY IS key2
   FILE STATUS IS field1 [field2].
ddname the ddname of the VSAM file being accessed

Code: Select all

 KSDS, RRDS format: DA-ddname
          ESDS format: DA-AS-ddname
type specifies the order that records have been stored in

Code: Select all

 SEQUENTIAL -- records are positioned in the order in  which they were originally loaded  (ESDS)                     
INDEXED -- records are positioned according to their index field (KSDS)
RELATIVE -- records are positioned according to their relative record number (RRDS)
access specifies how records are going to be processed

Code: Select all

 SEQUENTIAL -- read/write in sequential order
RANDOM -- read/write in a user specified order
DYNAMIC -- read/write in sequential, random, or both

key1 specifies the FD field name for the primary key field KSDS only
value in the key must be unique

key2 field in working storage that a value will be moved to prior to a READ/WRITE RRDS only used with RANDOM or DYNAMIC access

field1 PIC XX field in working storage that will be used by COBOL to indicate the result of an OPEN, CLOSE, READ, or WRITE 00 success / non-zero failure

field2 6 byte return code that is supplied if field1 is not 00

Code: Select all

         01 VSAM-STATUS-CODES.
            05  VSAM-RETURN-CODE         PIC 9(2)  COMP.
            05  VSAM-FUNCTION-CODE       PIC 9     COMP.
            05  VSAM-FEEDBACK-CODE       PIC 9(3)  COMP.
Changes in the DATA DIVISION:

VSAM records are not labeled, therefore the LABEL RECORDS ARE... clause is treated as a comment, though it is required.

VSAM records are not blocked, therefore the BLOCK CONTAINS... clause should not be specified.

Changes in the PROCEDURE DIVISION:

Opening a file:

Code: Select all

   OPEN  INPUT   file-name.
         OUTPUT
         I-O
         EXTEND
I-O file that will be read from and written to
EXTEND file that will have records added to the end sequential file only

You can now test whether the files opened correct by testing the value placed in the FILE STATUS IS variable.

Closing a file:
Same as before but you can now test if the close was successful.
Regards,
Anuj

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others