IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

To compare an input file with a master file


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
lekshmi133

New User


Joined: 14 Apr 2020
Posts: 2
Location: India

PostPosted: Tue Apr 14, 2020 3:01 pm
Reply with quote

Hi All,

Can anyone help me in this.
Requirement: To compare an input file to a master file and write the unmatched records from the input file to an output file and the matched records to the next separate page.

I tried writing the program. But I'm getting the unmatched records from both the files.
I have pasted a part of my program here. Kindly check and guide me on what I have done wrong

Code:
        PROCEDURE DIVISION.                                     
       *------------------*                                     
        A000-MAIN.                                             
       *----------*                                             
            DISPLAY 'ENTERING DATE PARA'.                       
            PERFORM DATE-PROCESS        THRU DATE-EXIT.         
            DISPLAY 'ENTERING HEAD PARA'.                       
            PERFORM HEAD-PARA           THRU HEAD-EXIT.         
            DISPLAY 'ENTERING RAW FILE OPEN PARA'.             
            PERFORM OPEN-RAW            THRU OPEN-EXIT.         
       *    DISPLAY 'ENTERING READ  PARA'.                     
       *    PERFORM READ-RAWFILE       THRU READ-EXIT.         
       *    DISPLAY 'EXITED READ  PARA'.                       
            CLOSE RFILE.                                       
            CLOSE MFILE.                                       
            CLOSE RAWFILE.                                     
            PERFORM EXIT-PARA.                                 
        A000-EXIT.                                               
       *----------*                                             
            EXIT.                                               
        DATE-PROCESS.                                           
       *-------------*                                           
            MOVE FUNCTION CURRENT-DATE  TO WS-CDATE.             
            DISPLAY 'DATE               : ' WS-DATE.             
            DISPLAY 'TIME               : ' WS-TIME.             
            MOVE WS-DAY TO WS-MDAY                               
            MOVE WS-MON TO WS-MMON                               
            MOVE WS-YEAR TO WS-MYEAR                             
            DISPLAY 'MODIFIED DATE               : ' WS-MDATE.   
        DATE-EXIT.                                               
       *----------*                                             
            EXIT.                                               
                                                                 
        OPEN-RAW.                                               
            SET NOT-END-OF-RAW-FILE TO TRUE                 
            OPEN INPUT RAWFILE                               
            OPEN INPUT MFILE                                 
       *         OUTPUT RFILE                               
            IF WS-RAW-STAT-OK                               
               PERFORM READ-RAWFILE UNTIL WS-END-OF-RFILE   
            ELSE                                             
               DISPLAY 'RAW FILE OPEN STSTUS :' WS-RSTS     
               CLOSE RAWFILE                                 
               PERFORM EXIT-PARA                             
            END-IF.                                         
                                                             
        OPEN-EXIT.                                           
       *----------*                                         
            EXIT.                                           
                                                             
        READ-RAWFILE.                                       
                                                             
            READ RAWFILE                                     
             AT END                                           
              SET END-OF-RAW-FILE TO TRUE                     
             NOT AT END                                       
              MOVE FS-EMPID TO WS-EMPID                       
              SET NOT-END-OF-MASTER-FILE TO TRUE             
       *      OPEN INPUT MFILE.                               
              IF WS-MASTER-STAT-OK                           
                 PERFORM PROCESS-PARA                         
              ELSE                                           
                 DISPLAY 'ERROR OPENING MASTER FILE' WS-MSTS 
                 CLOSE MFILE                                 
                 PERFORM EXIT-PARA                           
              END-IF.                                         
                                                             
        READ-EXIT.                                           
            EXIT.                                           
                                                             
        PROCESS-PARA.                                       
       *    OPEN INPUT MFILE.                               
       *     IF WS-MASTER-STAT-OK                           
            READ MFILE                                       
             AT END                                         
              SET END-OF-MASTER-FILE TO TRUE                 
       *      CONTINUE                                       
             NOT AT END                                     
               IF WS-EMPID = FS-MEMPID                       
       *        MOVE FS-NAME     TO FS-RNAME                 
       *          MOVE WS-EMPID    TO FS-REMPID             
                  MOVE FS-SKILL    TO WS-SKILL               
                  DISPLAY WS-EMPID                           
                  DISPLAY FS-SKILL                           
               ELSE                                         
                  ADD 1 TO WS-SRNO                           
                  IF WS-SRNO = 1                                 
                     PERFORM OTHER-PARA THRU OTHER-EXIT         
                     MOVE FS-NAME     TO WS-ENAME               
       *             MOVE WS-EMPID    TO FS-REMPID               
                     MOVE FS-SKILL    TO WS-SKILL               
                     MOVE FS-MDSGN    TO WS-DSGN                 
                     WRITE REPORT-REC FROM WS-REPORT-REC AFTER 1
                  ELSE                                           
                     MOVE FS-NAME     TO WS-ENAME               
       *             MOVE WS-EMPID    TO FS-REMPID               
                     MOVE FS-SKILL    TO WS-SKILL               
                     MOVE FS-MDSGN    TO WS-DSGN                 
                     WRITE REPORT-REC FROM WS-REPORT-REC AFTER 1
                  END-IF                                         
               END-IF                                           
               DISPLAY 'END IF'                                 
            END-READ.                                           
            DISPLAY 'MFILE END READ'.                           
                                                           
        OTHER-PARA.                                         
            MOVE 'OTHER'     TO WS-UNIT.                   
            WRITE REPORT-REC FROM WS-BLANK-LINE AFTER 1.   
            WRITE REPORT-REC FROM WS-BLANK-LINE AFTER 1.   
            WRITE REPORT-REC FROM REPORT-LINE-4 AFTER 1.   
            WRITE REPORT-REC FROM REPORT-LINE-5 AFTER 1.   
            WRITE REPORT-REC FROM REPORT-LINE-6 AFTER 1.   
            WRITE REPORT-REC FROM REPORT-LINE-7 AFTER 1.   
            WRITE REPORT-REC FROM REPORT-LINE-8 AFTER 1.   
                                                           
        OTHER-EXIT.                                         
            EXIT.                                           
                                                           
        HEAD-PARA.                                         
            OPEN OUTPUT RFILE                               
            IF STS-SUCCESSFUL                               
               WRITE REPORT-REC FROM REPORT-LINE-1 AFTER 1 
            ELSE                                                         
               DISPLAY 'STATUS OF OPENING  OUTPUT FILE :' STS-STATUS     
               CLOSE RFILE                                               
               PERFORM EXIT-PARA                                         
            END-IF.                                                     
       HEAD-EXIT.     
           EXIT.       
       EXIT-PARA.     
           STOP RUN.


