public static DataTable Query(SapParameters sap) { DataTable dt = new DataTable(); try { RfcDestination rfc = sap.ServerHost; rfc.Ping(); RfcRepository repo = rfc.Repository; IRfcFunction function = repo.CreateFunction(sap.FunctionName); foreach (KeyValuePair <string, string> keyValuePair in sap.Parameter) { function.SetValue(keyValuePair.Key, keyValuePair.Value); } function.Invoke(rfc); IRfcTable rfcTable = function.GetTable(sap.TableName); dt = GetDataTableFromRFCTable(rfcTable); _isConnec = true; } catch (System.Exception ex) { _isConnec = false; logeer.InfoFormat("{0}", ex.Message); } return(dt); }
public static SapParameters Setting(string destinationsName, string functionName, string tableName, Dictionary <string, string> parameter) { SapParameters sap = new SapParameters(); sap.Parameter = parameter; sap.TableName = tableName; sap.FunctionName = functionName; sap.ServerHost = RfcDestinationManager.GetDestination(destinationsName); return(sap); }