Search code examples
fileaixcobol

IBM COBOL on AIX file access


We are migrating a bunch of COBOL programs from z/OS to AIX 7. We are using the IBM COBOL Compiler (5.1) on AIX. Now I don't understand how the file access and the file system work for COBOL on AIX. The COBOL code is straight forward with

SELECT  :FILE:    ASSIGN       TO  :FILE:
                              ORGANIZATION IS  SEQUENTIAL
                              ACCESS  MODE IS  SEQUENTIAL
                              STATUS       IS  S-STATUS.

and then doing an OPEN INPUT

This compiled fine on AIX:

PP 5724-Z87 IBM COBOL for AIX  5.1.0 in progress ...
LineID  Message code  Message text
    91  IGYGR1216-I   A "RECORDING MODE" of "F" was assumed for file           
                      "CUSTOMERS".                                              
    94  IGYGR1216-I   A "RECORDING MODE" of "F" was assumed for file           
                      "LIST1".                                              
    97  IGYGR1216-I   A "RECORDING MODE" of "F" was assumed for file "UINPUT". 
Messages    Total    Informational    Warning    Error    Severe    Terminating
Printed:       3           3                                               
End of compilation 1,  program xxxxx,  highest severity: Informational.

Now the problem is, that when running the program the file is not found. It gives Status code: 37

I know that I have to provide a file system for the file on the shell (ksh), as such: export CUSTOMERS="STL-CUSTOMERS". The file is in the same directory as the program.

My question is this: Which file system to use? I tried "STL" which seemed to me like the "standard" AIX file system (which is JFS2). But that doesn't work. The other option are (from the COBOL on AIX Programming Guide 5.1):

  • DB2
  • SdU (SMARTdata Utilities)
  • SFS (Encina Structured File Server)
  • STL (standard language)
  • QSAM (queued sequential access method)
  • RSD (record sequential delimited)

We tried all and the file system that worked was "QSAM". The file is a text file (ASCII), that was transfered from the mainframe. But not directly, it was first copied by FTP and then converted to ASCII on Windows (we had to fix the line breaks). When playing around with it to make it work, we edited the file with vi to make the lines 80 characters each. So it was edited on AIX and looks like a ordinary text file on AIX. Why would COBOL still want QSAM as "file system"? What does the term "file system" mean here any way? It seems that it is not in the sense of a real file system such as JFS.


Solution

  • I can see where this would be confusing... Especially coming from a Non-POSIX environment.

    I'll start with the answer, and then provide more information.

    For a normal text file, you want RSD, and to make sure that the \n is column 81. A record length of 80 is just the data portion, not including the delimiter. QSAM (fixed length) would appear to work, but would return the \n as part of the data!

    Your FS=37 means that the attributes of the file don't match what the program is asking for (more esoteric than, say, FS=39 - invalid fixed attributes). In this case, it means the file you wanted to open was not, really, a STL file.

    By filesystem we mean how the data is physically stored on the platter, SSD, RAM, ... More accurately, how we format the record before handing it off to the next lower level of I/O.

    There are two basic types of filesystems:

    • Native (on top of JFS2, JFS, NFS, CIFS, ...) RSD, QSAM, LSQ, STL, SdU. These filesystems can be operated on by standard OS utilities

    • Non-Native (on top of another product) DB2 (DB2) and SFS (TxSeries/CICS). These filesystems are invisible to standard OS utilities

    Then, there are groupings by type of COBOL organization (preferred):

    • Sequential: All filesystems support Sequential...z/OS: QSAM, VSAM
    • Relative: STL, SdU, SFS, DB2...........z/OS: VSAM
    • Indexed: STL, SdU, SFS, DB2...........z/OS: VSAM

    Of the Native filesystems, QSAM(variable), STL and SDU contain metadata, making them not really viewable in vi,cat,... Ok... you can open them in vi, but it will look like utter garbage.

    QSAM is a faithful implementation of z/OS:

    • Fixed length records: Raw data, no BDW/RDW, no line delimiters (\n).
    • Variable length records: RDW + raw data (no \n)... However there is no BDW.

    RSD is a normal stream (text) file; each record is terminated with \n, which is not counted in the record length (the program will never see them).

    LSQ (Line Sequential) is the same as on z/OS - messy semantics.

    VSAM is an alias for a filesystem that provides all the features of z/OS VSAM. Unfortunately, for historical reasons, it points to SdU...

    STL is, by far and away, better at everything than is SdU.

    SdU was the first filesystem to cover QSAM and VSAM, but is old and decrepit, compared to STL.