Menu

LINE SEQUENATIAL file invalid data

Anonymous
2023-10-16
2024-06-18
  • Anonymous

    Anonymous - 2023-10-16

    Hi. I started with COBOL and because the most books available are dealing with older compilers I am doing my first steps with RM/COBOL for DOS, which is "freely" available. From time to time I try to compile the code with GnuCobol. And here is a case I can't compile with the latter.

    I wrote a program to create a data file and add entries to it. It compiles without error in RM/COBOL. But with GnuCobol there is a error status = 71:

    error

    When I do with a WORKING-STORAGE area (commented out below), then it compiles with GnuCobol. Any idea why that is?

    IDENTIFICATION DIVISION.
    
    PROGRAM-ID. MAKEART.
    
    ENVIRONMENT DIVISION.
    
    INPUT-OUTPUT SECTION.
    
    FILE-CONTROL.
    
    SELECT AUSGABE-DATEI ASSIGN TO DISK "ARTIKEL.DAT"
    
    ORGANIZATION IS LINE SEQUENTIAL.
    
    DATA DIVISION.
    
    FILE SECTION.
    
    FD AUSGABE-DATEI.
    
    01 AUSGABE-DATEI-RCD.
    
    05 ARTIKELNUMMER PIC 9(8).
    
    05 FILLER PIC X(1).
    
    05 STUECKZAHL PIC 9(6).
    
    05 FILLER PIC X(4).
    
    05 STUECKPREIS PIC 9(5)V99.
    
    05 FILLER PIC X(3).
    
    05 VERTRETER-KENNZAHL PIC 9(4).
    
    05 FILLER PIC X(46).
    
    05 DATENSATZ-ART PIC X.
    
    WORKING-STORAGE SECTION.
    
    77 DATEI-ENDE PIC 9 VALUE 0.
    
    77 DATENSATZ-ZAEHLER PIC 999 VALUE 1.
    
    77 DUMMY PIC X.
    
    *> 01 AUSGABE-DATEI-WS.
    
    *> 05 ARTIKELNUMMER-WS PIC 9(8).
    
    *> 05 FILLER PIC X(1).
    
    *> 05 STUECKZAHL-WS PIC 9(6).
    
    *> 05 FILLER PIC X(4).
    
    *> 05 STUECKPREIS-WS PIC 9(5)V99.
    
    *> 05 FILLER PIC X(3).
    
    *> 05 VERTRETER-KENNZAHL-WS PIC 9(4).
    
    *> 05 FILLER PIC X(46).
    
    *> 05 DATENSATZ-ART-WS PIC X.
    
    
    PROCEDURE DIVISION.
    
    000-BEGIN.
    
    OPEN OUTPUT AUSGABE-DATEI
    
    PERFORM 100-VERARBEITUNG UNTIL DATEI-ENDE = 1
    
    CLOSE AUSGABE-DATEI
    
    STOP RUN.
    
    100-VERARBEITUNG.
    
    INITIALIZE AUSGABE-DATEI-RCD
    
    DISPLAY "Eingabe Datensatz " DATENSATZ-ZAEHLER
    
    DISPLAY "---------------------"
    
    DISPLAY "Art.Nr : " WITH NO ADVANCING
    
    ACCEPT ARTIKELNUMMER
    
    DISPLAY "Stueckzahl : " WITH NO ADVANCING
    
    ACCEPT STUECKZAHL
    
    DISPLAY "Stueckpreis : " WITH NO ADVANCING
    
    ACCEPT STUECKPREIS
    
    DISPLAY "VertreterID: " WITH NO ADVANCING
    
    ACCEPT VERTRETER-KENNZAHL
    
    DISPLAY "Datenart : " WITH NO ADVANCING
    
    ACCEPT DATENSATZ-ART
    
    WRITE AUSGABE-DATEI-RCD
    
    ADD 1 TO DATENSATZ-ZAEHLER
    
    DISPLAY " "
    
    DISPLAY "Weiter (J/N)?"
    
    ACCEPT DUMMY
    
    IF DUMMY NOT EQUAL "J" AND DUMMY NOT EQUAL "j" THEN
    
    MOVE 1 TO DATEI-ENDE
    
    END-IF.
    
     

    Last edit: Simon Sobisch 2023-10-17
  • Simon Sobisch

    Simon Sobisch - 2023-10-17

    There is a mix-up of "compile" and "run".

    You should be able to compile the code with GnuCOBOL - if you use a file and you get a status 71 then you have invalid data (per COBOL2023 LINE SEQUENTIAL), but for compatibility with other environments you can disable the data check, for example using an environment variable COB_LS_VALIDATE=N, also see the 3.2 NEWS file and the runtime configuration (which is nicely included in the manual).

    ... but just glancing on your code there should be no invalid data. Maybe the input on that console is getting strange entries in? You could easily check be enabling the external console in the program configuration. If you still get status 71 there, then please run with COB_LS_VALIDATE=N and upload the result program, allowing us to check what's actually in there.

     

    Last edit: Simon Sobisch 2023-10-17
  • Simon Sobisch

    Simon Sobisch - 2023-10-17

    OK, just tested that myself - the issue is the uninitialized FILLERs.

    If you want to include them in the INITIALIZE then you have to code INITIALIZE AUSGABE-DATEI-RCD WITH FILLER, but the solution to make that work is more easy: just add a VALUE SPACE to all of your FILLER definitions and you should be good and produce a readable file in all COBOL environments.

     
    • Simon Sobisch

      Simon Sobisch - 2023-10-17

      .. or not, at least the VALUE doesn't help, INITIALIZE AUSGABE-DATEI-RCD WITH FILLER (or giving all filler field a name) does.

       
      • Ralph Linkletter

        This should be the default COB_LS_VALIDATE=N
        Perhaps if I were on the COBOL standards committee - I would enable this "advanced" feature.
        I am not.
        I do not know anybody that is.

        Ralph

         
        • Simon Sobisch

          Simon Sobisch - 2023-10-18

          Actually this is one of the cases where I think this is quite useful.
          The OP likely did not want low-values (or other garbage) in his LINE SEQUENTIAL file.

           
  • Chuck Haatvedt

    Chuck Haatvedt - 2023-10-18

    Hello,

    I would suggest that you issue the following statement immediately after opening your output file and then again after each WRITE verb as well

    MOVE SPACES TO AUSGABE-DATEI-RCD.

    the reason for this is that on some compilers the location of the 01 level in the FD is actually in a buffer. The buffer can be large enough to contain multiple records, so when the WRITE verb is issued, the runtime may actually just move the pointer to the record which the operating system may or may not have initialized.

    So the above practice ensures that the record area is set to spaces before any other data is moved to it. This should eliminate the issue you encountered with the status 71.

    As a best practice I would recommend always using the FILE STATUS IS xxxx clause as part of the SELECT statement. Then after every I/O operation on the file, check the file status variable to ensure that the I/O was successful. You can check the programmers guide for more information on this.

       Chuck Haatvedt
    
     
  • Colin Sare-Soar

    Colin Sare-Soar - 2024-06-18

    I kept getting the status = 71 error on a practise file downloaded from course material. I spent a long time trying to find uninitialized data but it turned out that as the input file had been downloaded from a mainframe there was an additional CRLF at the end and that was causing an extra read and that generated the error. Once deleted the program ren properly and EOF was found.

     

Anonymous
Anonymous

Add attachments
Cancel