Question

I am using VSAM files for the first time and am having a ton of trouble with the ORGANIZATION part of the VSAM definition.

I thought that the key is what Cobol uses to search on the file.

Question: Why is the organization clause not working?

Code Here:

 SELECT SW24VF01   ASSIGN TO UT-S-INPUT2                 
                   ORGANIZATION IS INDEXED               
                   ACCESS IS RANDOM                      
                   RECORD KEY IS MY-PROV-KEY-24          
                   FILE STATUS IS SW24VF01-STAT.    

 SELECT SS45VF90   ASSIGN TO UT-S-INPUT3                 
                   ORGANIZATION IS INDEXED               
                   ACCESS IS RANDOM                      
                   RECORD KEY IS MY-PROV-KEY-45          
                   FILE STATUS IS SS45VF90-STAT.

 FD  SW24VF01.                      
 01  MY-PROV-KEY-24 PIC X(09).      
 01  FILLER         PIC X(1991).    

 FD  SS45VF90.                      
 01  MY-PROV-KEY-45 PIC X(09).      
 01  FILLER         PIC X(1991).  

Error Here:

 32  IGYGR1208-E   The "ORGANIZATION" clause for file "SW24VF01" specified an
                   organization specified in the assignment-name.  An organiz

 37  IGYGR1208-E   The "ORGANIZATION" clause for file "SS45VF90" specified an
                   organization specified in the assignment-name.  An organiz         
Was it helpful?

Solution

You need to get hold of a copy of the Enterprise COBOL Language Reference for the version of Enterprise COBOL you are using. This will most likely be V3.4, V4.1 or V4.2, possibly V5.1 (released in June last year).

For this particular question, any version will do, but going forward it is good to know where to find the one specific to the version of COBOL you are using. Also get the Programming Guide as well.

An internet search for IBM Enterprise COBOL for z/OS library should get you to a page where you can easily locate the correct one.

Locate the ASSIGN clause in the Language Reference.

Format: assignment-name for QSAM files 
    label-S-name  
Format: > assignment-name for VSAM sequential file 
    label-AS-name 
Format: > assignment-name for line-sequential, VSAM indexed, or VSAM relative
file 
    label-name

label- Documents (for the programmer) the device and device class to
which a file is assigned. It must end in a hyphen; the specified value
is not otherwise checked. It has no effect on the execution of the
program. If specified, it must end with a hyphen.

S- For QSAM files, the S- (organization) field can be omitted. AS- For
VSAM sequential files, the AS- (organization) field must be specified.
**For VSAM indexed and relative files, the organization field must be omitted.**

name

A required field that specifies the external name for this file.

Thus, a VSAM KSDS or RRDS requires that the ASSIGN contains very limited information, a label, which is syntax-checked but otherwise not used.

In the past, information in the ASSIGN would have had many more meanings. A different COBOL on a different Operating System may have different requirements. For Enterprise COBOL for z/OS, the ASSIGN is very simple.

In the Programming Guide you will find a Chapter on processing VSAM files. It will assist you in this task.

From that Chapter, an example SELECT statement for a KSDS:

SELECT R-FILE
    ASSIGN TO RELATIVE-FILE
    ORGANIZATION IS RELATIVE
    ACCESS IS RANDOM
    RELATIVE KEY IS RFILE-RELATIVE-KEY
    FILE STATUS IS FSTAT-CODE VSAM-CODE.

You should take note of that second data-name for the FILE STATUS. This is an extension to the simple FILE STATUS, just for VSAM files. It will contain diagnostic information when you have a non-zero FILE STATUS. I suggest you code it, it will make things easier for you.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top