Hi,

I would like to have some clarification and opinion on this one.

I have a function that will be retrieving data from parent and other related records and this would be called from various places in an application.

Shall I save this in the DD of the table or in an include file (.inc)?

If I save it in the DD, shall I retrieve the contents of the fields from the DD buffer using get field_current_value or directly from the global buffer?

Also if I need to retrieve data from unrelated /related tables, is there a way of using the tables' DDO buffer from within DD of another table.

Am I right in assuming that when I call the function I will have only that record in memory (and this will apply for each instance, that is per user)

Ex Consider having another table in the Order System that is related to the item table and the vendor and for which i want to get the cost price.

So I add this function in the OrderLine_DD (this is just some pseudocode) and will be called from different views.

Code:
    Function GetCostPrice returns Number
        Number nCostPrice
        //
        move 0 to nCostPrice
        //
        clear tblPrice
        move orderline.item_no to tblCostPrice.item_no
        move item.vendor         to tblCostPrice.VendorNo
        move order.date           to tblCostprice.Date
        find ge tblCostPrice by index.2
        if (found) move tblCostPrice.price to nCostPrice

        Function_Return nCostPrice

    End_Function
or this

Code:
    Function GetCostPrice returns Number
        Number nCostPrice
        integer iVendorNo 
        Date dDate
        //
        move 0 to nCostPrice
        get field_current_value of Order_DD field order.date to dDate
        get field _current_value of Item_DD field item.vendor to iVendorNo
        //
        send clear to tbCostlPrice_DD
        move orderline.item_no to tblCostPrice.item_no
        move ivendorNo         to tblCostPrice.VendorNo
        move dDate           to tblCostprice.Date
        send find of tblCostPrice_DD GE 2
        if (found) get field_current_value of  tblCostPrice_DD field tblCostPrice.price to nCostPrice

        Function_Return nCostPrice

    End_Function
Thanks in advance

Jesmond