The following sample code shows how to run a procedure asynchronously on an AppServer:
ABL client
/* client.p */
DEFINE VARIABLE cCustomer AS CHARACTER NO-UNDO INITIAL "Lift Tours".
DEFINE VARIABLE hRequest AS HANDLE NO-UNDO.
DEFINE VARIABLE hServer AS HANDLE NO-UNDO.
DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO.
CREATE SERVER hServer.
lReturn = hServer:CONNECT("-URL http://MyHostname/inventory/apsv").
RUN server.p ON hServer ASYNCHRONOUS SET hRequest
EVENT-PROCEDURE "GetCustNum"
(INPUT cCustomer, OUTPUT iCustomer AS INTEGER).
MESSAGE "Amount of outstanding asynchronous requests: " hRequest:ASYNC-REQUEST-COUNT
VIEW-AS ALERT-BOX.
WAIT-FOR PROCEDURE-COMPLETE OF hRequest.
MESSAGE "Amount of outstanding asynchronous requests: " hRequest:ASYNC-REQUEST-COUNT
VIEW-AS ALERT-BOX.
DELETE OBJECT hRequest NO-ERROR.
hServer:DISCONNECT().
DELETE OBJECT hServer NO-ERROR.
PROCEDURE GetCustNum:
DEFINE INPUT PARAMETER piCustomer AS INTEGER NO-UNDO.
IF hServer:ERROR OR hServer:STOP THEN
MESSAGE "An error occurred while retrieving the customer number for " cCustomer "." SKIP
"The error is: " ERROR-STATUS:GET-MESSAGE(1)
VIEW-AS ALERT-BOX.
ELSE
MESSAGE "The customer number for " cCustomer " is: " piCustomer
VIEW-AS ALERT-BOX.
END.
AppServer
/* server.p */
DEFINE INPUT PARAMETER pcCustomer AS CHARACTER NO-UNDO.
DEFINE OUTPUT PARAMETER piCustomer AS INTEGER NO-UNDO.
/* Requires a connection to the Sports2000 database from PASOE or Classic AppServer */
FOR FIRST customer WHERE customer.name = pcCustomer NO-LOCK:
piCustomer = customer.custnum.
END.
NoteWhen an asynchronous request completes execution on the server, it sends a response to the client, which places it on the response queue for the appropriate server handle. To signify that the response is ready to be processed, the PROCEDURE-COMPLETE event is placed on the event queue where it can be processed in the context of blocking I/O statements, such as WAIT-FOR or the PROCESS EVENTS statement.