Try OpenEdge Now
skip to main content
Application Migration and Development Guide
Application Development with PAS for OpenEdge : Programming ABL Client Applications : Managing asynchronous requests : Handling the response from an asynchronous request : Obtaining parameter values
 
Obtaining parameter values
As explained earlier, the values returned for OUTPUT or INPUT-OUTPUT parameters on an asynchronous remote procedure are not returned to the RUN statement as for a synchronous remote procedure. Instead, they are returned in the corresponding INPUT parameters of the specified event procedure.
Note that INPUT parameters in an event procedure observe the same rules of definition and scoping as any internal procedure, as shown:
DEFINE VARIABLE hAsync AS HANDLE  NO-UNDO.
DEFINE VARIABLE iCount AS INTEGER NO-UNDO.

DEFINE TEMP-TABLE ttOrder ...

DEFINE BUTTON bCheckOrders.

CREATE SERVER hAppSrv.
hAppSrv:CONNECT(-URL http://slater:OuterLimits64@zeus:8810/inventory/apsv).

RUN order.p ON SERVER hAppSrv ASYNCHRONOUS SET hAsync
  EVENT-PROCEDURE GetOrderRecords IN THIS-PROCEDURE
  (INPUT-OUTPUT TABLE ttOrder, OUTPUT iCount).

DISPLAY iCount. /* Displays 0 */

ON CHOOSE OF bCheckOrders
  IF iCount GT 0 THEN
    MESSAGE "You have" iCount "orders." VIEW-AS ALERT-BOX
  ELSE
    MESSAGE "Orders are pending ..." VIEW-AS ALERT-BOX.
. . .
WAIT-FOR WINDOW-CLOSE OF CURRENT-WINDOW.
PROCEDURE GetOrderRecords:
  DEFINE INPUT PARAMETER TABLE FOR ttOrder.
  DEFINE INPUT PARAMETER piOrderCount AS INTEGER.

  IF SELF:ERROR OR SELF:STOP THEN ... /* Handle condition */
  ELSE iCount = piOrderCount.
  RETURN.
END.
Thus, in this example, the ttOrder temp-table (defined in the outer block) receives its content directly from the ttOrder INPUT parameter of the GetOrderRecords event procedure. However, you must explicitly assign the iCount variable (defined in the outer block) to the piOrderCount parameter in order to make the parameter value available to the outer block. (That is, if you define the INPUT parameter as iCount instead of piOrderCount, ABL does not automatically make the parameter value available as iCount in the outer block. Only the TABLE parameter is scoped to the outer block and thus receives its value from the parameter.)
Note also that the event procedure checks for and handles any unhandled conditions generated from the execution of order.p using the server session error-handling mechanisms.