Consultor Eletrônico



Kbase P4551: How to write custom code for distributed SmartDataObjects in
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   8/21/2003
Status: Verified

GOAL:

How to write custom code for distributed SmartDataObjects in ADM2

FIX:

When you create your new procedure or function from within the Section Editor,  the code block is designated as DB Required by default.  Note the toggle box for DB-Required in the upper-right corner of the section editor.

To write your own code blocks that can be deployed on client or server, follow these steps:

1) Create a new or override procedure or function.
2) Uncheck the DB-Required toggle.
3) Write code to manage the database access for different deployment configurations (database on client or server).
4) Wrap any code that requires a database connection in the &DB-REQUIRED-START and &DB-REQUIRED-END preprocessors.

If the SmartDataObject is running on the client with no database connection, then you want to run this procedure explicitly on the Appserver


IF DYNAMIC-FUNCTION('getASDivision':U IN TARGET-PROCEDURE) = "Client" THEN
DO:
   /* Run MyProcedure on the Server */
   {get asHandle hAppHandle TARGET-PROCEDURE}.
   IF VALID-HANDLE(hAppHandle) THEN
       RUN MyProcedure IN hAppHandle(INPUT pCity, OUTPUT TABLE tt-customer).
   RETURN.
END.

If the SmartDataObject is running only on the server side, you do not need the explicit call to the Appserver.  However, you do need to bracket this code with {&DB-REQUIRED-START} and {&DB-REQUIRED-END}.


ELSE
DO:
  {&DB-REQUIRED-START}
    /* code to execute on the server-side SmartDataObject */
 {&DB-REQUIRED-END}
END.