Consultor Eletrônico



Kbase 21958: Accessing Specific DataTarget Objects of a Multi Target SDO
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   11/04/2002
SUMMARY:

A SmartDataObject (SDO) can be a data source for multiple DataTarget Objects. These might include one or more SmartDataViewers (SDV), SmartDataBrowsers (SDB), or even another SmartDataObject (SDO). This Solution demonstrates, using sample code, how to get the handle of a specific Smart DataTarget Object from the SDO's target list.

EXPLANATION:

Three ADM2 functions provide the needed access to this information; 'getDataTarget', 'getObjectType; and 'getObjectName'.

-- The ADM2 function 'getDataTarget' returns a comma separated CHARACTER string consisting of the CHARACTER representations of all the Smart DataTarget Objects' handles.

-- The ADM2 function 'getObjectType' returns the type of the SmartObject, such as "SmartDataBrowse", etc.

-- The ADM2 dynamic function 'getObjectName' returns the name of the SmartObject, such as "bCustomer", "vItems", etc.

In the two solutions given below, these three functions are used to obtain the handle of a specified Smart DataTarget Object.

SOLUTION:

A) Scan by target type -- Using the type of the Smart DataTarget Object:

The following snippet extracts the handle of the first SmartDataViewer encountered, while parsing the CHARACTER result returned by the ADM2 function 'getDataTarget':

DEFINE VARIABLE cTargets AS CHARACTER NO-UNDO.
DEFINE VARIABLE hTarget AS HANDLE NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.

ASSIGN
cTargets = DYNAMIC-FUNCTION('getDataTarget':U IN hDataSource).

DO iCounter = 1 TO NUM-ENTRIES(cTargets):
hTarget = WIDGET-HANDLE(ENTRY(iCounter, cTargets)).
IF DYNAMIC-FUNCTION('getObjectType':U IN hTarget) = 'SmartDataViewer' THEN LEAVE.
END.

IF VALID-HANDLE(hTarget) AND DYNAMIC-FUNCTION('getObjectType':U IN hTaget) = 'SmartDataViewer' THEN
MESSAGE "hTarget now holds the handle of the SmartDataViewer"
VIEW-AS ALERT-BOX.
ELSE
MESSAGE "No SmartDataViewer objects are in the target list"
VIEW-AS ALERT-BOX.


B) Scan by target name -- Using the name of the Smart DataTarget Object:

The following snippet extracts the handle of the first Smart DataTarget Object named 'bCustomer', while parsing the CHARACTER result returned by the ADM2 function 'getDataTarget':

DEFINE VARIABLE cTargets AS CHARACTER NO-UNDO.
DEFINE VARIABLE hTarget AS HANDLE NO-UNDO.
DEFINE VARIABLE iCounter AS INTEGER NO-UNDO.

ASSIGN
CTargets = DYNAMIC-FUNCTION('getDataTarget':U IN hDataSource).

DO iCounter = 1 TO NUM-ENTRIES(cTargets):
hTarget = WIDGET-HANDLE(ENTRY(iCounter, cTargets)).
IF DYNAMIC-FUNCTION('getObjectName':U IN hTarget) = 'bCustomer' THEN LEAVE.
END.

IF VALID-HANDLE(hTarget) AND DYNAMIC-FUNCTION('getObjectName':U IN hTaget) = 'bCustomer' THEN
MESSAGE "hTarget now holds the handle of the 'bCustomer' object"
VIEW-AS ALERT-BOX.
ELSE
MESSAGE "No Smart Data Target named 'bCustomer in the target list"
VIEW-AS ALERT-BOX.


References to Written Documentation:

Progress ADM2 Source code in DLC\SRC\ADM2