使用C#

时间:2016-01-07 13:05:21

标签: c# sap sap-connector

我在主窗体中有两个DataGridView,第一个显示来自SAP的数据,另一个显示来自Vertica DB的数据,FM I使用的是RFC_READ_TABLE,但调用此FM时有异常,即如果目标表中的列太多,SAP连接器将返回DATA_BUFFER_EXCEED异常,是否有任何其他FM或方式从SAP无异常地检索数据?
我想出了一个解决方案,是将分割字段分成几个数组并将每个部分数据存储到数据表中,然后合并数据表,但我担心如果行数太大会花费很多时间。

screenshot of the program

here comes my codes:
RfcDestination destination = RfcDestinationManager.GetDestination(cmbAsset.Text);
            readTable = destination.Repository.CreateFunction("RFC_READ_TABLE");
            /*
             * RFC_READ_TABLE will only extract data up to 512 chars per row. 
             * If you load more data, you will get an DATA_BUFFER_EXCEEDED exception.
             */
            readTable.SetValue("query_table", table);
            readTable.SetValue("delimiter", "~");//Assigns the given string value to the element specified by the given name after converting it appropriately. 
            if (tbRowCount.Text.Trim() != string.Empty) readTable.SetValue("rowcount", tbRowCount.Text);
            t = readTable.GetTable("DATA");
            t.Clear();//Removes all rows from this table. 
            t = readTable.GetTable("FIELDS");
            t.Clear();

            if (selectedCols.Trim() != "" )
            {
                string[] field_names = selectedCols.Split(",".ToCharArray());
                if (field_names.Length > 0)
                {
                    t.Append(field_names.Length);
                    int i = 0;
                    foreach (string n in field_names)
                    {
                        t.CurrentIndex = i++;
                        t.SetValue(0, n);
                    }
                } 
            }
            t = readTable.GetTable("OPTIONS");
            t.Clear();
            t.Append(1);//Adds the specified number of rows to this table. 
            t.CurrentIndex = 0;
            t.SetValue(0, filter);//Assigns the given string value to the element specified by the given index after converting it appropriately. 

            try
            {
                readTable.Invoke(destination);
            }
            catch (Exception e)
            {
            }

3 个答案:

答案 0 :(得分:1)

首先,如果你的系统中有BBP_READ_TABLE,你应该使用BBP_READ_TABLE。这个更好的原因很多。但这不是你问题的重点。在RFC_READ_TABLE中,您有两个Imports ROWCOUNT和ROWSKIPS。你必须使用它们。

我建议你在30.000到60.000之间的行数。因此,每次增加ROWSKIPS时都必须多次执行RFC。第一个循环:ROWCOUNT = 30000 AND ROWSKIPS = 0,第二个循环:ROWCOUNT = 30000 AND ROWSKIPS = 30000等等......

使用旧的RFC_READ_TABLE时也要小心浮点字段。表LIPS中有一个。这个RFC有问题。

答案 1 :(得分:0)

使用交易

  

BAPI

按过滤器并设置为全部。 在物流执行下,您将找到交货。 详细信息屏幕显示功能名称。 直接测试它们以找到适合的函数,然后调用该函数而不是RFC_read_tab 例如:

  

BAPI_LIKP_GET_LIST_MSG

答案 2 :(得分:0)

另一种可能性是开发ABAP RFC函数来获取数据(具有可以在一次调用中获得结构化/多表响应的优点,以及这不是标准函数/ BAPI的缺点)

相关问题