Rahul
Rahul

Reputation: 119

Getting flow of control in program go beyond last line in Cobol

With this COBOL code:

  IDENTIFICATION DIVISION.                              
    PROGRAM-ID. DBNULLA.                                  
    DATA DIVISION.                                        
      WORKING-STORAGE SECTION.                            
        EXEC SQL                                          
          INCLUDE SQLCA                                   
        END-EXEC.                                         
        EXEC SQL                                          
          INCLUDE PATIENT                                 
        END-EXEC.                                         
    PROCEDURE DIVISION.                                   
    MAIN-PARA.                                            
         DISPLAY 'SAMPLE STRUCTURE OF COBOL DB2 PRORGRAM'.
         DISPLAY 'WE ARE CHECKING NULL HERE             '.
         MOVE 100 TO PAT-ID.                              
          EXEC SQL       
           SELECT PAT_ID,PAT_NAME,WARD_NAME INTO :PAT-ID,:PAT-NAME,
           :WARD-NAME FROM PATIENT WHERE PAT_ID = :PAT-ID          
          END-EXEC.                                                
         IF SQLCODE = 0                                            
          DISPLAY 'HI'                                             
         ELSE                                                      
          DISPLAY 'EMBEDDED SQL SQLCODE:' SQLCODE                  
         END-IF.                                                   
    STOP-RUN.    
   

I get the following output when executing it:

SAMPLE STRUCTURE OF COBOL DB2 PRORGRAM                                          
WE ARE CHECKING NULL HERE                                                       
HI                                                                              
IGZ0037S The flow of control in program DBNULLA proceeded beyond the last line of the program.
         From compile unit DBNULLA at entry point DBNULLA at compile unit offset  +000006E4 at entry offset +000006E4
         at address 1E5016E4.    

I don't understand why flow of control goes beyond last line. I have already added STOP RUN. Please help to resolve this.

Upvotes: 0

Views: 452

Answers (1)

cschneid
cschneid

Reputation: 10775

You have incorrectly coded STOP-RUN. Instead code a STOP RUN statement.

Upvotes: 5

Related Questions