cancel
Showing results for 
Search instead for 
Did you mean: 

JCO.createclient with connection string

Former Member
0 Kudos

Hi folks,

within sap landscapes a connection string can be used to logon to sap systems. The SAP Javagui use such a term to specify the way to sap systems.

An example term for a connection string connecting to an application server behind 2 saprouters is:

/H/gate.acme.com/S/3299/P/secret/H/gate.sap.com/S/3298/H/iwdf8997.sap.com/S/3200

<--


1st router -
><-- 2nd router -


><------ app_server -


>

The second term can be used to connect to a message server and specified logon group (load balancing):

/H/gate.acme.com/S/3299/P/secret/H/gate.sap.com/S/3298/M/alrmain.wdf.sap-ag.de/S/4253/G/SPACE

<--


1st router -
><-- 2nd router -


><----


msg server -


><- logon group->

Now my question:

Is it possible to use complex connection strings (with router and logon groups) with JCO.Client (method createclient)?

I've tried the createclient method with URL parameter and got an Exception "no protocol".

Thanx for Help!

Joerg

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

> Now my question:

>

> Is it possible to use complex connection strings

> (with router and logon groups) with JCO.Client

> (method createclient)?

>

Since I do not at all understand why you are trying to do what you are doing I'll just answer the question above. No. Just for reference here is one of the API specification for createClient. The one with maximum parameters:

public static JCO.Client createClient(java.lang.String client,

java.lang.String user,

java.lang.String passwd,

java.lang.String lang,

java.lang.String ashost,

java.lang.String sysnr,

java.lang.String gwhost,

java.lang.String gwserv)Creates an instance of a client connection to a remote SAP system (no load balancing)

Parameters:

client - SAP logon client

user - SAP logon user

passwd - SAP logon password

lang - SAP logon language

ashost - Host name of the application server

sysnr - SAP system number

gwhost - Host name of the SAP gateway

gwserv - Service number of the SAP gateway

Returns: the newly created client

You have the flexibility of using all of these or a subset of these, as well as, specifying them is a Property object or an array of strings.

Rudy

Former Member
0 Kudos

Hi Rudy,

Thanks for your reply.

The JCo methods supports no createclient with load balancing (message server and logon group) combined with one or more saprouter. Look at your coding --> (no load balancing).

You will found no (official documented) solution for this problem.

But I've found a workaround for this problem:

private static JCO.Client getClient(String user, String password,

String client, String connection, String system, String language) {

String mMsHost = "";

String mSID = "";

String mGroup = "";

try {

// Load Balancing Mode

int mPosM = connection.indexOf("/M");

if (mPosM >= 0) {

// Message Server found

// set SID

mSID = system;

// get Group

int mPosG = connection.indexOf("/G");

if (mPosG < 0) {

System.out

.println("Logon Group is missing. Set it to SPACE");

mGroup = "SPACE";

} else {

mMsHost = connection.substring(0, mPosG);

mGroup = connection.substring(mPosG + 3);

}

// prepare mshost

mMsHost = mMsHost.replaceFirst("/M", "/H");

System.out.println("Using MSHOST SID GROUP: " + mMsHost + " "

+ mSID + " " + mGroup);

// create client

return JCO.createClient(client, // SAP client

user, // userid

password, // password

language, // language

mMsHost, // msg host

mSID, // SID

mGroup); // Group

} else {

// simple Login to App Server

return JCO.createClient(client, // SAP client

user, // userid

password, // password

language, // language

connection, // host name

system); // system number

}

} catch (Exception e) {

System.err.println("Error occured connection to SAP System:\n"

+ e.getMessage());

return null;

}

}

by Joerg

Former Member
0 Kudos

Aha, so you are after load balancing then. Then I think what you want to do is use connection pooling. Take a look at JCO.addClientPool(...) API. An example of how to use it is available in the SAP JCO zip file, in the demo folder. Program name Example2.java.

There are several ways to create a client pool, and you should go through them all to see which one suits you best. I'll include one for you as an example:

public static void addClientPool(java.lang.String key,

int max_connections,

java.lang.String client,

java.lang.String user,

java.lang.String passwd,

java.lang.String lang,

java.lang.String mshost,

java.lang.String r3name,

java.lang.String group)

