Q:

Deleting/Omitting multiple records using Easytrieve/Cobol

Lets us suppose I have a file A having below data:  
A1.01  
A2.02  
A4.03   
A6.01

And a file B having following data:  
A2.02 xyshahaslsl  
A2.02 dkjhsldhsds  
A2.02 ewewhrewjws  
A4.03 wejwejwrewl  
A4.03 wejedededee  
A5.01 kdkgskhdgss  
A5.02 fljsdfjdfjd  
A5.03 sdjdhsdhsld  
A7.04 jhsdhskdhsd  
A7.07 dsjdhslkhds  

Its is required to delete the records present in the file A from file B, if it matches the first two letters data of records of second file.
Therefore output should look like:  
A5.01 kdkgskhdgss  
A5.02 fljsdfjdfjd  
A5.03 sdjdhsdhsld  
A7.04 jhsdhskdhsd  
A7.07 dsjdhslkhds 

I have file A having 400 records and file B having half million records. I ran a COBOL program but it ran for too long.
The cobol program logic is as follows:
Here I have taken the half million records contating file as A.
And the file containing 400 records as file B.  
WORKING-STORAGE SECTION.                         
01 WS-RECORDS-WRITTEN    PIC 9(8) VALUE ZEROES.  
01 WS-RECORDS-DELETED    PIC 9(8) VALUE ZEROES.  
01 WS-INSERT-FILE-STATUS PIC X(2).               
01 WS-EOFA PIC A(1) VALUE 'N'.                   
01 WS-EOFB PIC A(1) VALUE 'N'.                   
01 WS-FLAG-FOUND PIC A(1) VALUE 'N'. 

PROCEDURE DIVISION.                                    
MAIN-PARA.                                             
     OPEN INPUT IFILEA                                 
     OPEN OUTPUT OFILE                                 
     PERFORM PARA0 THRU PARA0-EXIT UNTIL WS-EOFA = "Y" 
     CLOSE IFILEA                                      
     CLOSE OFILE                                       
     STOP RUN.                                         
     EXIT.                                             
PARA0.                                                 
     READ IFILEA                                       
     AT END MOVE "Y" TO WS-EOFA                        
     END-READ                                          
     IF WS-EOFA = "N"                                  
        OPEN INPUT IFILEB                              
       MOVE "N" TO WS-EOFB                             
       MOVE "N" TO WS-FLAG-FOUND                       
         PERFORM PARA1 THRU PARA1-EXIT UNTIL WS-EOFB = "Y"  
             OR WS-FLAG-FOUND = "Y"                         
         IF WS-FLAG-FOUND = "N"                             
            WRITE F2RECORD FROM F0RECORD                    
         END-IF                                             
        CLOSE IFILEB                                        
      END-IF.                                               
 PARA0-EXIT.                                                
      EXIT.                                                 
 PARA1.                                                     
      READ IFILEB                                           
      AT END MOVE "Y" TO WS-EOFB                            
      END-READ                                              
      IF OSS024S-TRACKING-ID = OSS024V-REC                  
* SKIP THE RECORD                                           
        MOVE "Y" TO WS-FLAG-FOUND                           
      END-IF.                                               
 PARA1-EXIT.                                                
      EXIT.   

A:

[Sample File-control, file section and required working-storage added for clarity.
Follow the bouncing ball for the other files involved. Filenames referenced are for my testing. sample only for brevity's sake]
FILE-CONTROL.
    SELECT FILE-A ASSIGN TO "Q30309414.EXC"
            ORGANIZATION IS LINE SEQUENTIAL
        FILE STATUS  IS FILE-A-STATUS.

FILE SECTION.
FD  FILE-A.        
01  FILE-A-REC.
    05 FILE-A-FIELD    PIC X(02).
    05 FILLER          PIC X(18).

WORKING-STORAGE SECTION.
01  FILE-A-STATUS            PIC X(02).
    88 EOF-A                 VALUE '10'.

MAINLINE.
    OPEN INPUT FILE-A.
    OPEN INPUT FILE-B.
    OPEN OUTPUT FILE-O.
    MOVE LOW-VALUES          TO FILE-A-REC.
    PERFORM READ-AND-FILTER 
      UNTIL EOF-B.
    CLOSE FILE-A.
    CLOSE FILE-B.
    CLOSE FILE-O.
    STOP RUN.

READ-AND-FILTER.
    READ FILE-B AT END MOVE HIGH-VALUES TO FILE-B-REC.
    PERFORM READ-NEXT-FILTER
       UNTIL FILE-B-FIELD IS NOT GREATER THAN FILE-A-FIELD.
    IF FILE-B-FIELD IS LESS THAN FILE-A-FIELD
      WRITE FILE-O-REC FROM FILE-B-REC.

READ-NEXT-FILTER.
    IF FILE-B-FIELD IS GREATER THAN FILE-A-FIELD
      READ FILE-A
        AT END MOVE HIGH-VALUES TO FILE-A-REC.

No need for any flags, just file-statuses. Certainly no need for evil perform-throughs which create layout-dependent code.
This assumes your data is sorted as you have indicated. If it isn't then the approach would be different - read the exclusions file field in question (the two characters) into a working-storage table, sort and search the table for a match against each main file record read.

