Link to home
Start Free TrialLog in
Avatar of Sinsual34
Sinsual34

asked on

COBOL program using array wont compile

Can someone take a look and give some advice on why this program isnt compiling?  I would really appreciate it!  Here are some of the messages I get when I compile.  Thanks!

MSGID: LBL1326  SEVERITY: 30  SEQNBR:  015300                  
Message . . . . :   'ENTRIES' not defined name. Default item    
  assumed.                                                      
MSGID: LBL1338  SEVERITY: 30  SEQNBR:  015300                  
Message . . . . :   Table-name expected; ' DUMMY-NAME ' found.  
  Statement ignored.                                            
MSGID: LBL1447  SEVERITY: 30  SEQNBR:  015400                  
Message . . . . :   Statement incomplete; last valid item found
  before 'AT'. Statement ignored.                              
MSGID: LBL0018  SEVERITY: 00  SEQNBR:  015400                  
Message . . . . :   Input ignored starting with 'AT'.          
MSGID: LBL0013  SEVERITY: 00  SEQNBR:  015400                  
Message . . . . :   Compilation continued starting with 'END'.
MSGID: LBL1600  SEVERITY: 30  SEQNBR:  015400                
Message . . . . :   'DECLARATIVES' expected, 'DISPLAY' found.
  Clause or statement ignored.                                
MSGID: LBL0018  SEVERITY: 00  SEQNBR:  015400                
Message . . . . :   Input ignored starting with 'DISPLAY'.    
MSGID: LBL0013  SEVERITY: 00  SEQNBR:  015400                
Message . . . . :   Compilation continued starting with      
  'DISPLAY'.                                                  
MSGID: LBL1325  SEVERITY: 30  SEQNBR:  015600                
Message . . . . :   'WHEN' invalid and ignored, processing    
  continues at next verb or procedure-name in Area A.        
MSGID: LBL0018  SEVERITY: 00  SEQNBR:  015600                
Message . . . . :   Input ignored starting with 'WHEN'.      
MSGID: LBL0013  SEVERITY: 00  SEQNBR:  015700                
Message . . . . :   Compilation continued starting with 'ADD'.


  PROCESS APOST.                                                  
                                                                 
  IDENTIFICATION DIVISION.                                        
                                                                 
  PROGRAM-ID. D1501P.                                            
                                                                 
  AUTHOR.                                  
                                                                 
 *****************************************************************
 *                                                               *
 *  THIS PROGRAM PRINTS THE TOTAL SALES FIGURE FOR EACH SALES    *
 *  PERSON.                                                      *
 *                                                               *
 *****************************************************************

                                             
 ENVIRONMENT DIVISION.                        
                                             
 INPUT-OUTPUT SECTION.                        
                                             
 FILE-CONTROL.                                
     SELECT SALES-TRANSACTION-FILE            
        ASSIGN TO DATABASE-D1501P            
        ACCESS IS SEQUENTIAL.                

     SELECT PRINT-FILE                            
        ASSIGN TO PRINTER-QPRINT.                
                                                 
 DATA DIVISION.                                  
                                                 
 FILE SECTION.                                    
                                                 
 FD  SALES-TRANSACTION-FILE.                      

                                                               
 01  SALES-TRANSACTION-RECORD.                                
     05 SALESPERSON-NUMBER                                    
        OCCURS 20 TIMES             PIC S9(2).                
     05 SALESPERSON-NAME            PIC X(20).                
     05 AMOUNT-OF-SALES             PIC 9(5)V99 PACKED-DECIMAL.
                                                               
 FD  PRINT-FILE.                                              
 01  PRINT-RECORD-OUT               PIC X(80).                

                                                             
WORKING-STORAGE SECTION.                                      
                                                             
01  WS-CURRENT-DATE.                                          
    05  WS-CURRENT-YEAR             PIC 9(2).                
    05  WS-CURRENT-MONTH            PIC 9(2).                
    05  WS-CURRENT-DAY              PIC 9(2).                
                                                             
01 WS-TOTAL-ACCUMULATORS.                                    
   05  WS-TOTAL-SALES               LIKE AMOUNT-OF-SALES (+2).
                                                               
