Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## Making a call to an AppServer

> The code next checks the toggle box in the window that signals whether to retrieve the temp-table data from a separate AppServer session. A discussion of the details of how to use the OpenEdge AppServer is beyond the scope of this book, but this one example gives you a flavor of how straightforward it is to separate your client session from an AppServer session on another machine where the database is connected.

> If the AppServer toggle box is set, the procedure creates an AppServer object, which has a handle like any other Progress object, and uses it to connect to the AppServer:

>     CREATE SERVER hAppServer.
>     lAns = hAppServer:CONNECT("-H localhost -S 5162 -AppService asbroker1").

> The local hostname, server port number, and AppService name that are the parameters to the `CONNECT` method are the defaults for connecting to a local AppServer session for testing purposes.

> If the AppServer flag was not set, then the procedure sets the `h`AppServer variable to be the handle of the local session:

>     /* Otherwise set the AppServer handle to be the SESSION handle */
>       ELSE
>         hAppServer = SESSION:HANDLE.

> This signals OpenEdge that there is no AppServer running, but that all requests to this AppServer handle should just be run within the local session.

> Then any `RUN` statement, such as the following, can run a procedure `ON SERVER h`AppServer and have it run identically, whether there is really a separate AppServer session or not:

>     RUN h-gettemptable.p  ON SERVER hAppServer
>      (cTables, cForEach, cFields, cTableName, iRows, OUTPUT TABLE-HANDLE hTable).

> As you can see, running a procedure on an AppServer is just like running it within your session, except for the `ON SERVER` syntax. Even with this syntax, you can run the same procedure locally with no change to your code whatsoever, just by using `SESSION:HANDLE` as the alternative value for the server handle.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095