Page 1 of 1

File Comparison and RE-write

PostPosted: Thu Oct 27, 2011 2:46 am
by jaydeep1
I am working on a preparing a solution for the below requirement. Can you suggest some SORT ideas. We have SYNCSORT R132.

Input 1 (always negative values)
A  -2000
B  -2500   


INPUT 2 (always zero or positive values)
A         +100             280
A         +200             280
A         +300             281
A         +400             282
A         +500             283
A         +600             288
A         +700             290
B         +100             280
B         +200             280
B         +300             281
B         +400             284
B         +500             284
B         +600             290
B         +700             299
B         +800             300


Read (always negative) value against 'A' from INPUT1 and Start Reading 'A' records from INPUT2 from top to bottom till it covers (-ve from INPUT1 plus 'added up' +ve from INPUT2 is equal to or greater than zero). Once -ve value is fully covered, take value associated with the last read row, from the third column of INPUT2 and apply to all the rows previously read, leaving the remaining ('unread') rows intact.

Desired OUTPUT
A         +100             288
A         +200             288
A         +300             288
A         +400             288
A         +500             288
A         +600             288
A         +700             290
B         +100             299
B         +200             299
B         +300             299
B         +400             299
B         +500             299
B         +600             299
B         +700             299
B         +800             300


Any suggestions/help is greatly appreciated. If this can be achieved in a multi-step SORT, that would be great! Otherwise, the only option would be COBOL Program with Arrays! :x

Re: File Comparison and RE-write

PostPosted: Fri Oct 28, 2011 6:11 am
by dick scherrer
Hello and welcome to the forum,

Your "output" does not appear to follow your posted "rules" :?
I may have misunderstood something.

Keep in mind that while your question is completely clear to you, it may not be to those who read it and would like to help.

Good job using the Code tag - it would be helpful if everyone did :)

Re: File Comparison and RE-write

PostPosted: Fri Oct 28, 2011 7:50 pm
by jaydeep1
Thanks Dick for your response.

I am attempting to re-word a little bit to make it clearer:

Read (always negative) value against 'A' from INPUT1 and Start Reading 'A' records from INPUT2 from top to bottom till it covers (-ve from INPUT1 plus 'added up' +ve from INPUT2 is equal to or greater than zero). Once -ve value is fully covered, take value associated with the last read row, from the third column of INPUT2 and apply to all the rows previously read, leaving the remaining ('unread') rows, for 'A' , intact. Repeat the same logic for 'B's.

With this added text in bold, I guess my posted 'rules' follow exactly what's shown in the example.

Re: File Comparison and RE-write

PostPosted: Fri Oct 28, 2011 8:08 pm
by BillyBoyo
Once the accumulated value of each letter group "covers" the -ve value for that letter group on the first file, update the reference on all the records, on the second file, for that group up to this point to have the reference of the current record which has completed the "covering" of the -ve value on the first file.

Seems to be asking a lot from a sorting product.

If you can append a running total and a sequence number, then descending sort on the sequence number, you'd know the current record which covered the -ve before you've read the ones which make up that total. Maybe something from that?

Re: File Comparison and RE-write

PostPosted: Fri Oct 28, 2011 8:26 pm
by jaydeep1
Yes, that's exactly what I was trying to get to - to append a running total in the INPUT2. Is that possible through SORT?

Re: File Comparison and RE-write

PostPosted: Fri Oct 28, 2011 8:37 pm
by BillyBoyo
Have you got your sort manual? Maybe have a look at "grouping" the records, and "pushing" a value you can increment? I don't have Syncsort manuals. Have you googled for similar requirements? Might get you something.

Re: File Comparison and RE-write

PostPosted: Fri Oct 28, 2011 8:59 pm
by dick scherrer
Hello,

If the organization is licensed to use the product, all of the material is available free from Syncsort Support.