Try OpenEdge Now
skip to main content
Developing AppServer Applications
Programming the AppServer : Accessing the name of the current remote procedure : Accessing a procedure name on the AppServer
 

Accessing a procedure name on the AppServer

You can access the path or filename of a remote procedure running on the AppServer that an ABL client has invoked using the following code fragment:
DEFINE VARIABLE rqInfo AS Progress.Lang.OERequestInfo NO-UNDO.
DEFINE VARIABLE callerProcedureName AS CHARACTER NO-UNDO.
rqInfo = SESSION:CURRENT-REQUEST-INFO.
callerProcedureName = rqInfo:ProcedureName.
Suppose external procedures on the AppServer define at least one of two internal procedures, UsefulRoutine1 and UsefulRoutine2, that implement some logic in two different ways, as in the following external procedure fragment:
/* h-UsefulProc.p -- has an internal procedure others want to find. */
PROCEDURE UsefulRoutine1:
/*Does something useful */
END PROCEDURE.
PROCEDURE UsefulRoutine2:
/*Does something useful in a different way*/
END PROCEDURE.
An ABL client might invoke these internal procedures in persistent procedures currently running on this AppServer as shown in the following client code fragment:
DEFINE VARIABLE happsrv AS HANDLE NO-UNDO.
DEFINE VARIABLE hUseful AS HANDLE NO-UNDO.
DEFINE VARIABLE hProc AS HANDLE NO-UNDO.
CREATE SERVER happsrv.
IF happsrv:CONNECT(" -H localhost -S 3090 -DirectConnect -AppService asbroker1","","") THEN
DO:
  RUN h-UsefulProc.p ON happsrv PERSISTENT SET hUseful.  hProc = happsrv:FIRST-PROCEDURE.
  DO WHILE VALID-HANDLE(hProc):
    IF LOOKUP("UsefulRoutine1", hProc:INTERNAL-ENTRIES) NE 0 THEN
       RUN UsefulRoutine1 IN hProc.    ELSE
      RUN UsefulRoutine2 IN hProc.    hProc = hProc:NEXT-SIBLING.
  END.
  DELETE PROCEDURE hUseful.
  happsrv:DISCONNECT().
END.
ELSE
  MESSAGE "Failed to connect" VIEW-AS ALERT-BOX.
For the client remote request that runs h-UsefulProc.p persistently, the value of the ProcedureName property is "h-UsefulProc.p".
For a client remote request that runs one of the specified internal procedures in hProc when the remote procedure handle refers to any instance of the h-UsefulProc.p persistent procedure currently instantiated on the AppServer, the value of the ProcedureName property is one of the following, depending on the internal procedure that the client is executing:
*"h-UsefulProc.p&UsefulRoutine1"
*"h-UsefulProc.p&UsefulRoutine2"