2
votes

I'm trying to open a sequential dataset.

I get the file status 37, for which IBM says:

An OPEN statement was attempted on a file that would not support the open mode specified in the OPEN statement. Possible violations are:

  • The EXTEND or OUTPUT phrase was specified but the file would not support write operations.
  • The I-O phrase was specified but the file would not support the input and output operations permitted.
  • The INPUT phrase was specified but the file would not support read operations.

I suspect the third, because the relevant bits of my program are :

  *----------------------
   INPUT-OUTPUT SECTION.
  *----------------------

   FILE-CONTROL.

 *    input file 1
      SELECT INPUT-1-FILE
         ASSIGN TO EXAMPLE
         ORGANIZATION IS RELATIVE
         ACCESS MODE IS DYNAMIC
         RELATIVE KEY IS INPUT-1-ACCESS-KEY
         FILE STATUS IS INPUT-1-FS
         .


  ****************
   DATA DIVISION.
  ****************

  *--------------
   FILE SECTION.
  *--------------

  * fichier 1
   FD INPUT-1-FILE
       .
   01 INPUT-1-LINE.
     05 filler                     PIC X(300).


  *-------------------------
   WORKING-STORAGE SECTION.
  *-------------------------

   77 INPUT-1-ACCESS-KEY           PIC 9(3) comp value 1.

   01 INPUT-1-FS                   PIC 99 value 00.


  *********************
   PROCEDURE DIVISION.
  *********************

       OPEN INPUT INPUT-1-FILE
       DISPLAY INPUT-1-FS

And the DD card in my JCL looks like :

EXAMPLE DD DISP=SHR,DSN=MY.DATASET.NAME

We're using COBOL v5, so I checked IBM's relevant docs, but I can't find any reason that my file is not openable in input mode.

Here are my dataset's characteristics: ISPF dataset info screen

And the result of a VSAM listcat: VSAM listcat result

3
The reference you provide is for iSeries, if you're running on z/OS you want the mainframe reference. It says the same thing as what you quote for this error, but just for future reference... - cschneid
Is the file a KSDS or RRDS VSAM file? - cschneid
ESDS, I think. Is that the problem ? - SCH
I'm not certain, I've never done ESDS but the documentation seems to talk about relative and indexed files without mentioning ESDS specifically. - cschneid
Clearing up a few missing points...First, the non-VSAM analog to an RRDS is BDAM, but IBM COBOL doesn't provide BDAM support anymore (you can use a subroutine in another language if you want to use BDAM in COBOL).BDAM has efficient block-oriented direct access, very similar to RRDS. To fill another blank, a cool things about VSAM is that a given file can be accessed in different ways... generally any VSAM KSDS or ESDS can also be opened and processed by relative record number as though it was an RRDS. It's all spelled out in "z/OS DFSMS Using Datasets" if you want the details. - Valerie R

3 Answers

2
votes

In your program, ORGANIZATION IS RELATIVE means the input file must be a relative record data set (RRDS) VSAM file, which can be defined using the IDCAMS DEFINE command. What could be happening is that if the file you open is a sequential file, you get a file status of 37. More information about IDCAMS DEFINE is mentioned in IBM Redbook "VSAM Demystified" section 1.5.3, 'Relative record data set'.

You can make the input file a VSAM file with something like the following:

//[YOURID]  JOB ,
// MSGCLASS=S,REGION=0M,COND=(9,LT),NOTIFY=&SYSUID,TIME=(1,1)
//*********************************************************************
//* Create a VSAM
//*********************************************************************
//S1IDCAMS   EXEC  PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//SYSIN    DD  *
DELETE   ([YOURID].P00695.VSAMRRDS) CLUSTER PURGE
DEFINE CLUSTER (NAME([YOURID].P00695.VSAMRRDS)   -
           NUMBERED                                -
           RECORDSIZE(80 80)                      -
           BUFFERSPACE(2048)                       -
           SHAREOPTIONS(4 3)                       -
           VOLUMES(SYS162))                        -
   DATA    (NAME([YOURID].P00695.VSAMRRDS.DATA) -
           TRACK(1,1)                              -
           CISZ (1024))
/*
//S2REPRO    EXEC  PGM=IDCAMS
//SYSPRINT DD  SYSOUT=*
//VSAM  DD DISP=SHR,DSN=[YOURID].P00695.VSAMRRDS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
REPRO OUTFILE(VSAM) INFILE(INREC)
/*
//INREC  DD *
XXXXXXX060ALISONALISONALISONALISONALISONALISONALISONALISONAL        ISONALIS
XXXXXXX060ALISONALISONALISONALISONALISONALISONALISONALISONAL        ISONALIS
/*
1
votes

In the IBM docs linked in the question (page 126: FILE-CONTROL paragraph) it is said that the relative access mode is only available for VSAM files :

table from IBM doc

Problem: the input file is currently not a VSAM file.

Solution: make the input file a VSAM file.

This worked:

DD card in the JCL when creating the input file:

//FOO      DD DISP=(NEW,CATLG,DELETE),
//         SPACE=(TRK,(1000,1000),RLSE),
//         LRECL=300,
//         RECORG=RR,
//         DSN=MY.DATASET.NAME

The RECORG parameter makes the dataset an RRDS. The lines don't have an easily defined key, so I couldn't use a KSDS and I need the random access, so no ESDS either.

DD card for reading the dataset:

//BAR      DD DISP=SHR,DSN=MY.DATASET.NAME

And then in the COBOL program (in FILE-CONTROL):

       SELECT INPUT-FILE
         ASSIGN TO BAR
         ORGANIZATION IS RELATIVE
         ACCESS MODE IS DYNAMIC
         RELATIVE KEY IS INPUT-FILE-KEY
         FILE STATUS IS INPUT-FILE-STATUS
         .
0
votes

If you want to open a sequential dataset for read, you need to open it for Input (done!), have it in the JCL with DISP=SHR (you could try with OLD, but don't need it), and have ACCESS IS SEQUENTIAL.

ACCESS IS RELATIVE as noted by other users is for VSAM only, and your IDCAMS output shows that this is not a VSAM file. If it's just a sequential dataset, you don't need a key either.