简体   繁体   English

sapnco 多连接问题,创建 function 后一次登录调用调用后再次调用

[英]sapnco multiple connections issue, one login after create function call one again after invoke call

I'm trying to achieve the following, but with using only one connection so as to avoid breaking the sap license where you're only allowed to have the same user logged on once.我正在尝试实现以下目标,但只使用一个连接,以避免破坏 sap 许可证,您只能让同一用户登录一次。

I'm using the sapnco.dll and sapnco_util.dll version 3.0.我正在使用 sapnco.dll 和 sapnco_util.dll 3.0 版。

The following code shows the issue.以下代码显示了该问题。 Two connections get generated.生成两个连接。 One when the call to CreateFunction is made and another one when the Invoke call is made.一种是在调用 CreateFunction 时,另一种是在调用 Invoke 时。

RfcDestinationManager.RegisterDestinationConfiguration(new SapConnection("test"));
        ExampleSessionProvider sessionProvider = new ExampleSessionProvider();
        sessionProvider.SetSession(sessionProvider.CreateSession());
        RfcSessionManager.RegisterSessionProvider(sessionProvider);

StringBuilder result = new StringBuilder();

        var destination = RfcDestinationManager.GetDestination("test");
        RfcSessionManager.BeginContext(destination);
        var function = destination.Repository.CreateFunction("Z_PKUK01_ZDC_ENGINE_CALLH");
        var requestTable = function.GetTable("ITAB_REQUEST");
        requestTable.Append();
        requestTable.SetValue("LINE", "TestMessage");
        function.Invoke(destination);
        RfcSessionManager.EndContext(destination);
        var responseTable = function.GetTable("OTAB_RESPONSE");
        var row = responseTable.CurrentRow;
        var rowval = row.GetValue("LINE").ToString();
        result.Append(row.GetValue("LINE").ToString()
            .Substring(0, Math.Min(rowval.Length, result.Capacity)));

SAP NCo will always use different pools for repository calls and business application calls. SAP NCo 将始终为存储库调用和业务应用程序调用使用不同的池。 That means it will need at least 2 connections if you are working with a standard dynamic repository.这意味着如果您使用标准动态存储库,它将需要至少 2 个连接。 I am wondering if this would really break your SAP license as this is the recommended and standard way of using the SAP .NET Connector.我想知道这是否真的会破坏您的 SAP 许可证,因为这是使用 SAP .NET 连接器的推荐和标准方式。 Are you sure about this?你确定吗?

However, the repository connection won't be needed anymore after all RFC meta data have been queried.但是,在查询完所有 RFC 元数据后,将不再需要存储库连接。 So it will be closed soon afterwards and never reopened again if you don't need further meta data.因此,如果您不需要更多元数据,它将很快关闭,并且永远不会再次重新打开。 So you can wait until the repository pool closes the connection with defining a short ConnectionIdleTimeout - ideally via a separate destination configuration only used for repository meta data queries.因此,您可以等到存储库池关闭连接并定义一个短的ConnectionIdleTimeout - 理想情况下,通过仅用于存储库元数据查询的单独目标配置。 Or - after having obtained the RfcRepository instance and the IRfcFunction object - you actively delete the repository destination via IDestinationConfiguration.ConfigurationChanged event which should also close all pooled connections immediately.或者 - 在获得RfcRepository实例和IRfcFunction object 之后 - 您通过IDestinationConfiguration.ConfigurationChanged事件主动删除存储库目标,该事件也应该立即关闭所有池连接。 Alternatively, you can also work with a static RfcCustomRepository and serialized/stored meta data where no connection for retrieving the RFC meta data would be required at all.或者,您也可以使用 static RfcCustomRepository和序列化/存储的元数据,其中根本不需要用于检索 RFC 元数据的连接。 But this approach has the disadvantage not to be so flexible anymore against function interface modifications at ABAP system side.但是这种方法的缺点是对 ABAP 系统端的 function 接口修改不再那么灵活。

But again: I doubt that your standard approach would really violate the SAP license.但同样:我怀疑您的标准方法是否真的违反了 SAP 许可证。 However, I am also no lawyer.不过,我也不是律师。

PS: Your declaration of a stateful call context is superfluous in your example and should be avoided if not really needed. PS:在您的示例中,您对有状态调用上下文的声明是多余的,如果不是真的需要,应该避免使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM