Search code examples
cobol

Cobol Treating Multiple Lines as One Line When it Should Not


Trying to code a cobol program and it keeps treating multiple lines as one line when compiling with opencobol (have to use opencobol, I've heard GNU is better), giving errors The code is

       IDENTIFICATION DIVISION.
       PROGRAM-ID. InteractiveProcessing.
       ENVIRONMENT DIVISION.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           SELECT INVENTORY-FILE
              ASSIGN TO "C:\COBOL\INVENTORY-FILE.DAT"
              ORGANIZATION IS LINE SEQUENTIAL.
       DATA DIVISION.
       FILE SECTION.
       FD  INVENTORY-FILE.
       01  FILE-OUTPUT.
           05  PART-NO          PIC X(5).
           05  PART-DESC        PIC X(15).
           05  QTY-ON-HAND      PIC 9(5).
           05  UNIT-PRICE       PIC 999V99.
       WORKING-STORAGE SECTION.
       01  MORE-DATA                PIC X(3) VALUE 'YES'.
       PROCEDURE DIVISION.
       100-MAIN-MODULE.
           OPEN OUTPUT INVENTORY-FILE
           PERFORM UNTIL MORE-DATA = 'NO '
               PERFORM 200-INVENTORY-MODULE
               DISPLAY 'ENTER MORE DATA? (YES/NO)'
               ACCEPT MORE-DATA
           END-PERFORM
           CLOSE INVENTORY-FILE
           STOP RUN.
       200-INVENTORY-MODULE.
           DISPLAY 'ENTER PART NUM (5 CHARACTERS)'
           ACCEPT PART-NO
           DISPLAY 'ENTER PART DESCRIPTION (15 CHARACTERS)'
           ACCEPT PART-DESC                      
           DISPLAY 'ENTER QUANTITY ON HAND(INTEGER, UP TO 5 DIGITS)'
           ACCEPT QTY-ON-HAND
           DISPLAY 'ENTER UNIT PRICE (5 DIGITS, 2 AFTER DECIMAL)'
           ACCEPT UNIT-PRICE
           WRITE FILE-OUTPUT.

The errors I keep getting say

'ENTER' undefined 

and

syntax error, unexpected UNIT

The line the errors are appearing on is

DISPLAY 'ENTER QUANTITY ON HAND(INTEGER, UP TO 5 DIGITS)'

The errors are from ENTER and UNIT from two lines down and I can't figure out why this is happening. Changing the quotation marks from single to double on just that line then gives an unexpected end of file error as well.


Solution

  • The problem was that I used tab to align the PIC clauses. Had the same issue in another program. Solved by backspacing the tabs then just using the spacebar to get the clauses to the right spot. Looks the same in the end but actually ran this way.