In the following example, the ABL client procedure, client.p, calls server.p (following) asynchronously on an AppServer. The server.p procedure returns the customer number corresponding to a customer name provided by client.p.
The client.p procedure blocks and waits for the PROCEDURE-COMPLETE event that triggers execution of the GetCustNum event procedure. The GetCustNum procedure displays the result and deletes the corresponding asynchronous request handle (referenced by the SELF system handle).
In a more typical example, additional event handlers (triggers) would be active for user-interface events, allowing the user of client.p to perform other tasks with the procedure while completion of the request is pending. In this case, the client application blocks immediately after submitting the request to wait for the result and terminate on the PROCEDURE-COMPLETE event.
client.p
DEFINE VARIABLE cCustomer AS CHARACTER NO-UNDO INITIAL "WILNER".
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("-S 5162 -H zeus -AppService Inventory").
RUN server.p ON hServer ASYNCHRONOUS SET hRequest
EVENT-PROCEDURE "GetCustNum"
(INPUT cCustomer, OUTPUT iCustomer AS INTEGER).