COBOL program using VSAM ESDS

 

 

An ESDS VSAM file is very similar to a flat file, as with a flat file the access mode is sequential and the file control section would look very similar to that of a flat file if the ESDS file is of fixed length with both ORGANIZATION and ACCESS MODE being SEQUENTIAL.

 

So how do you differentiate an fixed length ESDS file from your normal flat file in a COBOL program.The difference lies in the ASSIGN TO cause, for an ESDS file your DD name must be prefixed with AS- in the COBOL program while the JCL will not have this part. So your COBOL program will have a DD name of “AS-DDNAM1” your JCL will only have //DDNAME1 DD DSN  =

 

If you omit the AS- part in your COBOL Assign clause you would get a file status 39 , attribute mismatch , as the COBOL program is  expecting a flat file but the JCL will be having a VSAM ESDS instead.

 

I have given a small program using a VSAM ESDS file and the run JCL below for reference

 

IDENTIFICATION DIVISION. 

PROGRAM-ID. PGMESDS.                                            

INPUT-OUTPUT SECTION.                                           

FILE-CONTROL.                                       

    SELECT ESDS-FILE ASSIGN TO AS-ESDS          

    ORGANIZATION IS SEQUENTIAL                     

    ACCESS MODE   IS SEQUENTIAL                     

    FILE STATUS   IS ESDS-FILE-STATUS.            

DATA DIVISION.                                      

FILE SECTION.                                        

FD ESDS-FILE.                                     

01 ESDS-REC                 PIC X(100).          

WORKING-STORAGE SECTION.

77 INVTDB-FILE-STATUS         PIC X(2). 

PROCEDURE DIVISION.                           

     OPEN OUTPUT INVTDB-FILE.                  

     IF INVTDB-FILE-STATUS = ZERO              

        DISPLAY ‘FILE OPENED’                  

     ELSE                                                    

         DISPLAY ‘ERROR OPENING FILE’                        

         DISPLAY ‘FILE STATUS IS: ‘ESDS-FILE-STATUS       

    END-IF.                                                

    STOP RUN.  

Run JCL for the above

000001 //JOBESDS1 JOB (XXXXXXX#),MSGCLASS=A,NOTIFY=&SYSUID,CLASS=A,MSGLEVEL=(1,1)         000005 //STEP01   EXEC  PGM=PGMESDS     

000006 //STEPLIB  DD  DSN=LOADLIB,DISP=SHR 

000007 //SYSPRINT DD SYSOUT=*                             

000008 //SYSOUT   DD SYSOUT=*                             

000009 //INVTDB  DD DSN=U488565.IMS.INVENDB,DISP=SHR      

 

         

 

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Mainframe Wiki © 2015 Frontier Theme