01  CONTROL-FIELDS.                                            
    05 ARE-THERE-MORE-RECORDS       PIC X(3) VALUE 'YES'.      
        88 NO-MORE-RECORDS                  VALUE 'NO'.        
    05  WS-PAGE-COUNTER             PIC 9(3)    PACKED-DECIMAL  
                                                VALUE ZEROS.    
    05  WS-LINE-COUNTER             PIC 9(3)    PACKED-DECIMAL  
                                                VALUE 60.      
 01  TOTAL-SALES-ARRAY.                                          
     05 SALES-TOTAL               OCCURS 20 TIMES INDEXED BY SUB.
         10 T-SALESPERSON-NUMBER  LIKE SALESPERSON-NUMBER.      
         10 T-SALES               LIKE AMOUNT-OF-SALES (+2).    
         10 T-SALESPERSON-NAME    LIKE SALESPERSON-NAME.        
                                                                 
 01  ERROR-LINE.                                                
     05                          PIC X(23)                      
                                 VALUE 'ERROR IN SALES FIELD - '.
     05 ERROR-SALES-OUT          PIC 9(2).                  
                                                             
 01 HEADING-1.                                              
    05                           PIC X(2)    VALUE SPACES.  
    05  HL-CURRENT-MONTH         PIC 9(2).                  
    05                           PIC X(1)    VALUE '/'.      
    05  HL-CURRENT-DAY           PIC 9(2).                  
    05                           PIC X(1)    VALUE '/'.      
    05  HL-CURRENT-YEAR          PIC 9(2).                  
     05                           PIC X(9)    VALUE SPACES.    
     05                           PIC X(20)                    
                                  VALUE 'TOTAL SALES FOR EACH'.
     05                           PIC X(11)                    
                                  VALUE 'SALESPERSON'.        
     05                           PIC X(9)    VALUE SPACES.    
     05                           PIC X(4)    VALUE 'PAGE'.    
     05  HL-PAGE                  PIC Z9      VALUE ZERO.      
                                                                 
  01 HEADING-2.                                                  
     05                           PIC X(2)   VALUE SPACES.      
     05                           PIC X(11)  VALUE 'SALESPERSON'.
                                                                 
  01 HEADING-3.                                                  
     05                           PIC X(5)   VALUE SPACES.      
     05                           PIC X(6)   VALUE 'NUMBER'.    
     05                           PIC X(10)  VALUE SPACES.      
     05                           PIC X(16)                      
                                  VALUE 'SALESPERSON NAME'.      
     05                           PIC X(11)  VALUE SPACES.      
     05                           PIC X(11)  VALUE 'TOTAL SALES'.
                                                                 
  01 DETAIL-RECORD.                                              
     05                           PIC X(7)   VALUE SPACES.      
     05 DR-SALESPERSON-NUMBER     PIC 9(2).                      
     05                           PIC X(12)  VALUE SPACES.      
     05 DR-SALESPERSON-NAME       PIC X(20).                    
     05                           PIC X(9)   VALUE SPACES.    
     05 DR-AMOUNT-OF-SALES        PIC ZZ,ZZZ.99.              
                                                             
  01 TOTAL-LINE.                                              
     05                           PIC X(21)  VALUE SPACES.    
     05                           PIC X(19)                  
                                  VALUE 'TOTAL COMPANY SALES'.
     05                           PIC X(4)   VALUE SPACES.    
     05 TL-TOTAL-SALES            PIC $$,$$$,$$$.99.          
                                                 
   PROCEDURE DIVISION.                            
                                                 
   000-MAIN-MODULE.                              
       PERFORM 100-INITIALIZATION-RTN.            
       PERFORM 200-ADD-TO-BALANCE-RTN            
           UNTIL NO-MORE-RECORDS.                
       PERFORM 300-PRINT-RTN                      
           VARYING SUB FROM 1 BY 1 UNTIL SUB > 20.
       PERFORM 400-TERMINATION-RTN.              
       STOP RUN.                                
                                                 
   100-INITIALIZATION-RTN.                      
       OPEN INPUT SALES-TRANSACTION-FILE        
            OUTPUT PRINT-FILE.                  
       ACCEPT WS-CURRENT-DATE FROM DATE.        
       MOVE WS-CURRENT-MONTH TO HL-CURRENT-MONTH.
       MOVE WS-CURRENT-DAY TO HL-CURRENT-DAY.    
        MOVE WS-CURRENT-YEAR TO HL-CURRENT-YEAR.
        INITIALIZE WS-TOTAL-ACCUMULATORS.      
        READ SALES-TRANSACTION-FILE            
            AT END                              
                SET NO-MORE-RECORDS TO TRUE    
        END-READ.                              
                                               
    200-ADD-TO-BALANCE-RTN.                    
        SET SUB TO 1.                          
        SEARCH ENTRIES                                              
            AT END DISPLAY 'There are more than 20 salespeople'    
                   STOP RUN                                        
            WHEN T-SALESPERSON-NUMBER (SUB) = SALESPERSON-NUMBER    
                   ADD AMOUNT-OF-SALES TO T-SALES (SUB)            
            WHEN T-SALESPERSON-NUMBER (SUB) = ZEROS                
               MOVE SALESPERSON-NUMBER TO T-SALESPERSON-NUMBER (SUB)
               MOVE AMOUNT-OF-SALES TO T-SALES (SUB)                
        END-SEARCH.                                                
        ADD AMOUNT-OF-SALES TO TL-TOTAL-SALES.    
        READ SALES-TRANSACTION-FILE              
            AT END                                
                SET NO-MORE-RECORDS TO TRUE      
        END-READ.                                
                                                 
    226-PRINT-HEADING-RTN.                        
        ADD 1 TO WS-PAGE-COUNTER.                
        MOVE WS-PAGE-COUNTER TO HL-PAGE.          
     WRITE PRINT-RECORD-OUT FROM HEADING-1.
     WRITE PRINT-RECORD-OUT FROM HEADING-2
         AFTER ADVANCING 2 LINE.          
     WRITE PRINT-RECORD-OUT FROM HEADING-3
         AFTER ADVANCING 1 LINES.          
     MOVE SPACES TO PRINT-RECORD-OUT.      
     WRITE PRINT-RECORD-OUT                
         AFTER ADVANCING 1 LINE.          
     MOVE 5 TO WS-LINE-COUNTER.            
                                                                 
 300-PRINT-RTN.                                                  
     PERFORM 226-PRINT-HEADING-RTN.                              
     IF T-SALESPERSON-NUMBER (SUB) = ZEROS                      
         SET SUB TO 25                                          
     ELSE                                                        
         MOVE T-SALESPERSON-NUMBER (SUB) TO DR-SALESPERSON-NUMBER
         MOVE T-SALESPERSON-NAME (SUB) TO DR-SALESPERSON-NAME    
         MOVE T-SALES (SUB) TO DR-AMOUNT-OF-SALES                
         WRITE PRINT-RECORD FROM DETAIL-RECORD          
     END-IF.                                            
                                                       
                                                       
 400-TERMINATION-RTN.                                  
     MOVE WS-TOTAL-SALES TO TL-TOTAL-SALES.            
     WRITE PRINT-RECORD-OUT FROM TOTAL-LINE            
         AFTER ADVANCING 2 LINES.                      
     CLOSE SALES-TRANSACTION-FILE                      
          SALES-TRANSACTION-FILE-REPORT.

