Consultor Eletrônico



Kbase P21707: How to export data from an SDO when the SDO is linked to a SmartDataBrowse
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/16/2008
Status: Unverified

GOAL:

How to export data from an SDO when the SDO is linked to a SmartDataBrowse

FIX:

The problem with an SDO linked to a SmartDataBrowser is that by using functions fetchFirst and fetchNext, rows might not be returned as one would expect.
The only workaround is to add a secondary SDO to the same window where the main SDO is and run the following code (assuming that h_SDO is the handle to the SDO linked to a SmartDataBrowser, and that h_SDO2 is the handle to this new SDO):

DEF VAR r AS CHAR.
DEF VAR q AS CHAR.

/* What is the current query for the "main" SDO ?
This will include any filtering from any SmartFilter. */
ASSIGN q = DYNAMIC-FUNCTION('getQueryWhere':U IN h_SDO).

/* Close query for the "secondary" SDO,
Change its query,
Re-open it. */
DYNAMIC-FUNCTION('closeQuery':U IN h_SDO2).
DYNAMIC-FUNCTION('setQueryWhere':U IN h_SDO2, INPUT q).
DYNAMIC-FUNCTION('openQuery':U IN h_SDO2).

/* Get the records, but using h_SDO2 rather than h_SDO. */
RUN fetchFirst IN h_SDO2.
IF DYNAMIC-FUNCTION('getQueryPosition' IN h_SDO2)
'NoRecordAvailable':U THEN DO WHILE TRUE:

/* Here is where the record can be exported.
In this example, we will simply append the columns values
to a string. */
ASSIGN r = r + DYNAMIC-FUNCTION('colValues':U IN h_SDO2,
'CustNum,Name':U) +
CHR(10).

/* Exit condition. */
IF CAN-DO('OnlyRecord,NoRecordAvailable,LastRecord':U,
DYNAMIC-FUNCTION('getQueryPosition':U IN h_SDO2)) THEN
LEAVE.

RUN fetchNext IN h_SDO2.
END.

/* View both the query from the "main" SDO, and the list of
records extracted from the "secondary" SDO. */
MESSAGE q SKIP r.