MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

File Comparisions..Help !!!

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
bharat
Beginner


Joined: 22 Mar 2005
Posts: 1
Topics: 1

PostPosted: Wed Mar 23, 2005 12:00 am    Post subject: File Comparisions..Help !!! Reply with quote

Hi !
i want to develop the logic of the program where I have 2 i/p files and 2 o/p files.
Now the 1st I/P file say Ifile1 has 3 fields - group, amount, check#(spaces initially)
Another I/P file say Ifile2 also has same structure with same 3 fields - group, amount, check#
Both Output files Ofile1 and Ofile2 also has same structure and are empty initially.

The program should match the amounts for a group in file1 to file2 and pick the draft number for that amount n that group and write it in the O/p file say Ofile1.
In Ofile1 job should write the Ifile1's record occurence/details and the check# for that, which it picked from Ifile2.

There may be a record occurence(group+amount) in Ifile1 for which there is no match in Ifile2. For such records also, write the Ofile1 but with empty check#.
There may be a record occurence(group+amount) in Ifile2 for which there is no match in Ifile1, write such records in the Ofile2

The problem is the amounts coming in the files.
There can be a single occurence in Ifile2 for 2 occurences of Ifile1 i.e.
Ifile1
Group Amount Check
1 1 0
1 3 0
1 4 0
1 10 0

Ifile2
Group Amount Check
1 5 111 (This 5 is a sum of 1 and 4 in Ifle1)
1 10 111
1 15 111

In this case the match should be 100%. The 2 O/P files should be like this :
Ofile1
Group Amount Check
1 1 111
1 4 111
1 3 0
1 10 0

and Ofile2 will be :
1 15 111

Also Consider :
The amounts may be -ve in both files.
There can be multiple amounts for a single group.
The amounts in Ifie1 for which there is a sum amount in ifile2, may come 1 after the other or
may have many amounts in between them for that group.

Assumptions :
The files are sorted in order of Group and then Amount, both in Ascending order.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Wed Mar 23, 2005 4:58 am    Post subject: Reply with quote

bharat,


Please search before posting. Check these topics.

http://www.mvsforums.com/helpboards/viewtopic.php?t=11&highlight=match

http://www.mvsforums.com/helpboards/viewtopic.php?t=166&highlight=match

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chandra_vssv
Beginner


Joined: 08 May 2005
Posts: 26
Topics: 12
Location: pune

PostPosted: Sun May 08, 2005 2:45 am    Post subject: Reply with quote

hi

i have two input files , both the input files contains acct no's and the corresponding details of acct no's.
those two files are sequential files, files can contain duplicate acct numbers

compare two files acct number 's, if acct no matches compare the details of acct numbres , if any mis match in the corresponding details of that matching acct number, write that account number in to o/p file.
.If there are any mis matching account numbers also should be sent to o/p file.
can anybody provide me the code in cobol or is there any other alternative where we can compare using jcl.
_________________
Regards,
Chandu
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon May 09, 2005 10:10 am    Post subject: Reply with quote

chandra_vssv,


Please go thru the links provided by me. The first link shows different methods to compare the files. Go thru them and try to understand the logic and you will be on a path to become a good programmer.

Thanks

Kolusu

Ps: Stop posting in CAPS. Posting in all caps is like shouting.
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chandra_vssv
Beginner


Joined: 08 May 2005
Posts: 26
Topics: 12
Location: pune

PostPosted: Mon May 09, 2005 10:36 am    Post subject: Reply with quote

