developers.de
daenet's .NET Community

Conneting to SAP: SAP Connection string

Damir Dobric Posts

 

Damir@Phone    



My upcoming sessions:

AppFabric Applications at
NRW Conf 2011
09.Sept.2011 Wuppertal

HTML5 widgets in WP7+
Monodroid
Mobility Day
21.Sept.2011 - Zagreb

AppFabric and WCF sessions at
Advanced Developer Conference
26.-27. Oktober 2011 in Frankenthal

AppFabric Applications, queues, topics and more at
Prio Conference
02. - 03. November 2011 in Meistersingerhalle Nürnberg

AppFabric Applications deep dive hosted by
.NET User Group Frankfurt
17.Nov.2011 18.30-22.30 Microsoft - Bad Homburg 

 

 

By connecting to SAP from BizTalk SAP Adapter I was a little confused by choosing of right parameters like: client, system, r3 name, message server etc.

 

This was a reason to dig deeper in the SAPManagementAdapter namespace.  This namespace contains classes responsible for establishing of connection to SAP. Without of any explanation I just posted optimized code, which shows how SAP Connector internally treats some of configuration parameters.

 

private static void connectToSAP()
        {
            try
            {
                string connStr1 = "ASHOST={0} SYSNR={1} CLIENT={2} LANG={3} USER={4} PASSWD={5}";
                string connStr2 = "ASHOST={0} R3NAME={1} CLIENT={2} GROUP={3} USER={4} PASSWD={5}";

                string srvHost = "..";
                string sysNum = "46";
                string client = "100";
                string language = "EN";
              
                string msgSrv = null;
                string logonGroup = null;
                string r3Name = null;

                string userName = "***";
                string pwd = "***";

                string text1 = string.Empty;
                if (srvHost != null)
                {
                    text1 = String.Format(connStr1, srvHost, sysNum, client, language, userName, pwd);
                }
                else
                {
                    if (msgSrv == null)
                    {
                        throw new Exception("Could not for a valid connection string");
                    }

                    text1 = String.Format(connStr2, msgSrv, r3Name, client, logonGroup, userName, pwd);
                }

                SAPConnection connection1 = new SAPConnection(text1);
                connection1.Open();
               
                connection1.Close();
            }
            catch (Exception exception1)
            {
                throw exception1;
            }
        }


Posted Sep 13 2006, 04:59 PM by Damir Dobric
Filed under:

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
daenet GmbH