'Error: syntax error, unexpected "Identifier", expecting EXTERNAL or GLOBAL

Hi I was wondering if yall could help me figure this error out. Im rather new to cobol as it is my first (and only) cobol class in my major.

I keep getting this error lab3a.cob:23: Error: syntax error, unexpected "Identifier", expecting EXTERNAL or GLOBAL

whenever I try to compile. And I cant seem to see what I'm doing wrong.

My Code

   IDENTIFICATION DIVISION.
   PROGRAM-ID. "LAB3A".
   Author.     Fielding Featherston
   * Takes inputs from file and seperates.

   ENVIRONMENT DIVISION.
   INPUT-OUTPUT SECTION.
   FILE-CONTROL.
       SELECT InFile
        ASSIGN to "lab3-in.dat" 
        ORGANIZATION is LINE SEQUENTIAL.
   
   DATA DIVISION.
   FILE SECTION.
   FD   InFile.
   01       InString.
        05              PIC X(13).
        05  Instrument  PIC X(12).
             88  Brass       value "Bugle" "Flugelhorn" 
                                   "Sousaphone" "Trombone"
                                   "Trumpet" "Tuba".
             
             88  Percussion  value "Bass Drum" "Bells" "Bongos"
                                   "Castanets" "Chimes" "Cymbals"
                                   "Snare Drum" "Xylophone".
             
             88  Strings     value "Banjo" "Bass" "Cello" "Guitar"
                                   "Harp" "Lyre" 
                                   "Mandolin" "Violin".
             
             88  Woodwind    value "Bagpipes" "Bassoon" "Clarinet"
                                   "Flute" "Oboe" 
                                   "Piccolo" "Saxophone".                                      
   WORKING-STORAGE SECTION.
   01   BrassCount      PIC 9(3).
   01   PerCount        PIC 9(3).
   01   StringCount     PIC 9(3).
   01   WoodCount       PIC 9(3).
   01   OtherCount      PIC 9(3).
   01   BrassStr        PIC ZZ9.
   01   PerStr          PIC ZZ9.
   01   StringStr       PIC ZZ9.
   01   WoodStr         PIC ZZ9.
   01   OtherStr        PIC ZZ9.
   01   InStringLength  PIC 99.
   01   EndFileStr      PIC X VALUE "n".                                      
        88  EndFile         VALUE "y"
                            When Set to False is "y".

   PROCEDURE DIVISION.
   000-Main.
       Open Input InFile
       Perform until EndFile
           Read InFile
               At end
                   Set EndFile to FALSE
               Not at End
                   PERFORM 100-SeperateStrings
                   PERFORM 200-ClassCount
           END-READ
       END-PERFORM
       CLOSE InFile
       Move BrassCount  to BrassStr
       Move PerCount    to PerStr
       Move StringCount to StringStr
       Move WoodCount   to WoodStr
       Move OtherCount  to OtherStr
       DISPLAY "Counts"
       DISPLAY "    Brass:       " FUNCTION TRIM(BrassStr)
       DISPLAY "    Percussion:  " FUNCTION TRIM(PerStr)
       DISPLAY "    String:      " FUNCTION TRIM(StringStr)
       DISPLAY "    Woodwind:    " FUNCTION TRIM(WoodStr)
       DISPLAY "    OTHER:       " FUNCTION TRIM(OtherStr)
       STOP RUN.

   100-SeperateStrings.
       MOVE FUNCTION Length(InString) to InStringLength
       UNSTRING InString (14:InStringLength)
           INTO Instrument
       END-UNSTRING.

   200-ClassCount.
       IF Brass
           Add 1 to BrassCount
       ELSE IF Percussion
           Add 1 to PerCount
       ELSE IF Strings
           Add 1 to StringCount
       ELSE IF Woodwind
           Add 1 to WoodCount
       ELSE
           Add 1 to OtherCount
       END-IF.              


Solution 1:[1]

An EXTERNAL or GLOBAL clause in the context of the error may only occur in a record description entry; that is, a data entry that begins with 1 or 01. Given that the error occurs between two 88 level items, it appears the compiler is confused about where it is while scanning the source code.

There is some unusual formatting that may be creating a problem with an the compiler. In particular, line 22 contains a number of TAB characters that should not, but may, confuse the compiler. Also, lines 33 and 46 contain a number of TAB characters at the end of each source line causing the lines to exceed 72 characters.

Another possible issue is expansion of tabs, whether each TAB character is replaced by 4 or 8 spaces by the compiler. Again this will affect whether the text exceeds 72 characters. In the absence of a SOURCE FORMAT directive, source text after column 72 is ignored.

Until you know the effect that tabs have on the source code, I suggest replacing all tabs with spaces.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Rick Smith