Try OpenEdge Now
skip to main content
Application Migration and Development Guide
Application Development with PAS for OpenEdge : 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, that passes a class-based object parameter to the PAS for OpenEdge instance identified as hAppSrv. The object rCustObj is an instance of the class myObjs.CustObj, which is created for customer number 101, passed as numeric argument to the constructor. This class 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 rCustObj AS CLASS CustObj.
CREATE SERVER hAppSrv.
lReturn = hAppSrv:CONNECT("-URL http://slater:OuterLimits64@zeus:8810/inventory/apsv",
                          "SMITH", "StarShip90").
IF NOT lReturn THEN DO:
  DELETE OBJECT hAppSrv NO-ERROR.
  RETURN ERROR "Failed to connect to server".
END.
IF ERROR-STATUS:ERROR THEN DO:
  DELETE OBJECT hAppSrv NO-ERROR.
  RETURN ERROR RETURN-VALUE.
END.
. . .
rCustObj = NEW CustObj(101).
rCustObj:CustCredit = 0.
RUN updatecredit.p ON hAppSrv (INPUT-OUTPUT rCustObj).
rCustObj: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 rCustObj:CustCredit is initialized with 0. When the RUN statement is executed, a remote procedure request to run updatecredit.p is sent to the PAS for OpenEdge instance that is connected to 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.