Consultor Eletrônico



Kbase P10585: 4GL sample code to run a procedure asynchronously on an AppServer
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   10/15/2008
Status: Verified

GOAL:

4GL sample code to run a procedure asynchronously on an AppServer

FIX:

The following sample code is taken from the Progress 9.x documentation and shows how to run a procedure asynchronously on an AppServer:

/* r-async.p */

DEFINE INPUT PARAMETER invDate AS DATE NO-UNDO.

DEFINE VARIABLE sh AS HANDLE NO-UNDO. /* Server handle */
DEFINE VARIABLE ah AS HANDLE NO-UNDO. /* Asynchronous request handle */

CREATE SERVER sh.

sh:CONNECT("-AppService Inventory -H myhost").

RUN runReport.p ON SERVER sh
ASYNCHRONOUS SET ah
EVENT-PROCEDURE "reportDone" IN THIS-PROCEDURE (invDate, OUTPUT numLines AS INTEGER).

RETURN.

PROCEDURE reportDone:
DEFINE INPUT PARAMETER numLines AS INTEGER NO-UNDO.

IF ah:ERROR OR ah:STOP THEN
MESSAGE "An error occurred when running your" SKIP
"Inventory report for " invDate "." SKIP
"The error is: " ERROR-STATUS:GET-MESSAGE(1)
VIEW-AS ALERT-BOX.
ELSE
MESSAGE "Your Inventory report for " invDate SKIP
"has completed successfully." SKIP
numLines " report lines were generated"
VIEW-AS ALERT-BOX.

sh:DISCONNECT().

DELETE OBJECT sh.
DELETE OBJECT THIS-PROCEDURE. /* Persistent proc no longer needed */
END.