Checking for consequtive number within a group
Forums
Hi,
I am trying to write a script to find out the consquetive invoices of a vendor from vendor ledger.
Input (Consequtive check is a computed field)
Vendor number
Invoice no
Amt
Consequtive check
1
123
10
Start
1
124
20
Yes
1
125
30
Yes
1
301
400
No
1
302
200
End
2
2134
7000
Start
3
6162
100
Start
3
6163
100
Yes
3
6164
100
Yes
3
6165
400
Yes
3
6166
500
End
Output
Vendor
Purchase amt
No of invoices
No of consequtive invoices
1
660
5
2
2
7000
1
0
3
1200
5
4
How can i achieve this through a script. Could you pls help.
Regards
Padma
Hi Padma,
Hi Padma,
Try this script out. To use it the vendor fields must be a character field and the invoice field must be numeric. I am getting the expected results from your data but it will be good to test it on a longer file. Let me know if you have any problems or it doesn't do what it is supposed to do.
Thanks
Brian
Hi Padma,
Hi Padma,
That line is totally the amounts. Was it able to get through part of the analysis. You should see a new file called Consequtive Numbers, you migth have to close it and open it again to see the contents. Did it get through any of the vendors as there should be a line per vendor. If it got through some do the amounts look right for the different vendors? Usually an Overflow error means that the variable is not large enough to hold the item so in this case the next vendor are the amounts really large?
I am just trying to figure out what might be wrong. Any chance you could share the file with me so I could run it?
Thanks
Brian
Hi Padma,
Hi Padma,
In your above example I understand the results you want except for Vendor 3. Should the number of consecutive invoices be 1 and not 4 as there is no break? I am asking as for Vendor 1 there are two runs of consecutive invoices 123-125 and 301-302.
Let me know and I will see what I can do to help you out.
Brian