PDA调用RFC

原本计划在PDA中直接调用RFC,结果试了半天发现不行。网上寻找发现:

you cannot use .NET Connector from Compact framework as it uses unmananged code that cannot run on a PDA. But you have two alternatives:
If your SAP server is 6.20 or higher, you can use native Soap support with MS "Add web reference" feature. Details about native Soap support can be found in service.sap.com/connectors.

Else you need a "Middleware". The middleware can use the .NET Connector. For communication between the middleware and PDA you can use any protocol of your choice like WebServices or .NET Remoting.

As long as JCo is not fully "pure Java" and uses native methods from a DLL or EXE, it will not work.

 

总部服务器不让开SAP  CONSOLE,只能借助与中间件了..

无线PDA+Web Services+RFC

 

由于SAP.Net Connector 2.0 目前只支持.net framework 1.X,而预定的PDA为WINCE5.0。在网上找到可以用VS2003生成一个DLL,VS2005中调用。

 

最后效果也还不错,只是速度比较慢。太频繁的操作会严重影响性能。

可能只有通过PDA暂存数据、批量传到外挂表、批量执行。但这样如果中间有笔交易出错,如何处理?

SapNwRfc 可用于调用 SAP 系统中的 RFC 接口。以下是关于其使用方法、注意事项及示例代码的介绍。 ### 使用方法 在 VS2022 的 WINFORM 应用程序中,可借助 NuGet 中的 SapNwRfc 类库来调用 SAP 系统的 RFC 接口,调用时需传入相应参数并可获取返回的表数据。使用的前提条件是将 SAP 官方的几个 dll 放到 windows\system32 目录中,若采用 X64 的架构编译,则放置 X64 的 dll 包,SAP 官方下载压缩包名称为 nwrfc750P_17 - 70002755.zip,需将特定文件放入 system32 目录 [^1][^2]。 ### 注意事项 - 要保证 SAP 官方的 dll 正确放置到指定目录,且架构与编译环境相匹配。 - 调用 RFC 时,需准确传入所需的参数,参数数量和类型要与 RFC 接口定义一致。 ### 示例代码 以下是一个简单的 C# 示例代码,展示了如何使用 SapNwRfc 调用 RFC 接口: ```csharp using SAP.Middleware.Connector; class Program { static void Main() { // 创建连接参数 RfcConfigParameters rfcConfig = new RfcConfigParameters(); rfcConfig.Add(RfcConfigParameters.Name, "YourConnectionName"); rfcConfig.Add(RfcConfigParameters.AppServerHost, "YourAppServerHost"); rfcConfig.Add(RfcConfigParameters.SystemNumber, "YourSystemNumber"); rfcConfig.Add(RfcConfigParameters.Client, "YourClient"); rfcConfig.Add(RfcConfigParameters.User, "YourUser"); rfcConfig.Add(RfcConfigParameters.Password, "YourPassword"); // 创建连接 RfcDestination rfcDest = RfcDestinationManager.GetDestination(rfcConfig); // 创建 RFC 函数 IRfcFunction rfcFunction = rfcDest.Repository.CreateFunction("YourRFCName"); // 设置输入参数(假设有 7 个参数) rfcFunction.SetValue("PARAM1", "Value1"); rfcFunction.SetValue("PARAM2", "Value2"); rfcFunction.SetValue("PARAM3", "Value3"); rfcFunction.SetValue("PARAM4", "Value4"); rfcFunction.SetValue("PARAM5", "Value5"); rfcFunction.SetValue("PARAM6", "Value6"); rfcFunction.SetValue("PARAM7", "Value7"); // 调用 RFC rfcFunction.Invoke(rfcDest); // 获取返回的表数据(假设有 2 张表) IRfcTable table1 = rfcFunction.GetTable("TABLE1"); IRfcTable table2 = rfcFunction.GetTable("TABLE2"); // 处理表数据 foreach (IRfcStructure row in table1) { // 处理 table1 的每一行数据 } foreach (IRfcStructure row in table2) { // 处理 table2 的每一行数据 } } } ``` ### 相关问题
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值