Kbase P52524: How to populate a SmartDataObject (SDO) based on a Temp Tabl
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  22/03/2004 |
|
Status: Unverified
GOAL:
How to populate a SmartDataObject (SDO) based on a Temp Table, on an Appserver.
GOAL:
How to populate a SmartDataObject based on a Temp table using a Plipp.
FACT(s) (Environment):
Dynamics 2.0A
FACT(s) (Environment):
Dynamics 2.1A
FIX:
This example uses a plipp to populate an SDO's temp table that is running on an Appserver.
1. Create a static SDO based on a temp table (ttCustomer) from the Sports2000 customer table.
2. Create a static SDB and SDV based on this temp table.
3. Create an independent window with the static objects and link accordingly.
4. Create a button on the SDV and add the following code behind it:
DEFINE VARIABLE h_SDO AS HANDLE NO-UNDO.
{get DataSource h_SDO}.
RUN Populate IN h_SDO.
5. Create and internal procedure in the SDO called 'populate' without DB-REQUIRED set. Add the following code:
/* Populate */
DEFINE VARIABLE cASDivision AS CHARACTER NO-UNDO.
{get ASDivision cASDivision}.
IF cASDivision = "Client" THEN
DO:
/* Client Proxy */
RUN populate IN DYNAMIC-FUNCTION('getASHandle':U IN TARGET-PROCEDURE).
END.
ELSE IF cASDivision = "server" THEN
DO:
/* SDO Server side code */
{&DB-REQUIRED-START}
RUN SDOTTFill IN TARGET-PROCEDURE.
{&DB-REQUIRED-END}
END.
ELSE
DO:
/* SDO running fully on client */
{&DB-REQUIRED-START}
RUN SDOTTFill IN TARGET-PROCEDURE.
{&DB-REQUIRED-END}
END.
DYNAMIC-FUNCTION('openquery':U IN TARGET-PROCEDURE).
END PROCEDURE.
6. Create and internal procedure in the SDO called 'SDOTTFill' without DB-REQUIRED set. Add the following code:
/* SDOTTFill */
DEF VAR hCustomerTT AS HANDLE NO-UNDO.
EMPTY TEMP-TABLE ttCustomer.
hCustomerTT = TEMP-TABLE ttCustomer:HANDLE.
{launch.i &PLIP = 'sports/progs/TTplipp.p'
&IProc = 'FillTT'
&PList = "(INPUT-OUTPUT TABLE-HANDLE hCustomerTT)"
&OnApp = 'yes'
&AutoKill = YES
&Perm = NO}
7. Create a new Plipp and add a procedure called 'FillTT' with the following code:
/* Plipp FillTT */
DEFINE INPUT-OUTPUT PARAMETER TABLE-HANDLE h_TTcust.
DEFINE VARIABLE dbh AS HANDLE NO-UNDO.
DEFINE VARIABLE bh AS HANDLE NO-UNDO.
DEFINE VARIABLE q AS HANDLE NO-UNDO.
DEF VAR i AS INTEGER NO-UNDO.
CREATE BUFFER dbh FOR TABLE "customer".
CREATE TEMP-TABLE h_TTcust.
h_TTcust:CREATE-LIKE(dbh).
h_TTcust:TEMP-TABLE-PREPARE("customer").
bh = h_TTcust:DEFAULT-BUFFER-HANDLE.
CREATE QUERY q.
q:SET-BUFFERS(dbh).
q:QUERY-PREPARE("for each customer").
q:QUERY-OPEN.
REPEAT i = 1 TO 10:
q:GET-NEXT.
bh:BUFFER-CREATE.
bh:BUFFER-COPY(dbh).
END.
DELETE OBJECT dbh.
DELETE OBJECT q.
DELETE OBJECT h_TTcust.
END PROCEDURE.