Creates an instance of a client pool to a remote SAP system (with load balancing).

Note: Depending on the SAP system release, logins using Single-Sign-On (SSO) or X509 certificates are being supported.

For SSO specify the user to be $MYSAPSSO2$ and pass the base64 encoded ticket as as the passwd parameter.

For X509 specify the user to be $X509CERT$ and pass the base64 encoded certificate as the passwd parameter.

Parameters:

key - the name of the pool

max_connections - max. number of connections allowed for the pool.

Important:See also OSS notes 314530 and 316877 on how to setup the number of external connections in the SAP system and/or the SAP gateway.

client - SAP logon client

user - SAP logon user

passwd - SAP logon password

lang - SAP logon language

mshost - Host name of the message server

r3name - Name of the SAP system

group - Name of the group of application servers

Throws:

JCO.Exception - thrown if a pool with the specified name already exists

Good Luck.

Former Member
0 Kudos

Hi Rudy,

Yes - Load Balancing. But not the client based load balancing using JCo-ClientPools or similiar technology.

SAP systems can use more than one application server to process heavy workload. Within the SAP system you can define Logon Groups (Transaction SMLG) to group the available server according to a virtual group (e.g. SALES and SERVICE). The group SPACE is predefined and use all available application servers in one group.

The clientside logon mechanism (SAPGui, JCO) triggers the message server of the whole system (1 message server per sap instance: mshost). This message server routes the logon request to an available application server for the given group with load balancing mechanism (server side load balancing with performance calculating).

For this clientside logon mechanism you have to use the createclient method implementing the parameters mshost, r3name, group.

My problem is, that the message server can located behind one ore more saprouters. Then a direct connection to the message server is not available. The saprouter is comparable to a firewall with forwarding functionality.

Behind the user interfaces for defining sap connections (e.g. JavaGUI - Advanced Options) you will find the typical sap connection string to describe the way to the message server: /H/router1/S/routerport1/H/router2/S/routerport2/M/messageserver/G/logon group.

My given workaround posted in this thread works for 90%.

Thank You.

Joerg

Former Member
0 Kudos

>

> SAP systems can use more than one application server

> to process heavy workload. Within the SAP system you

> can define Logon Groups (Transaction SMLG) to group

> the available server according to a virtual group

> (e.g. SALES and SERVICE). The group SPACE is

> predefined and use all available application servers

> in one group.

Yup both connection types allow you to specify the name of the GROUP of your app servers. Pooled connection and direct connection (i.e. createClient)

> For this clientside logon mechanism you have to use

> the createclient method implementing the parameters

> mshost, r3name, group.

OK so you are using the direct connection instead of pooling.

>

> My problem is, that the message server can located

> behind one ore more saprouters. Then a direct

> connection to the message server is not available.

> The saprouter is comparable to a firewall with

> forwarding functionality.

Well several things jump to my mind here, but most likely you will not want to hear any of them. The situation you describe normally happens when outsiders try to access SAP. Meaning clients that are outside the company network attempt to login to SAP. Which I'm sure would be a security violation within your company. However, if these clients are within your company then it shouldn't be a big problem to allow them to see the app server directly bypassing the routers. Of course, I'm sure I'm missing something here, but this would be the thought process going through my head if I was in your situation.

>

> Behind the user interfaces for defining sap

> connections (e.g. JavaGUI - Advanced Options) you

> will find the typical sap connection string to

> describe the way to the message server:

> /H/router1/S/routerport1/H/router2/S/routerport2/M/mes

> sageserver/G/logon group.

OK this is a long shot but try this parameter jco.client.saplogon_id set to your string. Look at the API documentation for JCO and scroll down to the detailed description of createClient(java.util.Properties properties)

There they describe all the parameters that this call accepts. The description for jco.client.saplogon_id states that it is "String defined for SAPLOGON on 32-bit Windows "

It sounds in the neighborhood but I'm not sure since I've never used it myself.

Good Luck.

Rudy

>

> My given workaround posted in this thread works for

> 90%.

>

> Thank You.

>

> Joerg

Message was edited by:

Rudy Gireyev

Answers (0)