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 match logic help

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


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Dec 26, 2002 10:29 am    Post subject: File match logic help Reply with quote

Here I am giving my code can find out it will work fine or not.
Actually I have to compare two files
1) having 67000 recs
2)2037 recs
3)i have to compare based on two fields in each record .

but one field is same in the both records and seocnd feild is 9(1) in one file and other record it is havinf occurs 5 times
Code:

           MOVE LOW-VALUES TO NDDIPROC-PROCEDURE-ODE                 
                               THCPC-COMMON-PROCE-SYS-CODE             
         READ INPUT-FILE AT END MOVE HIGH-VALUES                     
                           TO NDDIPROC-PROCEDURE-CODE.                 
          READ INPUT-FILE1 AT END MOVE HIGH-VALUES                     
                           TO THCPC-COMMON-PROCE-SYS-CODE.             
            PERFORM COMPARE-FILES THRU 900-EXIT UNTIL                 
              NDDIPROC-PROCEDURE-CODE     EQUAL HIGH-VALUES aND       
              THCPC-COMMON-PROCE-SYS-CODE EQUAL HIGH-VALUES.           
      COMPARE-FILES SECTION.                                           
            IF NDDIPROC-PROCEDURE-CODE LESS THCPC-COMMON-PROCE-SYS-CODE 
             READ INPUT-FILE AT END MOVE HIGH-VALUES                          TO NDDIPROC-PROCEDURE-CODE                 
         END-IF                                                       
            IF NDDIPROC-PROCEDURE-CODE GREATER THCPC-COMMON-pROCE-SYS-CODE     
            READ INPUT-FILE1 AT END MOVE HIGH-VALUES                   
                            TO THCPC-COMMON-PROCE-SYS-CODE             
           END-IF                                                     
            IF NDDIPROC-PROCEDURE-CODE EQUAL THCPC-COMMON-PROCE-SYS-CODE
             PERFORM UNTIL (NDDIPROC-PROCEDURE-CODE NOT EQUAL           
                          THCPC-COMMON-PROCE-SYS-CODE)                 
                   MOVE +1 TO I                                       
                PERFORM VARYING I FROM +1 BY +1 UNTIL I > +5           
                 IF NDDIPROC-TY-SVCD EQUAL HCPCS-TYPE-SERVICE-CODE1(I)
                PERFORM COMPLETE-MATCH-STUFF THRU C900-EXIT           
               END-IF                                               
                  END-PERFORM                       
             END-PERFORM                                             
           END-IF.                                                     
        900-EXIT.  EXIT.                                                   
  A200-999-EXIT.  EXIT.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Dec 26, 2002 12:20 pm    Post subject: Reply with quote

Vallabhneni,

The following program will give you the desired results.I have assumed that your both input files are 80 bytes in length and key1 starts in position 1 for 3 bytes in both the files.

The second is 1 byte numeric which starts in position 10 in file1 and in file2 it is an occurance of 5 starting at position 10.

