Consultor Eletrônico



Kbase P33078: Sample code to set dynamically Foreign fields depending on d
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/24/2003
Status: Unverified

GOAL:

Sample code to set dynamically Foreign fields depending on data-source SDO

FIX:

When Data-Source is THIS-OBJECT, it can indeed be a parent SDO on unknown table at design time, so the foreign cannot be defined at design time, and needs to be set at run time.  (example, Orderline SDO can be linked to either Order SDO or Item SDO, depending on the Parent Window it is launched from)

In initializeObject of SDO Data Logic Procedure:
DEFINE VARIABLE hDataSource AS HANDLE NO-UNDO.
DEFINE VARIABLE cTables AS CHARACTER NO-UNDO.
DEFINE VARIABLE cForeignFields AS CHARACTER NO-UNDO.

{get DataSource hDataSource}.

IF VALID-HANDLE(hDataSource) THEN DO:
{get Tables cTables hDataSource}.
IF LOOKUP("TableA",cTables) > 0 THEN DO:
cForeignFields = "TableA.FieldOne_obj,FieldOne_obj".
{set ForeignFields cForeignFields}.
END.
IF LOOKUP("TableB",cTables) > 0 THEN DO:
cForeignFields = "TableB.FieldTwo_obj,FieldTwo_obj".
{set ForeignFields cForeignFields}.
END.
END.

RUN SUPER.