Skip to main content
Question

ASSIGN TO DYNAMIC VSAM

  • November 4, 2025
  • 1 reply
  • 44 views

Bruce Cheatwood
Forum|alt.badge.img+2

I have a KSDS VSAM file that has been extracted from mainframe and converted to Enterprise Server 10 using the VRECGEN and Classic Data tools utilities.  Currently the Cobol program that reads this file is compiled under “Enterprise COBOL for z/OS”.  When I run the cobol program using a DD statement in the JCL the file opens and retrieves data.

I have a need to be able to dynamically supply the file name inside the Cobol program instead of the JCL and have been experimenting with using “ASSIGN TO DYNAMIC” and compiling the program under the “MicroFocus” dialect.  When I try this method to open the file I get a VSAM return code of 39 indicating that the file definition on the server and the definition in the Cobol program don’t match.  

Is this related somehow to the VRECGEN process and is there any way to have the DYNAMIC assignment work?

Also, my platform is Windows and IDE is Visual Studio.

1 reply

Bruce Cheatwood
Forum|alt.badge.img+2

Here is some further information regarding my environment and program code (still haven’t worked through this one).

Enterprise Server 10.0 (Windows)

Catalog Definition:
DSName:   VSAM.ABC
Physical File:  C:\ES\...\Catalog\VSAM\VSAM.ABC.DAT
DS Org:  VSAM
Codeset:  ASCII
LRECL:  131
BLKSIZE: 0
RECFM:  KS
VSAM Type:  Cluster
Key Start:  0
Key Length: 13
Rec Max Length:  131
Rec Avg Length:  131

COBOL Definition:
FILE-CONTROL.
SELECT VSAM-KSDS-FILE ASSIGN TO DYNAMIC WS-FILENAME
    ORGANIZATION IS INDEXED
    ACCESS MODE IS RANDOM
    RECORD KEY IS VSAM-KSDS-RECORD-KEY
    FILE STATUS IS VSAM-STATUS

FILE SECTION.
FD VSAM-KSDS-FILE.
01 VSAM-KSDS-RECORD.
    05 VSAM-KSDS-RECORD-KEY PIC X(13).
    05 TOL-DATA PIC X(20).
    05 EXTRA-DATA PIC X(98).

WORKING-STORAGE-SECTION.
01 VSAM-STATUS PIC X(02).
01 WS-FILENAME PIC X(256).

PROCEDURE DIVISION.
MOVE "C:\ES\...\Catalog\VSAM\VSAM.ABC.DAT" TO WS-FILENAME.

OPEN INPUT VSAM-KSDS-FILE.
    (The open returns a VSAM file status of 39)