1
votes

Hello guys I'm currently learning COBOL and I'm kinda stuck in my exercise. I'm currently using the german book Insider COBOL to get into the topic.

Now the problem: I was reconstructing the introduction example, it's a calculator for the gross price, you write the amount of products, the price and the VAT and the programm will give you the net amount, the VAT amount and the gross amount back.

At the end I saw I had a typo earlier in the code so i fixed it. After that the whole Procedure Division went wild with all my Displays where I create the gui.

Every error says "syntax error, unexpected (" a few say "expecting OMITTED or Identifier" after the syntax error too. I googled if thesyntax has changed but I don't really get it, whats wrong.

Here is the code:


   PROCEDURE DIVISION.
  ******************************************************************
   B100.
  ******************************************************************
  *****    Ausgabe Bildkopf
  ******************************************************************
       DISPLAY (1,1) ERASE.                *>Löschen des Bildschirms
       DISPLAY (1,1)
       'B R U T T O P R E I S B E R E C H N U N G            PROG01'
               WITH HIGHLIGHT.
       DISPLAY (2,1) S-Strich.
  ******************************************************************
  *****    Einlesen der Daten 
  ******************************************************************
   B150.
       DISPLAY (3,1) 
           'MENGE..............................:'.
       ACCEPT  (3,40)  E-MENGE.
       DISPLAY (4,1) 
           'EINZELPREIS:.......................:'.
       ACCEPT  (4,40)  E-PREIS.
       DISPLAY (5,1)  
           'MW-ST-PROZENTSATZ..................:'.
       ACCEPT  (5,40) E-MWST.
       DISPLAY (6,1) S-Strich.
  ******************************************************************
  *****    Berechnung
  ******************************************************************
   B200.
       COMPUTE S-NETTO = E-MENGE*E-PREIS.
       COMPUTE
          S-MWST-BETR = S-NETTO*E-MWST/100.
       COMPUTE S-BRUTTO = S-NETTO+S-MWST-BETR.
  ******************************************************************
  *****    Ausgabe der Ergebnisse
  ******************************************************************
   B300.
       MOVE    S-NETTO     TO  A-NETTO.     *>Übertragen in Ausgabe
       DISPLAY (8,1)
           'NETTOWERT:....................:'.
       DISPLAY (8,30) A-NETTO.
       MOVE    S-MWST-BETR TO  A-MWST-BETR.
       DISPLAY (9,1) 
           'MEHRWERTSTEUER:...............:'.
       DISPLAY (9,30)  A-MWST-BETR.
       MOVE    S-BRUTTO    TO  A-BRUTTO.
       DISPLAY (10,1)
           'BRUTTOPREIS:..................:'.
       DISPLAY (10,30) A-BRUTTO.
  ******************************************************************
  *****    Ausgabe Systemzeile
  ******************************************************************
   B400.
       DISPLAY (23,1)  S-Strich    ERASE.
       DISPLAY (24,1)  'WEITERE BERECHNUNGEN (J/N) :'.
       ACCEPT  (24,40) S-WEITER    WITH    AUTO-SKIP.
       IF  S-WEITER    = 'J'   *> es werden nur Großbuchstaben
           GO TO   B100        *> aktzeptiert
       END-IF.
       IF  S-WEITER = 'N'
           GO To B900
       END-IF.
  *****    falsche Eingabe:
       GO TO B400.

I hope I'm not blind or something and thank you in advance :)

1
What's the actual, full error message? - melpomene
syntax error, unexpected (, expecting OMITTED or Identifier //and sometimes the expecting... part is missing - PIumpsKIo
No filename or line number? - melpomene
Filename is my Test.cbl and the lines are 56,57 and so on everywhere where the DISPLAY is. - PIumpsKIo
Please edit your question and supply a Minimal, Complete, and Verifiable Example. - cschneid

1 Answers

2
votes

Judging from the code and the error message, it looks like you're trying to compile Microsoft COBOL with GnuCOBOL. Sadly, GnuCOBOL does not (yet) recognise the Microsoft-style position-specifier. So you'll have to manually translate every DISPLAY and ACCEPT statement to standard COBOL; for instance,

 DISPLAY (3,1) 
     'MENGE..............................:'.
 ACCEPT  (3,40)  E-MENGE.

becomes

 DISPLAY
     'MENGE..............................:'
     AT LINE 3 COL 1
 ACCEPT E-MENGE LINE 3 COL 40.

More of a problem is the ERASE phrase in DISPLAY. The closest GnuCOBOL has to that is Micro Focus' DISPLAY SPACES extension. To use it, change, for example,

   DISPLAY (23,1)  S-Strich    ERASE.

to

   DISPLAY S-Strict LINE 23 COL 1, SPACES