0

(Windows 11) I am creating a text file of currently running tasks and I am having difficulty reading it into my OPENCOBOLILE program. The open is fine, but on the first read I receive an error code 1000 (file size error). In looking at the file it seems to be a variable length file with crlf. I am an as/400 Cobol programmer, getting back into Cobol after quite a few years and I've never done any COBOL coding on Windows. Can anyone offer any advice on how to set up my file select or environment variables to read this file? Thank you!


Environment division.
       input-output section.
       file-control.
           select webinput assign to KEYBOARD
                file status is ws-in-status.
           
           select tasklist ASSIGN TO 'g:\temp\tasklist.txt'
                file status is ws-if-status.

       data division.
       file section.
       fd  webinput.
           01 chunk-of-post        pic x(1024).
               
       fd  tasklist.
           01 Ws-Input-Data.
               05  filler          pic x.
               05  ws-id-name      pic x(12).
               05  filler          pic x(1011).

PROCEDURE DIVISION.
           OPEN InPUT tasklist.
               display ws-if-status.
               PERFORM UNTIL WS-EOF='Y'
                   READ tasklist at end
                       display ws-if-status
                       MOVE 'Y' TO WS-EOF
                       NOT AT END DISPLAY ws-value-string
                   END-READ
                END-PERFORM.
           CLOSE tasklist.
           STOP RUN.

enter image description here

  • Not sure how "ws-if-status" is defined; it should be PIC X(02). In any case you want to use `ORGANIZATION IS LINE SEQUENTIAL`. Also you _may_ want to switch to GixIDE which is maintained and also provides newer windows binaries for GnuCOBOL (for OCIDE you'd have to update those on your own). If anything helped to get to the answer: please answer yourself as if you'd explain the solution and reason to someone else - that matches StackOverflows Q+A style quite fine (and you'd have an accepted answer, too). – Simon Sobisch Jul 24 '23 at 18:50
  • Thank you. I added the Line Sequential and I'm now getting a return code of '10' - eof . The file is definitely there and has data in it. Thoughts? – Jim French Jul 25 '23 at 13:18
  • I _guess_ it is completely processed any you may not see the results; or you use an older version of GnuCOBOL and get the EOF because there's not a record of 1024 in it. The best is to try that outside of OCIDE - and possibly update it from https://arnoldtrembley.com/GnuCOBOL.htm – Simon Sobisch Jul 26 '23 at 05:57
  • Thank you. I was able to do this easily in Rexx. It would still be helpful for me to be able to read a variable length file in COBOL. Perhaps I'll take a shot at writing a Rexx program to convert a variable length file to fixed. Thanks for your help. – Jim French Jul 26 '23 at 15:18
  • That works fine in COBOL... so you either may go on or check with on a COBOL discussion group / mailing list if you feel stranded. For the former you may want to head to https://sourceforge.net/p/gnucobol/discussion/help/ – Simon Sobisch Jul 26 '23 at 19:13
  • I appreciate your help. Thank you! – Jim French Jul 27 '23 at 11:48

0 Answers0