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