HI KOLUSU,
COULD YOU PLEASE TELL ME WHETHER THIS CODE WORKS FOR SEQUENTIAL VALIDATION. HERE I'M COMPARING TWO FILES WHICH HAS ACCOUNT NUMBERS AND THE CORRESPONDING DETAILS OF THAT ACCOUNT NUMBER.THE PROGRAM HAS TO COMPARE ACCOUNT NUMBERS FIRST , IF IT MATCHES THEN COMPLETE RECORD HAS TO VALIDTAE IF ANY DISCRPENCIES IN THE RECORD THEN IT HAS TO WRITE INTO O/P FILE.IF THERE ARE ANY A/C NUMBERS WHICH ARE NOT IN BOTH THE FILES ALSO SHOULD WRITE INTO O/P FILE.
ONE MORE THING I NEED TO VERIFY 9 MORE PAIRS LIKE THIS WHICH ARE OF DIFFERENT LERECL , SO I NEED TO WRITE NINE PROGRAMS OR IS THERE ANY OTHER ALTERNATIVE. COULD YOU PLEASE SUGGEST ME . O/P FILE WILL BE OF FB AND LRECL IS 80 , IT SHOUL CONTAIN ONLY A/C NO AND HEADER AND HEADER POSITION IS NON STANDARD, HOW TO OVERCOME THESE, I DONT HAVE COPY BOOKS ALSO.
Code:

       IDENTIFICATION DIVISION.
       PROGRAM-ID.EXTCOMP.
     
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
      *
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.

           SELECT P1-C41-DAT1          ASSIGN   TO FILE1
                  ORGANIZATION         IS SEQUENTIAL                   
                  ACCESS               IS SEQUENTIAL                   
                  FILE STATUS IS WS-FILE1-STATUS.

           SELECT P2-C41-DAT1         ASSIGN   TO FILE2
                  ORGANIZATION         IS SEQUENTIAL                   
                  ACCESS               IS SEQUENTIAL                   
                  FILE STATUS IS WS-FILE2-STATUS.

           SELECT MIS-FILE         ASSIGN   TO OUTFILE
                  FILE STATUS IS WS-OUTPUTFILE-STATUS.
     

       DATA DIVISION.
       FILE SECTION.

       FD  P1-C41-DAT1
           LABEL RECORDS ARE STANDARD
           BLOCK CONTAINS 0 RECORDS
           RECORDING MODE IS V.
           
      01 FILE1-REC.
       02 P1-ACCTNO PIC X(13).
       02 FILLER PIC X(8192).


       FD  P2-C41-DAT1
           LABEL RECORDS ARE STANDARD
           BLOCK CONTAINS 0 RECORDS
           RECORDING MODE IS V.

      01 FILE2-REC.
       02 P2-ACCTNO PIC X(13).
       02 FILLER PIC X(8192).
           
       FD  MIS-FILE
           LABEL RECORDS ARE STANDARD
           BLOCK CONTAINS 0 RECORDS
           RECORDING MODE IS F.

      01 OUT-REC.
       02 ACCTNO PIC X(13).
       02 FILLER PIC X VALUE SPACES.
       02 HEADER PIC X(8) VALUE "HEADER".
       02 FILLER PIC X(58) VALUE SPACES.            

   
      ******************************************************************
      * WORKING STORAGE SECTION BEGINS HERE.                           *
      ******************************************************************
       WORKING-STORAGE SECTION.
      *------------------------
       01   START-WS                    PIC X(50)   VALUE
                     'MECHANISE VALIDATION WORKING-STORAGE BEGINS HERE '.

       01  WORK-AREA.
           05  WS-FILE-STATUS.
               10  WS-FILE1-STATUS            PIC X(02).
                   88 WS-FILE1-STATUS-OK                VALUE '00' '04'.
               10  WS-FILE2-STATUS            PIC X(02).
                   88 WS-FILE2-STATUS-OK                VALUE '00' '04'.
               10  WS-OUTFILE-STATUS          PIC X(02).
                   88 WS-OUTPUTFILE-STATUS-OK           VALUE '00'.

           05  WS-COUNTERS.
               10  WS-FILE1-CTR         PIC 9(09)   VALUE ZEROS.
               10  WS-FILE2-CTR         PIC 9(09)   VALUE ZEROS.
               10  WS-DISPLAY-CTR       PIC 9(09)   VALUE ZEROS.
               10  WS-MATCH-CTR         PIC 9(09)   VALUE ZEROS.
               10  WS-OUTPUT-CTR        PIC 9(09)   VALUE ZEROS.
           
      05  WS-SWITCHES.
               10  WS-EOF-FILE1-FLAG      PIC X(01).
                   88  NOT-EOF-FILE1                VALUE 'N'.
                   88  EOF-FILE1                    VALUE 'Y'.
               10  WS-EOF-FILE2-FLAG      PIC X(01).
                   88  NOT-EOF-FILE2                VALUE 'N'.
                   88  EOF-FILE2                    VALUE 'Y'.
               10  WS-EOF-OUTPUTFILE-FLAG PIC X(01).
                   88  NOT-EOF-OUTPUTFILE           VALUE 'N'.
                   88  EOF-OUTPUTFILE               VALUE 'Y'.
   
      


      ******************************************************************
      * WORKING STORAGE SECTION ENDS HERE.                             *
      ******************************************************************
      *
       01  END-WS                      PIC X(50)   VALUE
                     'MECHANISE VALIDATION WORKING-STORAGE ENDS HERE'.
      *
     
       PROCEDURE DIVISION.
      *
      ******************************************************************
      * THIS PARAGRAPH CONTROLS THE PROGRAM'S MAIN PROCESSING.         *
      ******************************************************************
       A1000-MAIN-PARA.
      *---------------
      *
           PERFORM B1000-HOUSEKEEPING-PARA
              THRU B1000-EXIT.

           PERFORM C1000-PROCESS-PARA
              THRU C1000-EXIT UNTIL EOF-FILE2.

           PERFORM D1000-WRAP-UP
              THRU D1000-EXIT.

           DISPLAY '*************************************************'.
           DISPLAY '          VALIDATION END OF JOB'.
           DISPLAY '*************************************************'.
      *
       A1000-EXIT.
      *-----------
           STOP-RUN.
      *
      ******************************************************************
      * THIS PARAGRAPH INITIALIZES THE WORKING STORAGE VARIABLES AND
      * ALL THE FILES ARE OPENED AND THEIR STATUS VERIFIED.
      ******************************************************************
       B1000-HOUSEKEEPING-PARA.
      *-----------------------

           MOVE 'N' TO WS-EOF-FILE1-FLAG
                       WS-EOF-FILE2-FLAG.
      *
           OPEN INPUT P1-C41-DAT1.
           IF WS-FILE1-STATUS = '00'
              CONTINUE
           ELSE
              display 'file status' WS-FILE1-STATUS
              display 'Error in OPENING FILE1'
           END-IF.
      *
           OPEN INPUT P2-C41-DAT1.
           IF WS-FILE2-STATUS = '00'
              CONTINUE
           ELSE
              display 'file status' WS-FILE2-STATUS
              display 'Error in OPENING FILE2'
           END-IF.
      *
           OPEN OUTPUT MIS-FILE.
           IF WS-OUTPUTFILE-STATUS = '00'
              CONTINUE
           ELSE
             display 'file status' WS-OUTPUTFILE-STATUS
             display 'Error in OPENING output FILEs'
           END-IF.
      *
           DISPLAY '*********************************************'
           DISPLAY '* PROGRAM: COBOLTS START                  '.
           DISPLAY ' '.
           PERFORM R1000-READ-BOTHFILE
              THRU R1000-EXIT.
      *
       B1000-EXIT.
      *-----------
             EXIT.
      *
       C1000-PROCESS-PARA.
      *-------------------
             EVALUATE TRUE
      *
                WHEN P1-ACCT-NO = P2-ACCT-NO
         PERFORM P5000-PROCESS-COMPARE-FILE
         THRU R1000-EXIT
                    PERFORM R1000-READ-BOTHFILE
                       THRU R1000-EXIT
                     
      *
      * ACCOUNT NUMBER ONLY PRESENT IN FILE1
      *
                WHEN P1-ACCT-NO < P2-ACCT-NO
          MOVE P1-ACTNO TO ACCTNO   
          PERFORM W5000-WRITE-OUTPUT-FILE
                         THRU W5000-EXIT      
                    PERFORM R1010-READ-FILE1
                      THRU R1010-EXIT
      *
      * ACCOUNT NUMBER ONLY PRESENT IN FILE2
      *
                WHEN P1-ACCT-NO > P2-ACCT-NO
      MOVE P2-ACTNO TO ACCTNO
                      PERFORM W5000-WRITE-OUTPUT-FILE
                         THRU W5000-EXIT
                      PERFORM R1020-READ-FILE2
                      THRU R1020-EXIT
                END-EVALUATE.
      *
       C1000-EXIT.
      *-----------
             EXIT.
      *
   P5000-PROCESS-COMPARE-FILE.
      *
      *---------------------------------------------------------------------
      * THIS IS TO PERFORM BYTE BY BYTE COMPARISON OF TWO RECORDS
      *---------------------------------------------------------------------
            IF FILE1-REC = FILE2-REC
      CONTINUE.
      
      ELSE
      
      MOVE P1-ACCTNO TO ACCTNO.
      PERFORM W5000-WRITE-OUTPUT-FILE
                    THRU W5000-EXIT.
      END-IF.
   P5000-EXIT.                                                         
           EXIT.


      *
       W5000-WRITE-OUTPUT-FILE.
      *
      *-----------------------------------------------------------------
      * THIS MOVE MATER EXTRACT RECORD  TO OUTPUT RECORD               *
      *-----------------------------------------------------------------
                                                 
      *                                                                 
     WRITE OUT-REC                                          
