-1

I am trying to familiarize myself with COBOL. I try to start the following program:

   identification division.
   program-id. Bestand.
   date-written. 08.05.2020

   environment division.
   input-output section.
   file-control.
       select bestand-datei-ein assign to
       "C:\Users\Michael\Desktop\Microfocus\Programme\aus.txt".
       select bestand-datei-aus assign to
       "C:\Users\Michael\Desktop\Microfocus\Programme\aus.txt".

   data division.
   file section.
   fd  bestand-datei-ein label records are omitted.

   01 bestand-satz-ein.
     05 e-teile-nr               PIC X(6).
     05 e-bestand-menge          PIC 9(5).
     05 e-eingang-menge          PIC 9(4).
     05 e-stueck-preis           PIC 999V99.

   fd bestand-datei-aus label records are omitted.

   01 bestand-satz-aus.
     05 a-teile-nr                 PIC X(6).
     05 filler                     PIC X(4).
     05 a-bestand-menge            PIC 9(5).
     05 filler                     PIC X(3).
     05 a-eingang-menge            PIC 9(4).
     05 filler                     PIC X(3).
     05 a-stueck-preis             PIC 999.99.
     05 filler                     PIC X(3).
     05 a-bestand-menge-neu        PIC 9(5).
     05 filler                     PIC X(3).
     05 a-kosten                   PIC 9(6).99.

   01 a PIC X.

   working-storage section.

   01 bestand-datei-ein-ende       PIC X.

   procedure division.

   a000-haupt-steuerung-routine.
       open input      bestand-datei-ein
            output     bestand-datei-aus.

       move 'N' to bestand-datei-ein-ende.

       read bestand-datei-ein
           at end move 'J' to bestand-datei-ein-ende.

       perform b010-listen-bestandsdaten
         until bestand-datei-ein-ende = 'J'.

       close bestand-datei-aus
             bestand-datei-ein.

       accept a.

       stop run.


   b010-listen-bestandsdaten.
       move spaces to bestand-satz-aus.
       move e-teile-nr to a-teile-nr.
       move e-bestand-menge to a-bestand-menge.
       move e-eingang-menge to a-eingang-menge.
       move e-stueck-preis to a-stueck-preis.
       add e-bestand-menge, e-eingang-menge
         giving a-bestand-menge-neu.

       multiply a-bestand-menge-neu by e-stueck-preis
         giving a-kosten.

       read bestand-datei-ein
           at end
               move 'J' to bestand-datei-ein-ende.

I always get the error message "File not found: C: \ Users \ Michael \ Desktop \ Microfocus \ Program \ aus.txt" when I start the program and the should be opened.

I work with Micro Focus Visual Cobol for Visual Studio

Any idea ?

Michael
  • 23
  • 1
  • 6
  • "Any idea" is a special kind of question, not really working for SO's Q&A style. I highly suggest to [take the tour](https://stackoverflow.com/tour) and see if you are able to tweak your question a bit. To "debug" the issue I'd try if it makes any difference to split the `OPEN` into two separate statements and to explicit define `ORGANIZATION IS LINE SEQUENTIAL` (I *guess* this is what you want). – Simon Sobisch May 08 '20 at 19:07
  • 2
    You should not use the same file for both input and output oe if you do you should us it in one mode until done withit in that mode, close it and reopen it in the other mode, – NicC May 08 '20 at 20:31
  • Not really a COBOL issue but I don't think you can have the same file name for input and output at the same time. – Jim Castro May 08 '20 at 20:40
  • 1
    I will formulate my questions more precisely in the future, sorry for the imprecise question. The problem has now been solved. The file names were not displayed correctly in the code (cut and paste errors). It should read "ein.txt" and aus.txt. The problem was that the file names in the file system were set so that the extension is not displayed. I named the input file "ein.txt" and basically created a file named "ein.txt.txt". Therefore the file was not found. Thank you for the answers. The problem is solved. – Michael May 09 '20 at 10:37

1 Answers1

1

From comment:

The problem has now been solved. The file names were not displayed correctly in the code (cut and paste errors). It should read "ein.txt" and aus.txt. The problem was that the file names in the file system were set so that the extension is not displayed. I named the input file "ein.txt" and basically created a file named "ein.txt.txt". Therefore the file was not found.

Rick Smith
  • 3,962
  • 6
  • 13
  • 24