You can use remote procedure calls (RPCs) in any application that requires G2 to execute a procedure in another G2 across an ICP interface object. In particular, you can use RPCs for value- and item-passing, and to build interfaces to external devices and database systems. You can also use RPCs to allow G2 Gateway to call procedures in G2 and receive return values.
To create a remote procedure declaration:
Choose KB Workspace > New Definition > remote-procedure-declaration
You complete the remote procedure declaration by stating the name of the procedure you will call from the local KB, but which resides on a remote G2 process. The syntax is:
declare remote remote-procedure-name ( [argument] [,...] ) = (return [,...])
Name-in-remote-system attribute of the remote procedure declaration's attribute table, as shown in this diagram.
![]() |
You can use the
Name-in-remote-system attribute to declare a remote procedure with a different name so that you do not have two procedures with the same name in your local KB. Name-in-remote-system attribute. You will have to edit that attribute directly to change it. Name-in-remote-system attribute of the remote procedure declaration is a case-sensitive string. For example, if the name of the remote procedure is my-proc, and you enter MY-PROC, G2 will be unable to locate the appropriate procedure on the remote system. By default, G2 procedure names are uppercase. Invoking Remote Procedures
You can invoke a remote procedure from the client G2 in one of two ways:
start action with the across g2-to-g2-interface phrase
call statement with the across g2-to-g2-interface phrase
start action for remote procedures in both rules and procedures. When you use start, the client G2 continues to execute the calling rule or procedure. You can use the
call statement only in procedures. When you use call, the client G2 waits until the remote procedure completes before continuing with the calling procedure. It is possible for a
call to a remote procedure to be aborted at the client, for example, when a different branch of a do in parallel statement within a procedure finishes first. In this case, the client procedure continues processing and the remote procedure is aborted.
start remote procedure (argument [,...])
[at priority integer-expression] [after time-interval]
across g2-to-g2 interface
If an error occurs during the execution of the remote procedure after it has started, the server G2 handles the error as if the procedure were called locally. The client G2 does not signal an error. If the remote procedure was called from a higher-level procedure, that procedure continues processing.
[return [,...] =] call remote procedure (argument [, ...] ] )
across g2-to-g2 interface
If an error occurs during the execution of the called remote procedure, the remote procedure is aborted in the server G2 and the error message is propagated back to the client. On the client G2, the procedure that initiated the remote call is aborted and a message is displayed on the client logbook.