To handle the response from an asynchronous request, you must define an event procedure or an event method. In this context, an event procedure or an event method is an internal procedure or method that executes in response to a PROCEDURE-COMPLETE event. To define an event procedure or method, you must:

  • Specify the name of the event procedure or method using the EVENT-HANDLER option on the RUN...ASYNCHRONOUS statement that executes the request.
  • Define an internal procedure or method with the same name as the event procedure specified in the RUN...ASYNCHRONOUS statement.

Typical places where you might define the specified internal procedure or method include:

  • The same procedure or method context as the RUN...ASYNCHRONOUS statement that specifies the event procedure or method.
  • An external procedure context that you specify using the EVENT-HANDLER option on the RUN...ASYNCHRONOUS statement using its procedure handle. In this case, the external procedure context must be active in the client session before you execute the RUN...ASYNCHRONOUS statement.
  • An external method context that you specify using the EVENT-HANDLER option on the RUN...ASYNCHRONOUS statement using its object instance. In this case, the external object containing the external method context must be active in the client session before you execute the RUN...ASYNCHRONOUS statement.
    Note: You can overload the callback method and the AVM will identify the most appropriate method to run by using the the signature of the method. The signature of the method is determined based on the output and input-output parameters passed to the procedure executed by the RUN statement.

You must define the specified internal procedure or method with INPUT parameters that correspond in type and order to the OUTPUT and INPUT-OUTPUT parameters that you specify on the RUN...ASYNCHRONOUS statement.

To receive results from the asynchronous request in an event procedure or method, you can access:

  • The asynchronous request handle for the request using the SELF system handle
  • The attributes and methods of the ERROR-STATUS system handle to obtain error information from the request
  • Values passed as output parameters from the remote procedure to corresponding input parameters in the event procedure or method
  • The RETURN-VALUE function to get the return value from the request