Hi Michael,

Thanks for the detailed explanation.


"as far as where the function should live it is a design choice. Of course the DD is a nice place where it can be organized but at the same time it means you have to have a DD instance to use it.

So it depends on the need. We have lots of functions like this in DDs but also have a number of more global things again depending on how we need to use it
if you decide to use it outside a DD make use of the USE command not #INCLUDE. USE will ensure a single use of a package while #INCLUDE will not"
Thanks for this. I will change my code to replace the #INCLUDE with USE

"DD fields vs global buffer
again a choice dependent on your design and intended use. A lot of our functions similar to what you have here (price lookup) use the global buffers" -
I think I will take this route as these functions will be used to retrieve data

"Accessing other DDs
if the DD is part of your DD structure (related somehow and DD in the structure) you can use the Which_Data_Set function to get the DD object id.
if the DD is not part of the structure you would have to come up with some other way. Do not just use the object name. A lot of code written with hard coded object names that fails at some point" -
Will look into Which_Data_Set, I never used it before (wasn't even aware of it)

"RE: I will have only that record in memory
there is only one record buffer per table.
In a desktop app this is simple of course in a webapp you have to be careful as this data will not carry over a roundtrip to the client.

so for example if you have 2 buttons and the first calls this function the data will not automatically be available when clicking the second button (it will actually work in the debugger because there is only one process, but not when the app runs outside the debugger)"
I am not sure whether I am understanding correctly here. So if I am in view using DD's and call a function which is placed inside the main dd, the global buffers will be in sync. If I call it again from another button, the buffers won't be in sync?

"In one system we have something similar but much more complex. We have a structure for Inventory Pricing Info and a function to get the data.
Data comes from a number of tables and settings and fills the info structure that contains cost, SRP info, barcodes, etc." - I just made that example to explain myself. I am building an Insurance module

Thanks once again