Code:

 IDENTIFICATION DIVISION.                         
 PROGRAM-ID.    VALLABH                           
 DATE-COMPILED.                                   
 ENVIRONMENT DIVISION.                             
 CONFIGURATION SECTION.                           
 INPUT-OUTPUT SECTION.                             
 FILE-CONTROL.                                     
                                                   
       SELECT   IN1-FILE                           
       ASSIGN   TO IN1                             
       ORGANIZATION IS SEQUENTIAL.                 
                                                   
       SELECT   IN2-FILE                           
       ASSIGN   TO IN2                             
       ORGANIZATION IS SEQUENTIAL.                 
                                                   
       SELECT   MATCH-FILE                         
       ASSIGN   TO MATCH                           
       ORGANIZATION IS SEQUENTIAL.                 
                                                   
 DATA DIVISION.                                   
 FILE SECTION.                                     
                                                   
 FD IN1-FILE                                       
     RECORDING MODE IS F                           
     LABEL RECORDS ARE STANDARD                   
     BLOCK CONTAINS 0 RECORDS                     
     DATA RECORD IS IN1-REC.                       
                                                   
 01 IN1-REC.                                       
     05 IN1-KEY                  PIC X(03).       
     05 FILLER                   PIC X(07).       
     05 IN1-SINGLE-VAR           PIC 9(01).       
     05 FILLER                   PIC X(69).       
                                                   
 FD IN2-FILE                                               
     RECORDING MODE IS F                                   
     LABEL RECORDS ARE STANDARD                             
     BLOCK CONTAINS 0 RECORDS                               
     DATA RECORD IS IN2-REC.                               
                                                           
 01 IN2-REC.                                               
     05 IN2-KEY                  PIC X(03).                 
     05 FILLER                   PIC X(07).                 
     05 IN2-OCCUR-VAR            PIC 9(01) OCCURS 5 TIMES. 
     05 FILLER                   PIC X(65).                 
                                                           
 FD MATCH-FILE                                             
     RECORDING MODE IS F                                   
     LABEL RECORDS ARE STANDARD                             
     BLOCK CONTAINS 0 RECORDS                               
     DATA RECORD IS MATCH-REC.                             
                                                           
 01 MATCH-REC                   PIC X(80).                 
                                                           
 WORKING-STORAGE SECTION.                                   
 01 S-IN1-FILE                  PIC X(01)  VALUE 'N'.       
 01 S-IN2-FILE                  PIC X(01)  VALUE 'N'.       
 01 W-SUB                       PIC 9(01)  VALUE 0.         
                                                           
 PROCEDURE DIVISION.                                       
                                                           
       PERFORM 1000-INITIALIZATION                         
                                                           
       PERFORM 2000-MAIN-PROCESS UNTIL S-IN1-FILE = 'Y'     
                                                           
       PERFORM 3000-WRAPUP                                 
                                                           
       GOBACK                                               
       .                                                   
                                                           
 1000-INITIALIZATION.                                         
************************************************************* 
* THIS PARAGRAPH OPENS INPUT AND OUTPUT FILES AND DOES THE  * 
* PRIME READ.                                               * 
************************************************************* 
                                                               
       OPEN INPUT  IN1-FILE                                   
                   IN2-FILE                                   
            OUTPUT MATCH-FILE                                 
                                                               
       PERFORM 2100-READ-IN1-FILE                             
       PERFORM 2200-READ-IN2-FILE                             
       .                                                       
                                                               
 2000-MAIN-PROCESS.                                           
************************************************************* 
*THIS PARAGRAPH PERFORMS THE MAIN LOGIC                     * 
************************************************************* 
                                                               
     IF IN1-KEY = IN2-KEY                                     
        PERFORM 2300-MATCH-LOGIC                               
     ELSE                                                     
        PERFORM 2100-READ-IN1-FILE                             
     END-IF                                                   
     .                                                         
                                                               
 2100-READ-IN1-FILE.                                           
************************************************************* 
*THIS PARAGRAPH READS THE IN1-FILE                          * 
************************************************************* 
                                                               
     READ IN1-FILE                                             
         AT END                                               
             MOVE 'Y'            TO S-IN1-FILE                 
             MOVE  HIGH-VALUES   TO IN1-KEY                   
     END-READ                                                 
     .                                                         
                                                               
 2200-READ-IN2-FILE.                                           
************************************************************* 
*THIS PARAGRAPH READS THE IN2-FILE                          * 
************************************************************* 
                                                               
      READ IN2-FILE                                           
          AT END                                               
              MOVE 'Y'            TO S-IN2-FILE               
              MOVE  HIGH-VALUES   TO IN2-KEY                   
      END-READ                                                 
      .                                                       
                                                               
 2300-MATCH-LOGIC.                                             
