Finding "the most recent record" from a subset of

johnsogjjohnsogj Member Posts: 103
I'm trying to build a report that can look back through a subset of records already pulled and perform some actions based on values in the most recent record from that subset:


Here is what I’ve built so far:

1.I display a list of receipt records that meet a certain criteria.
2.Then I calculate the total quantity received across all of those records.
3.Then I compare that total quantity received to another value I’ve already calculated (total sold) to determine the Total Qty Remaining

Then I get stuck. Here is what I need to do next:

1.If the value from #3 above (Total Qty Remaining) is greater than zero, find quantity in the MOST RECENT receipt record from step #1
2.Subract the quantity in that most recent receipt record from the “Total Qty Remaining”,
3.If it is 0 or less, I’m done.
4.But if that quantity is greater than zero, go find the quantity in the NEXT MOST RECENT receipt record and repeat…

Can anyone help? Does anyone know of any functions that could be useful?

Thanks,
Molly

Comments

  • garakgarak Member Posts: 3,263
    i hope i understand this.
    when you run 1. you can store the needed datas into a temp. table.
    then, on 3.x you go through these stored temporary records to find the record you need.

    For an better understanding (my part) its good to see some code snippes.

    regards
    Do you make it right, it works too!
  • johnsogjjohnsogj Member Posts: 103
    It makes sense, but some sample code would definitely help. Do you know where I could see some? Or do you know of any documentation on how to build a temp table?
  • garakgarak Member Posts: 3,263
    as a temporary table you can use every table. in some cases (i think ever) its better to create your own table. these table you use as temporary table.

    How to define a table in code as temporary:

    create a recordvariable under Global variables or Local variables

    name Type ID
    TempTab record 27 //for example

    Now go to the properties of these variabel. here you see the property temporary. So, datas in a temp. table are only in the client cache. But note: if you forgott to set the property temporary you work on the real table. So its better to create your own real table (like 50000 My Buffer) with some fields (integer, decimal, char, text, code, etc.) to use this as temorary table. So the distress is not so high, that you delete inadvertently the records in the real table.

    regards.

    PS: with code snippes i mean your code
    Do you make it right, it works too!
  • johnsogjjohnsogj Member Posts: 103
    Thank you - now I understand how to create the temporary table - but how do I write my subset of receipt records to that table once I find them in the Purch. Rcpt. Line table?
  • garakgarak Member Posts: 3,263
    like you write data per code in other tables.

    You are new on Nav :?: If yes, please, before you develop your own solutions, read the manual
    Application Designer’s Guide (w1w1adg.pdf)
    Do you make it right, it works too!
Sign In or Register to comment.