Thanks Don. Here is what I ended up with but I'm not sure if I handled
the first and last record properly I haven't verify those.

Thanks for the tip.

WW

034     LOOP
035      WHILE READNEXT RMT.ITM FROM RecordList DO
036       READ Rec FROM F.RMT, RMT.ITM ELSE STOP
037       ThisCPN = Rec<1>
038       IF ThisCPN <> CurrentCPN THEN
039         PRINT 'CPN = ':CurrentCPN:' ':'Total = ':TotalQTY:'
':'Average = ':OCONV(TotalQTY/1.5, "MD")
040         CurrentCPN = ThisCPN
041         TotalQTY = OCONV(Rec<4>, "MCN")
042       END ELSE
043         TotalQTY += OCONV(Rec<4>, "MCN")
044       END
045       *PRINT Rec<1>:' ':Rec<2>:' ':Rec<3>:' ':Rec<4>
046     REPEAT


On Apr 29, 10:37 pm, DonRobinson <[email protected]> wrote:
> Hello ww,
>
> A few more details would be helpful but I'll assume a few things.
>
> If the transaction file records contain the items numbers and received
> quantities in associated multi-value fields, then you need to do an
> exploding sort by item number,
>
> SELECT TRANSACTIONS BY-EXP ITEMNBR
>
> then in your BASIC program, total the quantity field and calculate the
> average each time the item number changes.
>
> You will need to handle the first record and last record in such a way
> that nothing is printed for the first record read and the total and
> average is printed after the last record is read. You will need
> variables to store the item number and running total so you can
> compare the item number with the item number for the current record.
> When the current item number is different than the stored item number,
> then print the stored item number and running total, then store the
> current item number and replace the total with the current quantity.
> If you want a grand total, then you need another variable to store it
> and print it out after the last record.
>
> So;
> process first record,
> printout data when item number changes
> replace item number and total when item changes
> process last record and grand total.
>
> And to make it useful, print column headings, etc.
>
> Hope this helps,
> Good luck.
> DonR
>
> On Apr 28, 5:49 pm, ww <[email protected]> wrote:
>
>
>
> > I have a data file containing transaction numbers and quantities for
> > items received. I need to select transactions received in the last 45
> > days and then find all transactions for that same item so I can find
> > the total quantity received for that item. From there I can find the
> > 45 day average. Finding the average is the easy part! Finding the
> > proper records is where I'm in the dark.
>
> > I know I need a loop within a loop but I'll be darned if I can figure
> > it out. I tried returning a list of transaction meeting the criteria
> > and then selecting and returning a list of transactions based on the
> > key from the first list but I don't know how I can total the quantity
> > from there. Maybe I'm not even on the right track.
>
> > Any thoughts on how I might achieve this.
>
> > Thanks in advance,
>
> > WW- Hide quoted text -
>
> - Show quoted text -

--~--~---------~--~----~------------~-------~--~----~
Please read the posting guidelines at: 
http://groups.google.com/group/jBASE/web/Posting%20Guidelines

IMPORTANT: Type T24: at the start of the subject line for questions specific to 
Globus/T24

To post, send email to [email protected]
To unsubscribe, send email to [email protected]
For more options, visit this group at http://groups.google.com/group/jBASE?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to