Page 1 of 1

I can't solve a problem using DFSORT

PostPosted: Wed Sep 12, 2012 5:26 pm
by javivi
Hi
I have a problem that i can’t solve with DFSORT but I hope it possible to solve with DFSORT.

I have a file with the input money and output money from an account and I need to match each output with each input. The rules to match a output with a input are:
1.- Look for an input with a date less than the output.
2.- If the input money is >= than the output money , the match finish and the output money is subtracted from the input money.
3.- If the input money is < than the output money, subtract the input money from the output money and look for another input.

Example file:
KEY          INPUT/OUTPUT  MONEY   
------------ ------------- ------
A 2010-01-01   input       +40
A 2010-03-02   input       +80
A 2011-04-06   input       +100
A 2012-01-03   output      -110
A 2012-02-05   output      -10
A 2012-05-03   output      -12
A 2012-06-09   input       +50


I need to obtain the next file :
KEY          INPUT/OUTPUT  MONEY   
------------ ------------- ------
A 2010-01-01   input       +0
A 2010-03-02   input       +0
A 2011-04-06   input       +82
A 2012-01-03   output      -110
A 2012-02-05   output      -10
A 2012-05-03   output      -12
A 2012-06-09   input       +50


Explanation

The first output with 110 matches with the first input of 40 and let the input with 0, but in the output remain 70 not matched against any input. Then search for other Input and find the second input with 80, subtract 70 from 80 and leave de second input with 10. The first output now is fully matched.
The second output with 10 use the second input, and leave the second input with 0 and the second output is fully matched.
The third output with 12 matches with the third input and let the input with 82 and the third output is fully matched.

There is any interested to help me?

Thanks.

Code'd

Re: I can't solve a problem using DFSORT

PostPosted: Wed Sep 12, 2012 6:21 pm
by NicC
Read it twice - still all gobbledy-gook to me. Is your first file supposed to be for SORTIN and the second for SORTOUT? If so, still does not make sense.

Re: I can't solve a problem using DFSORT

PostPosted: Wed Sep 12, 2012 6:55 pm
by BillyBoyo
Why don't you just set some of the "input"s to zero and some to amounts smaller than they started with.

Without looking at the original input, no-one can have any idea that anything is wrong.

Of course, I'm not really suggesting you do this. I'm pointing out that the "design" is deeply flawed. Such that the above is true.

Re: I can't solve a problem using DFSORT

PostPosted: Wed Sep 12, 2012 6:58 pm
by enrico-sorichetti
I can't solve a problem using DFSORT

stupid title,
the only reasonable reply is how bad

I wonder why the TS requested a solution for the "amount against multiple invoices" problem
using a dsfort solution, instead writing a program to provide a properly audited track of the computations

see anyway for example ...
http://ibmmainframes.com/about58190.html

Re: I can't solve a problem using DFSORT

PostPosted: Wed Sep 12, 2012 8:46 pm
by dick scherrer
Hello,

This sounds very much like an Accounts Receivable cash application situation.

Because there many things going in most (every one i've seen) cash application processes, i do not believe it should be done tieh the sort or any other utility. Cash application becomes rather complex and usually refers to vsam or database data as part of the process.

I suspect this came to the sort part of the forum to get away from having to develop the process. . .