Consultor Eletrônico



Kbase P47838: How to dynamically create Dynamic Lookups.
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/14/2003
Status: Unverified

GOAL:

How to dynamically create Dynamic Lookups.

FACT(s) (Environment):

Dynamics 2.0A

FIX:

/*------------------------------------------------------------------------------
Purpose: Create a Dynamic Combo/Lookup
Parameters: <none>
Notes:
------------------------------------------------------------------------------*/

DEFINE VARIABLE cMasterFile AS CHARACTER NO-UNDO.
DEFINE VARIABLE cPropertyList AS CHARACTER NO-UNDO.
DEFINE VARIABLE dRow AS DECIMAL NO-UNDO.
DEFINE VARIABLE dCol AS DECIMAL NO-UNDO.
DEFINE VARIABLE dHeight AS DECIMAL NO-UNDO.
DEFINE VARIABLE dWidth AS DECIMAL NO-UNDO.
DEFINE VARIABLE cObjectType AS CHARACTER NO-UNDO.
DEFINE VARIABLE cButton AS CHARACTER NO-UNDO.

/*** Get the selected object attributes and see whether this is a
DynLookup or DynCombo so we can create it. If it is a DynCombo or
DynLookup we will attempt to create it and put it at C:R 15.00:10.52 with W:H 48.40:1.00.
*/

RUN ObjectAttributes (INPUT gcLogicalObjectName,
OUTPUT cObjectType,
OUTPUT cMasterFile,
OUTPUT cPropertyList).

/*
Get the MasterFile attribute value. This is the base program
from which to start the Dynamic Combo or Dynamic Lookup.
*/

IF INDEX( cMasterFile, "dynlookup" ) = 0 AND
INDEX( cMasterFile, "dyncombo" ) = 0 THEN DO:
cMasterFile = "".
END.

IF cMasterFile = "" THEN DO:
RUN showMessages IN gshSessionManager
(INPUT "The SmartObject specified " + gcLogicalObjectName +
" is not a valid SDF object - valid types are Dynamic
Combo and Dynamic Lookup. " + cObjectType, /* message to display */
INPUT "ERR":U, /* error type */
INPUT "&OK,&Cancel":U, /* button list */
INPUT "&OK":U, /* default button *
INPUT "&Cancel":U, /* cancel button */
INPUT "Not a Valid SDF Object":U, /* error window title */
INPUT NO, /* display if empty */
INPUT ?, /* container handle */
OUTPUT cButton /* button pressed */
).
ghDynamicSDF = ?.
RETURN.
END.

RUN constructObject ( INPUT cMasterFile,
INPUT FRAME {&FRAME-NAME}:HANDLE,
INPUT cPropertyList,
OUTPUT ghDynamicSDF ).

IF VALID-HANDLE( ghDynamicSDF ) THEN DO:
ASSIGN
dRow = fiPlaceHolder:ROW
dCol = fiPlaceHolder:COLUMN
dWidth = fiPlaceHolder:WIDTH-CHARS
dHeight = fiPlaceHolder:HEIGHT-CHARS
.
RUN repositionObject IN ghDynamicSDF ( dRow, dCol ) NO-ERROR.
RUN resizeObject IN ghDynamicSDF ( dHeight, dWidth ) NO-ERROR.
RUN initializeObject IN ghDynamicSDF.

/*
** Get the Dynamic SDF Query so we can send this to the AppServer.
*/

EMPTY TEMP-TABLE ttLookup.
EMPTY TEMP-TABLE ttDCombo.

RUN getComboQuery IN ghDynamicSDF
( INPUT-OUTPUT TABLE ttDCombo ) NO-ERROR.
RUN getLookupQuery IN ghDynamicSDF
( INPUT-OUTPUT TABLE ttLookup ) NO-ERROR.

IF VALID-HANDLE( gshAstraAppserver ) AND
( CAN-FIND( FIRST ttDCombo ) OR
CAN-FIND( FIRST ttLookup )) THEN DO:
RUN adm2/lookupqp.p ON gshAstraAppserver
( INPUT-OUTPUT TABLE ttLookup,
INPUT-OUTPUT TABLE ttDCombo,
INPUT "",
INPUT "",
INPUT THIS-PROCEDURE).
END.

IF CAN-FIND( FIRST ttDCombo ) THEN DO:
RUN displayCombo IN ghDynamicSDF ( INPUT TABLE ttDCombo ).
RUN enableField IN ghDynamicSDF.
END.
ELSE IF CAN-FIND( FIRST ttLookup ) THEN DO:
RUN displayLookup .IN ghDynamicSDF( INPUT TABLE ttLookup ).
RUN enableField IN ghDynamicSDF.
RUN enableButton IN ghDynamicSDF.
END.
END.
ELSE DO:
ghDynamicSDF = ?.
END..