Try OpenEdge Now
skip to main content
Developing AppServer Applications
Programming ABL Client Applications : Running and managing remote procedures : Remote procedure code examples : Example 4: Remote non-persistent procedure with a class-based object as a parameter
 
Example 4: Remote non-persistent procedure with a class-based object as a parameter
This example shows how to run a remote, non-persistent procedure, updatecredit.p, on an AppServer identified as hAppSrv. The TRANSACTION DISTINCT option is used on the RUN statement to specify that the client application's transaction is not propagated to hAppSrv. The object rCreditObj is an instance of class myObjs.CreditObj, which has a public data member CustCredit of type DECIMAL and a public method ShowCustCredit() that displays a message with the value of CustCredit:
USING myObjs.*.
DEFINE VARIABLE hAppSrv AS HANDLE NO-UNDO.
DEFINE VARIABLE lReturn AS LOGICAL NO-UNDO.
DEFINE VARIABLE rCreditObj AS CLASS CreditObj.
CREATE SERVER hAppSrv.
lReturn = hAppSrv:CONNECT("-AppService inventory -S 5162 -H zeus",
                          "SMITH", "STARSHIP").
IF NOT lReturn THEN DO:
  DELETE OBJECT hAppSrv NO-ERROR.
  RETURN ERROR "Failed to connect to AppServer".
END.
IF ERROR-STATUS:ERROR THEN DO:
  DELETE OBJECT hAppSrv NO-ERROR.
  RETURN ERROR RETURN-VALUE.
END.
. . .
rCreditObj:CustCredit = 0.
RUN updatecredit.p ON hAppSrv (INPUT-OUTPUT rCustObj).
rCreditObj:ShowCustCredit().
CATCH eSysError AS Progress.Lang.SysError:
  MESSAGE eSysError:GetMessage(1).
END CATCH.
. . .
FINALLY:
  lReturn = hAppSrv:DISCONNECT().
  DELETE OBJECT hAppSrv NO-ERROR.
END.
The value of rCreditObj:CustCredit is initialized with 0. When the RUN statement is executed, a remote procedure request to run updatecredit.p is sent to the AppServer instance that is connected via the hAppSrv server handle. The object rCustObj is passed as an INPUT-OUTPUT parameter. If the RUN statement completes without error, the ShowCustCredit() method is called on rCustObj, which was updated and returned by updatecredit.p.