In the following example, the ABL client procedure, client.p, calls server.p (following) asynchronously on a server. 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 OnProcedureComplete event method defined in the callbackHandlerObj ABL object, which is an instance of the CallbackHandler class. The callbackHandlerObj method displays the customer number. After the callback method executes, the client.p procedure deletes the asynchronous request handle asyncRequest, the server connection handle appserverConnection and the callback method object instance callbackHandlerObj.

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 terminates after executing the callback method registered for the PROCEDURE-COMPLETE event.

client.p


var character customerName = "WILNER".
var handle asyncRequest.
var handle appserverConnection.
var logical lReturn.
var CallbackHandler callbackHandlerObj.                    				
callbackHandlerObj = new CallbackHandler().

create server appserverConnection.
lReturn = appserverConnection:connect("-URL http://localhost:8810/apsv").

run server.p on appserverConnection asynchronous set asyncRequest
event-handler "OnProcedureComplete"  event-handler-context callbackHandlerObj
(input customerName, output customerNum as integer).

wait-for procedure-complete of asyncRequest.

delete object asyncRequest no-error.
appserverConnection:disconnect().
delete object appserverConnection no-error.
delete object callbackHandlerObj.
end.
                    			

server.p


define input parameter customerName as character no-undo.
define output parameter customerNum as integer no-undo.

for first customer where customer.name = customerName no-lock:
	customerNum = customer.cust-num.
end.                    				
                    			

CallbackHandler.cls


class CallbackHandler:
    method public void OnProcedureComplete( customerNum as integer):
        display customerNum.
    end.
end.