我正在尝试使用Microsoft .NET从SAP ECC读取数据。为此,我使用了SAP Connector for Microsoft .NET 3.0以下代码检索数据,我也得到了结果。但是,我发现汇率值如果超过7个字符,则带有*。

        ECCDestinationConfig cfg = new ECCDestinationConfig();

        RfcDestinationManager.RegisterDestinationConfiguration(cfg);

        RfcDestination dest = RfcDestinationManager.GetDestination("mySAPdestination");

        RfcRepository repo = dest.Repository;


        IRfcFunction testfn = repo.CreateFunction("RFC_READ_TABLE");
        testfn.SetValue("QUERY_TABLE", "TCURR");

        // fields will be separated by semicolon
        testfn.SetValue("DELIMITER", ";");

        // Parameter table FIELDS contains the columns you want to receive
        // here we query 3 fields, FCURR, TCURR and UKURS
        IRfcTable fieldsTable = testfn.GetTable("FIELDS");
        fieldsTable.Append();
        fieldsTable.SetValue("FIELDNAME", "FCURR");
        fieldsTable.Append();
        fieldsTable.SetValue("FIELDNAME", "TCURR");
        fieldsTable.Append();
        fieldsTable.SetValue("FIELDNAME", "UKURS");
        fieldsTable.Append();
        fieldsTable.SetValue("FIELDNAME", "GDATU");

        // the table OPTIONS contains the WHERE condition(s) of your query
        // several conditions have to be concatenated in ABAP syntax, for instance with AND or OR
        IRfcTable optsTable = testfn.GetTable("OPTIONS");

        var dateVal = 99999999 - 20190701;
        optsTable.Append();
        optsTable.SetValue("TEXT", "gdatu = '" + dateVal + "' and KURST = 'EURX'");

        testfn.Invoke(dest);


值如下:

c# - 使用RFC_READ_TABLE从TCURR表中读取数据会截断速率值-LMLPHP

如何在没有任何截断的情况下获得全部价值?

最佳答案

您只是遇到了RFC_READ_TABLE的最坏限制。

它的错误是根据内部长度返回字段值并将其截断,而不是使用输出长度。 TCURR-UKURS是长度为9,5的BCD十进制压缩字段(9个字节= 17位数字,包括小数点后的5位数字),输出长度为12。不幸的是,RFC_READ_TABLE输出的结果为9个字符,因此105.48000-的值占用10个字符太长,因此ABAP的默认逻辑是在最左边的字符(*)上设置*5.48000-溢出字符。

您可以在SAP / ABAP端创建另一个启用RFC的功能模块,或者直接访问SAP数据库(连接到SAP服务器的经典RDBMS)。

10-04 23:28
查看更多