ASKER CERTIFIED SOLUTION
Avatar of daveslater
daveslater
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Member_2_276102
Member_2_276102

Yep. SEARCH SALES-TOTAL rather than SEARCH ENTRIES.

As the message says, there is no definition in the programs of any array or table named ENTRIES. You can't search through an array/table that doesn't exist.

If you don't have a COBOL reference handy, see:

http://publib.boulder.ibm.com/cgi-bin/bookmgr/BOOKS/QB3AG302/CCONTENTS?DT=19990312112008

That's a V4R4 book, but COBOL hasn't changed much. It's also a friendlier site than the current InfoCenter stuff.

Tom
Hi
Can I just ask why you accepted tom's answer when he basically agreed with what I told you?

dave
I also would be curious about the acceptance of the answer. I intended nothing but to help confirm Dave's statements. Points are no big deal for me.

Second opinions can lend credibility perhaps, but credit also builds... ummm... credibility.

Tom
Avatar of Sinsual34

ASKER

Sorry I didnt get back to you earlier.  Actually I didnt intend to choose tliotta's comment, I inadvertently accepted the wrong comment.  I couldnt figure out a way to change it.  Sorry, I certainly didnt intend to offend anyone.  If there is a way that I can correct it I will be more than willing to do so.  Again, I am sorry, and please let me know if I can change it.
Just a quick additional note - if this occurs in the future you can post a 0-point question in the Community Services area of this site (Support link at top of page, or https://www.experts-exchange.com/Community_Support/  ) asking someone to reopen the question or re-assign the points.
Thank you for your help.  I hope this doesnt happen again.  :)