*                                                                 
     IF WS-OUTPUTFILE-STATUS-OK                                   
        ADD 1                    TO WS-OUTPUT-CTR                 
     ELSE                                                         
       display ' file status ' WS-OUTPUTFILE-STATUS             
        display 'error IN WRITING output FILE'                   
     END-IF.                                                     
      *
       W5000-EXIT.                                                     
           EXIT.                                                       
      *
      *
      *
      ******************************************************************
      * DISPLAY ALL PROGRAM COUNTERS AND CLOSE THE FILES               *
      ******************************************************************
       D1000-WRAP-UP.
      *--------------
           DISPLAY '================================================='.
           DISPLAY '#       P R O G R A M    C O U N T E R S        #'.
           DISPLAY '================================================='.
           DISPLAY ' # OF FILE1 RECORD          : ' WS-FILE1-CTR.
           DISPLAY ' # OF OUTPUT RECORD         : ' WS-OUTPUT-CTR.
           DISPLAY '================================================='.

           CLOSE FILE2-FILE.
           IF WS-FILE2-STATUS = '00'
              CONTINUE
           ELSE
              display ' file status ' WS-FILE2-STATUS           
              display 'error IN closing file2'                   
           END-IF.

           CLOSE FILE1-FILE.
           IF WS-FILE1-STATUS = '00'
              CONTINUE
           ELSE
              display ' file status ' WS-FILE1-STATUS           
              display 'error IN closing file1'                   
           END-IF.

           CLOSE OUTPUT-FILE.
           IF WS-OUTPUTFILE-STATUS = '00'
              CONTINUE
           ELSE
              display ' file status ' WS-OUTPUTFILE-STATUS           
              display 'error IN closing output file2'                   
           END-IF.

       D1000-EXIT.
      *-----------
           EXIT.
      *
      ************************************************************
      * READ BOTH THE INPUT   FILES
      ************************************************************
       R1000-READ-BOTHFILE.
      *--------------------
           IF NOT-EOF-FILE1
              PERFORM R1010-READ-FILE1
                 THRU R1010-EXIT
           END-IF.

           IF NOT-EOF-FILE2
              PERFORM R1020-READ-FILE2
                 THRU R1020-EXIT
           END-IF.

       R1000-EXIT.
      *-----------
           EXIT.
      *
      ************************************************************
      *THIS READS THE FILE2 FILE
      ************************************************************
       R1010-READ-FILE1.
      *--------------------
           READ FILE1-FILE
             AT END
                SET  EOF-FILE1         TO TRUE
                MOVE 9999999999999 TO P1-ACCTNO
             NOT AT END
                ADD 1                  TO WS-FILE1-CTR
           END-READ.
           IF WS-FILE1-STATUS-OK OR EOF-FILE1
              CONTINUE
           ELSE
              display ' file status ' WS-FILE1-STATUS           
              display 'error IN reading file1'                   
           END-IF.
       R1010-EXIT.
      *-----------
           EXIT.
      *
      *************************************************************
      *THIS PARA READS THE MASTER   EXTRACT FILE
      *************************************************************
       R1020-READ-FILE2.
      *--------------------
           READ FILE2-FILE
             AT END
                SET  EOF-FILE2           TO TRUE
                MOVE 9999999999999  TO P2-ACCTNO
             NOT AT END
                ADD 1                  TO WS-FILE2-CTR
           END-READ.

           IF WS-FILE2-STATUS-OK
              OR EOF-FILE2
              CONTINUE
           ELSE
              display ' file status ' WS-FILE2-STATUS           
              display 'error IN reading file2'                   
           END-IF.
       R1020-EXIT.
      *-----------
           EXIT.
      *
         

     
      ****************************************************************
      *          //PROCEDURE DIVISION ENDS HERE//                    *
      ****************************************************************

_________________
Regards,
Chandu
Back to top
View user's profile Send private message Yahoo Messenger
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12378
Topics: 75
Location: San Jose

PostPosted: Mon May 09, 2005 10:45 am    Post subject: Reply with quote

chandra_vssv,

Can't you just follow simple instructions? Is that hard to follow ?
Quote:

Ps: Stop posting in CAPS. Posting in all caps is like shouting.


Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chandra_vssv
Beginner


Joined: 08 May 2005
Posts: 26
Topics: 12
Location: pune

PostPosted: Tue May 10, 2005 7:03 am    Post subject: Reply with quote

Hi Kolusu,

Sorry for that.I need your help.can i use compare batch jcl file-aid for comparing two files and giving o/p in our specified format.
_________________
Regards,
Chandu
Back to top
View user's profile Send private message Yahoo Messenger
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group