View previous topic :: View next topic
|
Author |
Message |
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
I have two different files i need to match the amounts.If amounts are matched i need to eliminate records.
Code: |
Record No File 1 File 2
1 1000 1000
2 1000 2000
3 2000 3000
4 3000 4000
5 3000 5000
6 4000 6000
7 4000 8000
8 4000 11000
9 4000
10 4000
11 4000 |
In above amounts first i need to compare amounts equal in both the files and i need to eliminate that records.Then remaining amounts i need to take and adding the amounts and find the match.
above example.
1) First i will check amounts in first file with second file at that i can eliminate 1,3,4,6 records from first file and 1,2,3,4 from second file.
2) Next i need to take remaining amounts from first file and second file.I need to match the amounts by adding one or more amounts in first file match with amounts in second file.I don't want to some amounts in second file.
3) If still unmatched amounts exists means i need to take second file one or more records to add and find exact match with first file. |
|
Back to top |
|
|
sandeep1dimri
New User
Joined: 30 Oct 2006 Posts: 76
|
|
|
|
hi
Quote: |
1) First i will check amounts in first file with second file at that i can eliminate 1,3,4,6 records from first file and 1,2,3,4 from second file.
2) Next i need to take remaining amounts from first file and second file.I need to match the amounts by adding one or more amounts in first file match with amounts in second file.I don't want to some amounts in second file.
3) If still unmatched amounts exists means i need to take second file one or more records to add and find exact match with first file. |
Query>
1. So ur comparing only the amount and ther is no other key for comparionsion ?? and why records 6-11 not droped from first file??
2.Then u need to do permutaion of addition of amount in first file ? Please elaborate.
Plse provide examples for requirement 2 and 3.
Sandeep |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
Yes I agree, we need to see your 'rules' in detail with examples.
Starting perhaps with how rules 2 and 3 apply to your example shown. |
|
Back to top |
|
|
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Hi Sandeep,
Yes i have a Key field is existed Claim no,With the same claim no i may get duplicate records.In that duplicates i need to match the amounts.
Why i have not eliminated 7 to 11 records from file1 means there is no matching amount in file2.File2 has existed only one 4000 amount that is matching with 5 record in first file.(First com first serve basis).
for second case i may get records from above example is from first file 2,5,7 to 11 records.From second file i will get 5,6,7,8 records.
I will do add amounts one or more amounts from first file and match with second file.
In second case also i am not able to eliminate any records then i need to go for third case.
Thanks,
Thanooz. |
|
Back to top |
|
|
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Hi Sandeep,
Yes.For second case i need to do permitations and combinations.
Thanks,
Thanooz. |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
Just to understand,
if after first round of elimination you are left with in file 1
1000
3000
4000(X5)
and in file 2
5000
6000
8000
11000
and you want to match combinations from file1 to file 2 to eliminate further.
eg method 1
starting with 1st remaining record in file2 and looking for matches
5000 = (1000+4000) leaving
3000, 4000(x4) in file1 unmatched
6000 does not match any permutation left in file1
8000 = (4000+4000) leaving
3000, 4000(X2)
11000 = (3000+4000+4000)
so all match except for 6000 in file2
or method 2
starting with file1
1000+3000 no match
1000+3000+4000 = 8000
4000+4000 no match
4000+4000+4000 no match
leaving
4000(x4) in file 1 and 5000, 6000, 11000 in file2
so then would you go on to option 3)ie file 2 combinations
eg
5000+6000 no match
5000+6000+11000 no match
5000+11000 = (4000+4000+4000+4000)
thus
leaving 6000 in file 2 unmatched (same result as method 1) |
|
Back to top |
|
|
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
hi,
Your explanation is correct.It has to work like method1.
In above example i have given some records.I don't know how many records come for file1 and file2.I have to write cobol code for like method one.
Thanks,
Thanooz. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
What you are looking for sounds very similar to the "cash application" algorithm used in some Accounts Reveivable systems. When a customer sends a payment, an invoice of the exact payment amount is "matched". For checks that do not exactly match an invoice, invoices are "grouped" and if a group totals to the same amount as a payment, they are all "paid" by that payment. If a payment is not matched to an individual invoice and does not match a "group", the payment is usually applied to the oldest invoices.
This was often done using arrays within the code.
I mention all of that to make sure that what you want to do is similar to the process i described. If so, you might search the web for some real or pseudo-code that does this for A/R and clone it for your use. |
|
Back to top |
|
|
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Hi,
You r correct.Could you provide any code or any website that can give some idea on this.
Thanks,
Thanooz. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19243 Location: Inside the Matrix
|
|
|
|
Hello,
Sorry, but i have no code - when i worked on a couple of these, it was before downloading source was possible.
That's why i suggested you might do some searching on the web - i just did a search using "cash application" and "receivable" as the search term and got over 21,000 hits. I suspect that among them is somthing you can use. |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
There is also a wee chance that your shop might have that algorithm already running somewhere.
Worth asking around? |
|
Back to top |
|
|
thanoozm
New User
Joined: 23 May 2007 Posts: 26 Location: hyderabad
|
|
|
|
Hi all,
Thank you very much for your support.
Thanks,
Thanooz. |
|
Back to top |
|
|
|