Consultor Eletrônico



Kbase 18866: ADM2. Assigning Two Key Fields In A SmartDataObject (SDO)
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   16/10/2008
Status: Unverified

FACT(s) (Environment):

Progress 9.x

SYMPTOM(s):

ADM2

FIX:

The V9 SmartObject sample procedure adds order lines to existing orders and assigns the order number and carrier values as foreign keys in the SDO.

Since we are working with two fields, for this example we must copy the carrier field from the Order table and include it in the Orderline table.

1) Create a SmartDataObject for Order table in the sports2000 sample database.

2) Create a SmartDataBrowser for Order table using the SDO created in step #1 as its Data Source.

3) Create a SmartDataObject for Orderline table.

4) Create a SmartDataViewer for 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 and drop the Order SDO and SDB  onto it and link them with a Data link.

6) Drop the Orderline SDO onto the SmartWindow and link it to the Order SDO with a Data link and map the Ordernum and carrier fields as the foreign keys.

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 SmartDataObject with a Navigation link.

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

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

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

/* Code placed here will execute PRIOR to standard behavior. */

DEFINE VARIABLE cforfld AS CHARACTER NO-UNDO.
DEFINE VARIABLE cforval AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE x AS INTEGER NO-UNDO.

IF DYNAMIC-FUNCTION('getnewrow':U) THEN
DO:
ASSIGN i = 2
x = 1.
REPEAT:
IF x > NUM-ENTRIES(DYNAMIC-FUNCTION('getforeignvalues'),chr(1)) THEN
LEAVE.
cforfld = ENTRY(i,DYNAMIC-FUNCTION('getforeignfields'),CHR(1)).
cforval = ENTRY(x,DYNAMIC-FUNCTION('getforeignvalues'),chr(1)).
IF pcvaluelist "" THEN
pcvaluelist = pcvaluelist + chr(1).
pcvaluelist = pcvaluelist + cforfld + chr(1) + cforval.
i = i + 2.
x = x + 1.
END.
END.

RETURN SUPER( INPUT pcRowIdent, INPUT pcValueList ).

END FUNCTION.

When a newly created orderline record is submitted in the orderline SDO, the order number and carrier fields from its data-source order is retrieved and used to assign the orderline.ordernum and orderline.carrier fields.