Consultor Eletrônico



Kbase 18468: ADM-ADM2. Converting Version 8 SMO Attributes to Version 9 Properties
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Verified

GOAL:

ADM-ADM2 Progress SmartObject Conversion Utility

GOAL:

This solution shows you how to convert a Version 8 style application using user-defined attributes to pass information between SmartObjects, to a Version 9 style SmartObject application that uses properties to pass this same information.

FACT(s) (Environment):

Progress 9.x

FIX:

There are two ways to pass user-defined information between SmartObjects with Version 9, the first is a naming convention used with user defined functions which will "set" and "get" properties in an object.  The second way is with dynamic properties which work similar to Version 8 get and set attribute list.

The naming convention requires the developer to write functions with the name setpropertyname and getpropertyname in the objects where the property needs to be set.  One advantage of using this approach is that the data is returned in its native datatype. This approach is recommended when properties are needed in a custom super procedures that will become part of an object type.

Dynamic properties work similar to Version 8 attributes, they are stored in ADM-DATA and are returned as strings which may need to be converted to another data type. This approach is recommended for a property being used once in an application.

The Version 8 example application used in this solution is a SmartWindow that contains a SmartQuery for Customers and a SmartViewer that displays Customer information for that query. The SmartWindow has a fill-in field called Credit Limit and a button that allows a user to enter a Credit Limit for the Customer and sets an attribute in the SmartViewer with the data entered by the user. The button trigger code does the following to set the attribute:


RUN set-attribute-list in h_v-customer ('NewLimit=' + dNewLimit:SCREEN-VALUE).

The SmartViewer then gets this attribute when it needs it in its code with the following:


RUN get-attribute ('NewLimit').
ASSIGN dLimit = DECIMAL(RETURN-VALUE).

The SmartObject Conversion Utility shipped with PRO*Tools will attempt to convert this code using the set and get naming convention as follows:

SmartWindow code that had set the attribute is changed to:


{set NewLimit '''}

SmartDataViewer (converted from the SmartViewer) code that had gotten the attribute will be converted to:


ASSIGN dLimit = DECIMAL(getNewLimit())


The conversion utility cannot completely convert your attributes to Version 9 properties.  You will need to manually adjust your code to use properties and add set and get functions to set and get these properties, or modify the code to use dynamic properties instead.

To get the code working in Version 9 as it did in Version 8 with set and get property user defined functions you first need to add functions to the SmartObject that the attribute had been set and get in, in this case the SmartViewer.

You would need to add the following two functions to your SmartDataViewer:


FUNCTION getNewLimit RETURNS DECIMAL
RETURN CreditLimitProp.
END FUNCTION.

FUNCTION setNewLimit RETURNS LOGICAL (pdLimit AS DECIMAL):
ASSIGN CreditLimitProp = pdLimit.
   RETURN TRUE.
END FUNCTION.

The following definitions would need to be added to the Definitions section of the SmartDataViewer:


DEFINE VARIABLE CreditLimitProp LIKE Customer.Credit-Limit NO-UNDO.

The following code would be used in the SmartWindow's button trigger to set the property:


DYNAMIC-FUNCTION('setNewLimit':U IN h_v-customer, DECIMAL(dNewLimit:SCREEN-VALUE)).

The following code would be used in the SmartDataViewer to get the property:


getNewLimit().

Another option would be to convert the attribute to a dynamic user property in Version 9.  You would not need to add functions to the SmartDataViewer.  You would need to add the following code to the SmartWindow button trigger where the attribute was set to set the property:


DYNAMIC-FUNCTION('setUserProperty':U IN h_v-customer, "NewLimi.t", dNewLimit:SCREEN-VALUE).

The following code would be used in the SmartDataViewer to get the property:


DECIMAL(DYNAMIC-FUNCTION('getUserProperty':U, "NewLimit")).

With either of these approaches the additional modifications to your SmartObject application, beyond what the SmartObject Conversion Utility will change for you, the Version 9 property, NewLimit, will work the same as the Version 8 attribute..