获取错误 - 使用目标配置在动态连接到 SAP 服务器时不允许硬编码登录参数
您可以尝试下面的示例代码。我建议您尝试使用这个
public class Program {
static void Main(string[] args) {
SapConnection con = new SapConnection();
RfcDestinationManager.RegisterDestinationConfiguration(con);
RfcDestination dest = RfcDestinationManager.GetDestination("NSP");
RfcRepository repo = dest.Repository;
IRfcFunction fReadTable = repo.CreateFunction("ZSOMA");
fReadTable.SetValue("I_NRO1", 1);
fReadTable.SetValue("I_NRO2", 2);
fReadTable.Invoke(dest);
var result = fReadTable.GetValue("E_RESULT");
Console.WriteLine(result.ToString());
Console.ReadLine();
}
}
public class SapConnection : IDestinationConfiguration {
public RfcConfigParameters GetParameters(string destinationName) {
RfcConfigParameters conf = new RfcConfigParameters();
if (destinationName == "NSP") {
conf.Add(RfcConfigParameters.AppServerHost, "sap-vm");
conf.Add(RfcConfigParameters.SystemNumber, "00");
conf.Add(RfcConfigParameters.SystemID, "xxx");
conf.Add(RfcConfigParameters.User, "yourusername");
conf.Add(RfcConfigParameters.Password, "yourpassword");
conf.Add(RfcConfigParameters.Client, "001");
}
return conf;
}
public bool ChangeEventsSupported() {
return true;
}
public event RfcDestinationManager.ConfigurationChangeHandler ConfigurationChanged;
}您可以参考以下 SAP 链接 -
https://archive.sap.com/discussions/thread/3171324

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP