Consultor Eletrônico



Kbase 15202: How to include a CALCULATED FIELD in a SMART VIEWER object
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to include a CALCULATED FIELD in a SMART VIEWER object


How can a calculated field be included in a Version 8 Smart Viewer?

SmartObjects are implemented as persistent procedures whose
functionality is contained within internal procedures. In order to
pass messages between SmartObjects it is necessary to run standard
internal procedures called "event procedures" or "method procedures",
depending on whether they are customizable or not, respectively.

So, in order to to modify the behavior of a SmartObject it is
necessary to customize that object's appropriate event procedure.
PROGRESS allows programmers to create local versions of these
standard events easily.

The example in this knowledgebase entry uses the sports database.
Let's say you want a SmartViewer to display the customer fields
name, credit limit, and balance, as well as a calculated field
for available credit which is derived using the credit limit and
balance.

(1) Create a SmartViewer and add the three database fields: name,
credit limit, balance.

(2) Add a fill-in field as a fourth field and name it avail-credit.
Mark this field "disabled" in its Property Sheet. This step
has now created a display space for the calculated value.

(3) Select the Section Editor. Note that you are editing code within
the persistent procedure which constitutes the SmartObject, *not*
the code for the window which will eventually contain it. The
title bar on the Section Editor should indicate this.

(4) In the Section Editor, under "Section" choose "Procedures".
Click "New" for a new procedure. This is the procedure which will
be overriding the default processing.

(5) A dialog box will appear that includes a radio-set with three
buttons; select "Local ADM Event". Note that the fill-in for
the name of the event is disabled; the procedure you will write
must have a specific name in order to override existing event
procedures.

(6) In the "Source" combo-box, select "adm-display-fields". This is
the event whose behavior you want to modify. A procedure appears
which consists of the following:

/* <procedure heading comments> */
/* Code placed here will execute PRIOR to standard behavior */

/* Dispatch standard ADM method. */
RUN dispatch IN THIS-PROCEDURE ( INPUT 'display-fields':U) .

/* Code placed here will execute AFTER standard behavior */

Add code after the last commend, since you want your code to run
after the remaining fields are retrieved from the database and
displayed. This additional code should be:

avail-credit = customer.credit-limit - customer.balance.
DISPLAY avail-credit WITH FRAME F-Main.

(7) Save the SmartViewer and place an instance of it within your
design SmartWindow, along with a SmartQuery and a Navigation
Panel. When you run the result, you should see the calculated
field properly created and displayed.

Progress Software Technical Support Note # 15202