Consultor Eletrônico



Kbase P41658: How to access a fields database description from an ADM2 Sma
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/11/2003
Status: Unverified

GOAL:

How to access a fields database description from an ADM2 SmartDataObject application?

GOAL:

How to access a field description from the database meta schema files using ADM2?

GOAL:

A fields database description is not included as a property of a defined SDO, and it is not an attribute of the RowObject temp tables BUFFER-FIELD object handle. Therefore in order to access this data from a SmartDataObject, the RowObject temp table BUFFER-FIELD PRIVATE-DATA attribute can be used to store the description. The PRIVATE-DATA attribute can then be accessed from a visual object.

FACT(s) (Environment):

Progress 9.x

FIX:

As an example, this code (using the Sports2000.vacation table) is placed in an override of the SDO InitializeObject procedure, and it retrieves the description from the database for each field in the SDO. It then stores this in the BUFFER-FIELD object PRIVATE-DATA attribute. i.e.

RUN SUPER.
/* Code placed here will execute AFTER standard behavior. */
DEFINE VARIABLE cFields AS CHARACTER NO-UNDO.
DEFINE VARIABLE cField AS CHARACTER NO-UNDO.
DEFINE VARIABLE i AS INTEGER NO-UNDO.
DEFINE VARIABLE hRowObject AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.

cFields = DYNAMIC-FUNCTION('getDataColumns':U).
hRowObject = DYNAMIC-FUNCTION('getRowObject':U).
FIND FIRST _file WHERE
_file._file-name = "vacation" NO-LOCK NO-ERROR.

DO i = 1 TO NUM-ENTRIES(cFields):
cField = ENTRY(i, cFields).
FIND FIRST _field WHERE
_field._file-recid = RECID(_file) AND
_field._field-name = cField NO-LOCK NO-ERROR.

IF AVAILABLE(_file) AND AVAILABLE(_field) THEN
DO:
IF VALID-HANDLE(hRowObject) THEN
hField = hRowObject:BUFFER-FIELD(cField).
ELSE
hField = ?.
IF VALID-HANDLE(hField) THEN
DO:
hField:PRIVATE-DATA = _field._desc.
END.
END.
END.
END PROCEDURE.

In a SmartDataViewer the description can then be accessed via the same BUFFER-FIELD object PRIVATE-DATA attribute. i.e.

DEFINE VARIABLE hRowObject AS HANDLE NO-UNDO.
DEFINE VARIABLE hField AS HANDLE NO-UNDO.
DEFINE VARIABLE cField AS CHARACTER NO-UNDO.
DEFINE VARIABLE h_SDO AS HANDLE NO-UNDO.

{get datasource h_SDO}.

cField = 'StartDate'.
hRowObject = DYNAMIC-FUNCTION('getRowObject':U IN h_SDO).

IF VALID-HANDLE(hRowObject) THEN
hField = hRowObject:BUFFER-FIELD(cField).

MESSAGE hField:PRIVATE-DATA VIEW-AS ALERT-BOX.