Consultor Eletrônico



Kbase P160969: How to capture the changed values of browse columns?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   26/02/2010
Status: Unverified

GOAL:

How to capture the changed values of browse columns?

GOAL:

How to capture the old values of browse columns?

GOAL:

How to use the MODIFIED attribute of browse columns?

FACT(s) (Environment):

Windows
Progress 9.x
OpenEdge 10.x
OpenEdge Category: Language (4GL/ABL)
OpenEdge Language Category: ADE Tools

FIX:

To check whether a cell (aka field or column) in a browse has changed, we use the MODIFIED attribute.

The following steps demonstrate how to use the Progress or OpenEdge AppBuilder to create a sample Window application against the sports2000 demo database that shows how to capture the existing (old) column values using the browse ROW-ENTRY event trigger and how to capture the new (modified) column values using the browse ROW-LEAVE event trigger:
1. In the Definitions Section, define the following variables to capture the old field values on the browse ROW-ENTRY event and new or modified (changed) field values, if any, on the browse ROW-LEAVE event:
/* Local Variable Definitions --- */
DEFINE VARIABLE cOldRegionValue AS CHARACTER NO-UNDO.
DEFINE VARIABLE cOldStateValue AS CHARACTER NO-UNDO.
DEFINE VARIABLE cOldStateNameValue AS CHARACTER NO-UNDO.
DEFINE VARIABLE cNewRegionValue AS CHARACTER NO-UNDO.
DEFINE VARIABLE cNewStateValue AS CHARACTER NO-UNDO.
DEFINE VARIABLE cNewStateNameValue AS CHARACTER NO-UNDO.
2. Cut and paste the following code to the browse ROW-ENTRY event trigger. This code simply stores the old (existing) values of all columns of the state table when the user enters a row. In the AppBuilder design mode, the body of this trigger looks like this:
DO:
ASSIGN
cOldRegionValue = State.Region:SCREEN-VALUE IN BROWSE BROWSE-2
cOldStateValue = State.State:SCREEN-VALUE IN BROWSE BROWSE-2
cOldStateNameValue = State.StateName:SCREEN-VALUE IN BROWSE BROWSE-2.
END.
3. Cut and paste the following code to the browse ROW-LEAVE event trigger. This code captures any MODIFIED or changed fields or columns and messages a summary of the old and the new values if one or more fields have been modified. In the AppBuilder design mode, the body of this trigger looks like this:
DO:
DEFINE VARIABLE cMessage AS CHARACTER NO-UNDO.
ASSIGN
cNewRegionValue = ""
cNewStateValue = ""
cNewStateNameValue = ""
cMessage = "Field" + "~t~t" + "Old Value" + "~t~t" + "New Value" + "~n".
IF State.Region:MODIFIED IN BROWSE BROWSE-2 THEN DO:
ASSIGN
cNewRegionValue = State.Region:SCREEN-VALUE IN BROWSE BROWSE-2
cMessage = cMessage + "Region" + "~t~t" + cOldRegionValue + "~t~t" + cNewRegionValue + "~n".
END.
IF State.State:MODIFIED IN BROWSE BROWSE-2 THEN DO:
ASSIGN
cNewStateValue = State.State:SCREEN-VALUE IN BROWSE BROWSE-2
cMessage = cMessage + "State" + "~t~t" + cOldStateValue + "~t~t" + cNewStateValue + "~n".
END.
IF State.StateName:MODIFIED IN BROWSE BROWSE-2 THEN DO:
ASSIGN
&n.bsp; cNewStateNameValue = State.StateName:SCREEN-VALUE IN BROWSE BROWSE-2
cMessage = cMessage + "StateName" + "~t" + cOldStateNameValue + "~t~t" + cNewStateNameValue + "~n".
END.
IF (State.Region:MODIFIED IN BROWSE BROWSE-2) OR (State.StateName:MODIFIED IN BROWSE BROWSE-2) OR (State.State:MODIFIED IN BROWSE BROWSE-2) THEN
MESSAGE cMessage
VIEW-AS ALERT-BOX INFO BUTTONS OK.
END.
4. Save and Run the Window. Observe that if you modify none or more column values, the old and the new values will be displayed by the message statement when you leave the modified row.
.