Kbase 19554: ADM2. How to Add a Calculated Field
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  4/4/2006 |
|
Status: Unverified
GOAL:
How to Add a Calculated Field?
FACT(s) (Environment):
Progress 9.x
FIX:
The SmartDataObject can represent data from either a single table or a join of tables. If you need to display and interact with supportive records in addition to the main set of records, use a Calculated Field. For example, If the goal is to display records from the Order table and only the Name field from the Customer table, make use of a Calculated field that holds the return value of Customer.name
1) In the SmartDataObject, create a function called getname that takes the Customer Number as an argument and returns the description of that Customer.
2) Add the following code to this function:
FUNCTION getname RETURNS CHARACTER (INPUT iCustNum AS INTEGER):
FIND FIRST Customer WHERE Customer.CustNum = iCustNum NO-LOCK NO-ERROR.
IF AVAILABLE(Customer) THEN
RETURN Customer.Name
ELSE
RETURN "".
END FUNCTION.
3) In the SDO's Property Sheet, click on Fields, Calculated Field and add the following code to the Expression Window:
getname(RowObject.CustNum). Click OK, and name the Calculated Field name in the Field Attributes window.
4) Now when you create a new SmartDataViewer for this SDO, you will see the Calculated Field "name" as one of your fields to select.