**************************************************************
* THIS PARAGRAPH PERFORMS THE MATCH LOGIC ON THE SECOND FILED*
**************************************************************
                                                               
      PERFORM UNTIL IN2-KEY > IN1-KEY                         
              PERFORM VARYING W-SUB FROM 1 BY 1 UNTIL W-SUB > 5
                   IF IN1-SINGLE-VAR = IN2-OCCUR-VAR(W-SUB)   
                      PERFORM 2400-WRITE-MATCH-FILE           
                   END-IF                                     
              END-PERFORM                                     
              PERFORM 2200-READ-IN2-FILE                       
      END-PERFORM                                             
      .                                                       
                                                               
 2400-WRITE-MATCH-FILE.                                       
************************************************************* 
* THIS PARAGRAPH WRITES RECORDS WHICH MATCHES ON BOTH FILES.* 
************************************************************* 
                                                               
      MOVE SPACES                 TO MATCH-REC                 
      MOVE IN2-REC                TO MATCH-REC                 
                                                               
      WRITE MATCH-REC                                         
      .                                                       
 3000-WRAPUP.                                                 
*************************************************************
* THIS PARAGRAPH CLOSES THE INPUT & OUTPUT FILES.           *
*************************************************************
                                                             
      CLOSE  IN1-FILE                                         
             IN2-FILE                                         
             MATCH-FILE                                       
      .                                                       


Hope this helps...

cheers

kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Dec 26, 2002 12:51 pm    Post subject: Reply with quote

Thank you Very Much Kolusu.
I will make changes to my code and I will let you know after I get the result.

Thank you.
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Dec 26, 2002 3:27 pm    Post subject: Reply with quote

Hi Kolusu,

Here I have a question for you.
First time it will go to match logic,if it does not match ,it will go to read first file,after that it will go to match logic or not.
Can you clarify for me

Thanks
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Thu Dec 26, 2002 4:19 pm    Post subject: Reply with quote

Vallabhaneni,


look at this statement

Code:

PERFORM 2000-MAIN-PROCESS UNTIL S-IN1-FILE = 'Y'     


So the main process will be executed for every record in the input file until it reaches the end.

You can run the program thru XPEDITER and understand the logical flow of the program.

Hope this helps...

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Thu Dec 26, 2002 4:44 pm    Post subject: Reply with quote

Hi Kolusu,

Thank you for your prompt reply.
Just I ran thru your code,I am getting empty file.
I have to look into my data files.
I hope your code is fine.
Right Now I am going to see it in Trace-master like expeditor.

Thank you
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Fri Dec 27, 2002 4:31 pm    Post subject: Reply with quote

Hi Kolosu,

Here I have One question regarding logic

If I have fileds like 6,7,8,9 in first,secon,third,fourth records of first file
and 1,2,6,7 record of second file .when we go for main logic.

the first reocrds doesn't match ,then as per our logic we will read second record of first file.we are missing record first record of first file.

Can you clirify my doubt.
I made some changes to your code.

Can you help me
Thanks
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Dec 27, 2002 6:22 pm    Post subject: Reply with quote

Vallabhaneni,

yes we will miss the non matched keys. But your requirement is to write keys only when the records match. isn't it???

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Fri Dec 27, 2002 6:56 pm    Post subject: Reply with quote

Hi Kolusu,

yes you are correct but if it not mact first time we are reading the second record of first file if that record after some records in the seond file we ae loosing the first record of first file.
Did you notice this one

can you look into this one

regards
Back to top
View user's profile Send private message Yahoo Messenger MSN Messenger
kolusu
Site Admin
Site Admin


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

PostPosted: Fri Dec 27, 2002 6:59 pm    Post subject: Reply with quote

Vallabhaneni,

Yes I saw that and the only change you would need is in the 1000-INITIALIZATION. paragraph.

change this line

Code:

PERFORM 2200-READ-IN2-FILE   


to

Code:

PERFORM 2200-READ-IN2-FILE   UNTIL  IN2-KEY >= IN1-KEY


Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
vallabhaneni
Beginner


Joined: 26 Dec 2002
Posts: 23
Topics: 7

PostPosted: Sun Dec 29, 2002 10:05 am    Post subject: Reply with quote

Hi Kolusu,

Thanks for your timely helping.
I got the result.

Thank you
Vallabhaneni
Back to top
View user's profile Send private message Yahoo Messenger MSN 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