Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Need pattern matching algorithm

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
anurat

New User


Joined: 19 Sep 2006
Posts: 6

PostPosted: Thu Sep 21, 2006 3:49 pm    Post subject: Need pattern matching algorithm
Reply with quote

Hi!
I have a situation.
There are 2 sequential files with account number as a field in the record. Now we have to check for the matching account numbers in both the files and put it in a output file and the account numbers that are not matching in a second output file.
I want the algorithm for this.

Mind you the number of records are more than a million, normal algorithm would take lot of time.
I want the algorithm which takes the least time.

Thank you

Anuvrat
Back to top
View user's profile Send private message

Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Thu Sep 21, 2006 4:06 pm    Post subject: Re: patter matching algorithm
Reply with quote

Hi

Please find my suggestion.

1. Make both data files indexed on account number. (Organization is indexed).
2. read first file sequentially.
(read first-file next record at end
perfrom close-para.)
3. move acno1 to acno2.
4. read second file write records accordingly.
(ie. Read second-file not invalid key
write output1-rec
invalid key write output2-rec.)

Regards

Aji Cherian
Back to top
View user's profile Send private message
anurat

New User


Joined: 19 Sep 2006
Posts: 6

PostPosted: Thu Sep 21, 2006 4:33 pm    Post subject:
Reply with quote

Hi! Aji


Thanks for the solution!!!!!!

But what about account numbers in the second file which are not there in the first file. This logic does not seem to take care of this criteria.

Thanks
Anuvrat.
Back to top
View user's profile Send private message
Aji

New User


Joined: 03 Feb 2006
Posts: 53
Location: Mumbai

PostPosted: Thu Sep 21, 2006 4:50 pm    Post subject: Re: patter matching algorithm
Reply with quote

Hi

Please see the modified logic.

2. read first file sequentially.
(read first-file next record at end
go to read-file2.

4. read second file write records accordingly.
(ie. Read second-file not invalid key
write output1-rec
delete file2-rec
invalid key write output2-rec.)



read-file2.
read second-file next record at end
perform close-files.
write output2-rec.

Aji Cherian
Back to top
View user's profile Send private message
anurat

New User


Joined: 19 Sep 2006
Posts: 6

PostPosted: Thu Sep 21, 2006 4:55 pm    Post subject:
Reply with quote

thats the problem, we cannot delete the record from the file as it may be reuqired for some other purpose. after that the only solution is to make the local copy and then work on that but that will take so much time and space. Again we have to loop for the whole of the second file.

Thanks again boss.

Anuvrat
Back to top
View user's profile Send private message
muthuvel

Active User


Joined: 29 Nov 2005
Posts: 217
Location: Chennai

PostPosted: Thu Sep 21, 2006 5:47 pm    Post subject: Re: patter matching algorithm
Reply with quote

Hi,
A small bit of Eazytreive will provide you the solution.The only thing is sort the files based on account number and then the sorted files are passed as input to eazytreive and you will get the two desired files.

FILE INFILE1
IBD-OFFC 1 025 A
OFFC 1 008 A
*
FILE INFILE2
IBD-OFFC1 1 025 A
OFFC1 1 008 A
*
FILE OFILE1
OBD-OFFC 1 025 A
OFFCO1 1 008 A
FILE OFILE2
OBD-OFFC1 1 025 A
OFFCO2 1 008 A


*---------- JOB ---------------*

JOB INPUT (INFILE1 KEY INFILE1:OFFC +
INFILE2 KEY INFILE2:OFFC1)

IF MATCHED
MOVE IBD-OFFC TO OBD-OFFC
PUT OFILE1
ELSE
MOVE IBD-OFFC1 TO OBD-OFFC1
PUT OFILE2
END-IF


In this 25 is the record length and 08 is the key length.This proces will continue until the end of both files are reached.

I think this will help you.

Thanks,
Muthuvel.
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Thu Sep 21, 2006 11:13 pm    Post subject: Re: patter matching algorithm
Reply with quote

Anuvrat,

Since this is in a COBOL forum, I'm assuming you want a COBOL solution.

Sort the account files by account number, then do a simple two file compare. This is much faster than creating a vsam file and processing it.

This is the most efficient way, regardless on the number of records.

Here is some pseudo code for a two file match

Code:

INITIALIZATION.

    PERFORM READ-ACCOUNT-FILE-1.
    PERFORM READ-ACCOUNT-FILE-2.


    PERFORM COMPARE THRU COMPARE-EXIT
        UNTIL ACCOUNT-FILE-1-EOF
          AND ACCOUNT-FILE-2-EOF.

    PERFORM END-OF-JOB.
    GOBACK.

COMPARE.
    IF ACCOUNT-KEY-1 = ACCOUNT-KEY-2
    THEN
        PERFORM ACCOUNT-MATCH
        PERFORM READ-ACCOUNT-FILE-1
        PERFORM READ-ACCOUNT-FILE-2
    ELSE
        IF ACCOUNT-KEY-1 < ACCOUNT-KEY-2
        THEN
            PERFORM NO-MATCH-FOR-KEY-1
            PERFORM READ-ACCOUNT-FILE-1
        ELSE
            PERFORM NO-MATCH-FOT-KEY-2
            PERFORM READ-ACCOUNT-FILE-2
        END-IF.
COMPARE-EXIT.
    EXIT.

READ-ACCOUNT-FILE-1.
    READ ACCOUNT-FILE-1
      AT END
        SET ACCOUNT-FILE-1-EOF TO TRUE
        MOVE 999999 TO ACCOUNT-KEY-1
READ-ACCOUNT-FILE-2.
    READ ACCOUNT-FILE-2
      AT END
        SET ACCOUNT-FILE-2-EOF TO TRUE
        MOVE 999999 TO ACCOUNT-KEY-2


Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Sep 23, 2006 8:33 pm    Post subject:
Reply with quote

Deleted by author.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extract set of records matching on ac... bhaskar_kanteti DFSORT/ICETOOL 3 Mon Mar 06, 2017 7:19 am
No new posts Matching and unmatching records scdinesh DFSORT/ICETOOL 11 Tue Feb 07, 2017 12:41 am
No new posts Matching with Key at different postions. rajatbagga DFSORT/ICETOOL 12 Wed Nov 09, 2016 10:58 am
No new posts TSO Logon Failing - Acount Not matching SLNewton TSO/ISPF 1 Thu Aug 25, 2016 9:37 pm
No new posts File matching with PD key on differen... hiravibk DFSORT/ICETOOL 2 Wed Feb 17, 2016 11:40 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us