Consultor Eletrônico



Kbase 18422: ADM2 - How To Assign A Key Field In A SmartDataObject
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   06/01/2004
Status: Unverified

GOAL:

ADM2 - How to Assign a Key Field in a SmartDataObject (SDO)

FACT(s) (Environment):

Progress 9.x

SYMPTOM(s):

ADM2

FIX:

SmartObject application that adds order lines to existing orders and assigns the order number key value to newly created order line records in a SmartDataObject (SDO).

Follow these steps:
1) Create an SDO for the Order table in the Sports2000 sample database.

2) Create an SDB for the Order table using the SDO you created in step #1 as the data source.

3) Create an SDO for the Orderline table.

4) Create a SmartDataViewer (SDV) for the Orderline table using the SDO created in step #3 as its data source.

Include Orderline.Ordernum as a field in the SmartDataViewer and disable it.

5) Create a SmartWindow, drop the Order SDO and SmartDataBrowser (SDB) onto it, then link them with a data link.

6) Drop the Orderline SDO onto the SmartWindow, link it to the Order SDO with a data link and map the Ordernum field as the foreign key.

7) Drop the Orderline SDV onto the SmartWindow and link it to the Orderline SDO with data and update links.

8) Drop a Navigation SmartPanel onto the SmartWindow and link it to the Orderline SDO with a Navigation link.

9) Drop an Update SmartPanel onto the SmartWindow and link it to the Orderline SDV with a TableIO link.

10) Create a submitRow override function in the Orderline SDO with the following code:

RETURNS LOGICAL (pcRowIdent AS CHARACTER, pcValueList AS CHARACTER) :

    DEFINE VARIABLE cforfld AS CHARACTER NO-UNDO.
    DEFINE VARIABLE cforval AS CHARACTER NO-UNDO.

   /* Code placed here will execute PRIOR to standard behavior. */
    IF DYNAMIC-FUNCTION('getNewRow') THEN
DO:
         ASSIGN cforfld = ENTRY(2, DYNAMIC-FUNCTION('getForeignFields'))
           cforval = DYNAMIC-FUNCTION('getForeignValues').

         IF pcValueList <> "" THEN
ASSIGN pcValueList = pcValueList + CHR(1).

           ASSIGN pcValueList = pcValueList + cforfld + CHR(1) + cforval.
       END.

    RETURN SUPER(pcRowIdent, pcValueList).

END FUNCTION.

When a newly created orderline record is submitted in the Orderline SDO, the order number from its data source Order is retrieved and used to assign the Orderline.Ordernum field.