Summary -

In this topic, we described about the EXAMINE Statement with detailed example.

EXAMINE and INSPECT are used for same purpose. Syntax is almost same for both EXAMINE and INSPECT. INSPECT is using now a days that replaces the EXAMINE.

The EXAMINE statement is an HP extension to the ANSI COBOL standard. If any requirement to use EXAMINE in coding prospective, it is advisable to use the INSPECT statement.

Practical Example:

 IDENTIFICATION DIVISION.                                       
 PROGRAM-ID. EXAM.                                              
 ENVIRONMENT DIVISION.                                           
 DATA DIVISION.                                                  
 WORKING-STORAGE SECTION.                                        
 01 WS-DATA		PIC X(10) VALUE ‘DD-MM-YYYY’.          
 01 WS-CNT 	 	PIC 9(02) VALUE ZEROES.                
 PROCEDURE DIVISION.                                             
     DISPLAY 'EXAMINE TALLYING REPLACING....'.                   
     EXAMINE WS-DATA TALLYING WS-CNT ALL ‘-’                     
     REPLACING ALL ‘-‘ BY ‘/’.                                   
     DISPLAY 'COUNT OF - LETTER IS : 'WS-CNT.                   
     STOP RUN.