 |
 |
 |
Home > Part 2: Specifying parameters using a String array |
 |
|
|
 |
 |
 |
Part 2: Specifying parameters using a String array |
 |
| 15 Jul 2005 |
 |


|
You may have noticed that the number of system parameters that can be passed as single String values to the createClient() method is somewhat limited. Largely, these connections are limited to specifying user ID, password, and the basic parameters to connect to an SAP application server. However, the JCo API allows you to pass over 30 additional system parameters to SAP! So how can you utilize these additional parameters?
The simplest mechanism provided by JCo is to create a two dimensional String array and store a name/value pair as the second dimension. Through this technique, you can effectively specify any and all of the available system parameters directly within the application. Here is the code to call createClient() with a String array:
import com.sap.mw.jco.*;
...
String[][] sapParams = { {"client", "000"}, {"user", "userid"}, {"passwd", "password"},
{"lang", "en"}, {"ashost", "mysaphost"}, {"sysnr", "00"} };
JCO.Client connection = JCO.createClient(sapParams);
...
connection.disconnect();
This is an effective method for passing dynamic values as system parameters to JCo and also allows you to use some of the more advanced user identification techniques (X509 certificates and SAP logon tickets). However, you are still faced with the challenge of maintaining hardcoded system parameters repeatedly throughout your application. A slightly better technique would be to specify these values as public final class variables then construct your String array with both those global values and any dynamic parameters you might require (see Part 1.)

GETTING CONNECTED WITH JCO

Home: Introduction
Part 1: Specifying parameters as single String values
Part 2: Specifying parameters using a String array
Part 3: Specifying parameters using an external properties file
Part 4: Specifying parameters with a custom properties file
Review: Conclusion and more resources
');
// -->

|
 |
|
 |
 |
 |
| TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of . |
|
| | |
All Rights Reserved, , TechTarget |
SearchSAP.com is a search service provided by TechTarget and is completely independent of and not affiliated with SAP AG.
|
|
|
|
|