Skip to Content

Selecting a SAP Server at Runtime for JCo Based Application

In one of my recent projects we had an requirement for selecting a SAP Server at runtime. The older system being built in Visual Basic provided the flexibility of choosing the servers with the help of BAPI ActiveX objects. Currently, migrating to web based application (Lotus Domino), they prefered the same kind of functionality. This being very unique, we developed an alternative method to achieve the same. This weblog explains the same with a sample codes and screen shots which will make it more meaningful. The Login screen had a look as shown below,

image

In Visual Basic we can use the BAPI ActiveX Component to access SAP and perform the required operations. Further it also provided the chance to select a Server at runtime. Please refer the below VB code which will display a SAP logon Pad at runtime.

image

Now let us see how the same can be achieved using Java. The details that are displayed in SAP Logon Pad are available in C:\WINNT\saplogon.ini file.

image

Now we must read the required parameters from this file. I wrote a java code that will perfrom the required operation. For the readers reference a similar type of java code is given below.

The code performs the extraction of required details in saplogon.ini file and prompts for a choice of server. The sample code above just implements the following steps,
1. Read Details from saplogon.ini file
2. Extract the Server entry details
3. Get the choice of Server from user to establish a connection
4. Establishes a connection to the server using JCo.

Note: I did not perform much of the code optimization as it was just to explain the logic, i leave it in your hands to take it from here.

The result of the program is given below.

image

Thus simple way to achieve the Server selection functionality at runtime using java. Hope this was useful to you.

To report this post you need to login first.

Be the first to leave a comment

You must be Logged on to comment or reply to a post.

Leave a Reply