Setting Up and Starting a Session 

Purpose

If you only need a single connection to R/3, use the SessionManager object to handle that connection.

The SessionManager object uses system properties, the SessionInfo object, and the r3_connection.props properties file to obtain information it needs for the connection.

To enable the SessionManager to handle the connection, you must set up the various connection properties of the SessionInfo object.

Process Flow

  1. Obtain the SessionManager object.
  2. Set the connection properties of SessionInfo.
  3. You can set the information in SessionInfo using one of the following two methods:

    Manually setting the properties of SessionInfo

    Storing the information in the r3_connection.props properties file and then letting the SessionManager take care of filling the information into SessionInfo.

    Using a properties file for connection information simplifies the code you need to write for establishing a connection.

    You can override or change any of the properties in SessionInfo that were taken from the properties file.

    Follow the links above to see the detailed procedure and examples of using each of these methods of setting the properties of SessionInfo.

  4. Use the open method of SessionManager to start a session.
  5. You can now set up the IRfcModule object and its parameters, and then call the function module.
  6. After calling the function module, you can close the connection.

The following diagram summarizes this process.

Result

If you the r3_connection.props properties file exists, then the SessionManager reads its information to set SessionInfo. You can modify this information.

SessionManager starts a connection using the information in SessionInfo.

If the connection is established successfully, the SessionManager then re-writes the contents of the properties file. To enable this update, make sure that the properties file is write-enabled.

However, the SessionManager never writes password information into the properties file. If you have password information in this properties file, it will no longer exist after the first connection because the SessionManager overwrites its contents. If you wish to preserve the password in the properties file, then make the file read-only. Note that setting the properties file to read-only does not result in an exception.

If there is no r3_connection.props properties file, the SessionManager creates it in the default directory (user.home/sap/user.name/) and it fills it with the information from SessionInfo.

See Also

If you wish to use multiple connections, you use IRfcConnection objects for each of the connections, and you use the FactoryManager instead of the SessionManager to create objects. See the topic Programming Multiple Connections for details.