Coded for you - please do it yourself in future
Back to top
View user's profile Send private message
prino

Senior Member


Joined: 07 Feb 2009
Posts: 1306
Location: Vilnius, Lithuania

PostPosted: Tue Apr 14, 2020 3:06 pm
Reply with quote

Are you stupid? Or just pretending?

This is a forum for experts, and as an expert you would have read the stickies at the top of this forum!

'nuff said!
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Apr 14, 2020 3:53 pm
Reply with quote

I would also suggest that you join the beginner's forum whilst learning:-here
Back to top
View user's profile Send private message
lekshmi133

New User


Joined: 14 Apr 2020
Posts: 2
Location: India

PostPosted: Tue Apr 14, 2020 5:51 pm
Reply with quote

Sorry all.. I'm a beginner.. I dont knw where to post n how.. I'm a new user and have joined today only... Kindly guide me where to post n how
Back to top
View user's profile Send private message
sergeyken

Senior Member


Joined: 29 Apr 2008
Posts: 2010
Location: USA

PostPosted: Tue Apr 14, 2020 6:33 pm
Reply with quote

http://www.ibmmainframeforum.com/
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 2455
Location: Hampshire, UK

PostPosted: Tue Apr 14, 2020 7:01 pm
Reply with quote

There is a post, almost at the top of the COBOL forum, showing how to match two datasets which is what you are doing. Study it and work out how you would have to adjust it for your particular requirement.

Use DISPLAYs to show values at critical points.

When posting, use the code tags to present code and data. You should use the POST REPLY button to bring up the reply editor and you will see the buttons along the top of the text entry area. This also applies in the beginners forum which is where you should be. The link has been posted twice now.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
No new posts Access to non cataloged VSAM file JCL & VSAM 18
No new posts Compare only first records of the fil... SYNCSORT 7
No new posts Need help for File Aid JCL to extract... Compuware & Other Tools 23
Search our Forums:

Back to Top