Kbase P42492: Dynamics: How to add a Calculated Field for a Dynamic SmartD
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  9/16/2003 |
|
Status: Unverified
GOAL:
Dynamics: How to add a Calculated Field for a Dynamic SmartDataObject (DynSDO)
FACT(s) (Environment):
Dynamics 2.0A
FIX:
The way to create a calculate field for DynSDOs is different than the way to create it in an Static SmartDataObject.
In a DynSDO the calculate field definition is stored in the repository database and the calculated field logic must be added in a function in its DataLogicProcedure (DLP). The function name must be called: "Calculate" + Field-Name.
The following are the steps to create a calculate field for a DynSDO:
1- Open the DynSDO, create the Calculated Field using the 'Calculated Field' button.
2- Add the Data Type, Name, Label, Format and Help values for the calculated field.
3- Save the DynSDO.
4- Open the DataLogicProcedure for the DynSDO
5- Create a function called Calculate<Field-Name> (i.e.: For the calculated field 'myCalcField' the function name must be: 'CalculateMyCalcField').
The DataLogicProcedure does not have neither the RowObject temp-table definition or the pointer of the record. Therefore the reference to the field must be done getting the RowObject or Field handles.
/*Calculated Field function using the RowObject handle*/
FUNCTION CalculateNewLimit RETURNS DECIMAL:
DEFINE VARIABLE hRowObject AS HANDLE NO-UNDO.
DEFINE VARIABLE hCreditLimit AS HANDLE NO-UNDO.
hRowObject = DYNAMIC-FUNCTION(·getRowObject·:U IN TARGET-PROCEDURE).
hCreditLimit = hRowObject:BUFFER-FIELD(·CreditLimit·:U).
RETURN hCreditLimit:BUFFER-VALUE * 1.10.
END FUNCTION.
/*Calculated Field function using the database Field handle*/
FUNCTION CalculateNewLimit RETURNS DECIMAL:
DEFINE VARIABLE hCreditLimit AS HANDLE NO-UNDO.
ASSIGN hCreditLimit = DYNAMIC-FUNCTION('dbColumnHandle':U IN TARGET-PROCEDURE, INPUT ·CreditLimit·:U).
RETURN hCreditLimit:BUFFER-VALUE * 1.10.
END FUNCTION.