SAP server connection using GXEnterpriseSessionManager External Object

Unofficial Content

Before invoking a BAPI via RFC, GeneXus applications must be connected to the SAP server where it is located.

An External Object called GXEnterpriseSessionManager is provided to make the connection.

The first time a BAPI is imported, GeneXus ERP Connector automatically generates this External Object.

GXEnterpriseSessionManager has a Connect method and the following parameters:

UserName Char(40) SAP user to be used in the connection
Password Char(40) User's password
InstanceNumber  Char(10) Instance number within the server
AppServer Char(512)  Name of SAP application server to which we will be connecting 
RouterString Char(512) IP of SAP server
ClientNumber Char(10) Number of SAP client
SystemId Char(10) Identifier of the SAP system to be connected
SessionName Char(40) Name that the connection will receive
ErrorCode Num(5.0) Error code when attempting to connect
ErrorMessage Char(255) Error message when attempting to connect


The connection can be made as shown below (&SAPSessionManager is a variable based on GXEnterpriseSessionManager):

&SAPSessionManager.AppServer      = "<SAPServer>"
&SAPSessionManager.ClientNumber   = "<ClientIdNumber>"
&SAPSessionManager.RouterString   = "/H/<RouterString>/S/<Port>/H/"
&SAPSessionManager.SystemId       = "<SystemIdentification>"
&SAPSessionManager.InstanceNumber = "<SystemNumber>"
&SAPSessionManager.SessionName    = "<AnyStirng>"
&SAPSessionManager.UserName       = "<SAPUser>"
&SAPSessionManager.Password       = "<SAPPassword>"

if &SAPSessionManager.ErrorCode.IsEmpty()
  msg('Log in error ' + &SAPSessionManager.ErrorCode.ToString() + ': ' + &SAPSessionManager.ErrorMessage)

This connection option allows changing, at any time during runtime, the user and SAP server used by the application to connect.