首页 > 解决方案 > 在 C# 中使用 SAP 中的 BAPI 读取 RFCTable 数据

问题描述

我想在 c# 中从 RFCtable 读取表数据,我能够获取表结构,但我没有获取表中的数据。

下面是代码

                RfcDestinationManager.RegisterDestinationConfiguration(config__);
                RfcDestination prdData = RfcDestinationManager.GetDestination("Vim Analytics");
                RfcRepository repos = prdData.Repository;
                IRfcFunction InvoiceVIMAny = repos.CreateFunction("BAPI NAME");
               
                InvoiceVIMAny.SetValue("I_INVOICE_NO", InvoiceNumber);
                InvoiceVIMAny.SetValue("I_VENDOR_ID", VendorID);
               
                InvoiceVIMAny.Invoke(prdData);
                if (InvoiceVIMAny.ElementCount > 0 && InvoiceVIMAny.ElementCount != null)
                {
                    IRfcTable rfcTable = InvoiceVIMAny.GetTable(0);
                   
                    foreach (IRfcStructure dataRow in rfcTable)
                    {
                        invstatusResp.E_STATUS = dataRow.GetValue("E_STATUS").ToString();
                        invstatusResp.E_DOC_ID = dataRow.GetValue("E_DOC_ID").ToString();
                        invstatusResp.E_PO_NUMBER = dataRow.GetValue("E_PO_NUMBER").ToString();
                        invstatusResp.E_INVOICE = dataRow.GetValue("E_INVOICE").ToString();
                        invstatusResp.E_REASON = dataRow.GetValue("E_REASON").ToString();
                        invstatusResp.E_DOC_DATE = dataRow.GetValue("E_DOC_DATE").ToString();
                        invstatusResp.E_POSTING_DATE = dataRow.GetValue("E_POSTING_DATE").ToString();
                        invstatusResp.E_ENTRY_DATE = dataRow.GetValue("E_ENTRY_DATE").ToString();
                        invstatusResp.E_DUE_DATE = dataRow.GetValue("E_DUE_DATE").ToString();
                        invstatusResp.E_GROSS_AMT = dataRow.GetValue("E_GROSS_AMT").ToString();
                        invstatusResp.E_COMMENTS = dataRow.GetValue("E_COMMENTS").ToString();
                        invstatusResp.E_CUR_ROLE = dataRow.GetValue("E_CUR_ROLE").ToString();
                        listinvstatusResp.Add(invstatusResp);
                    }
                }
                RfcDestinationManager.UnregisterDestinationConfiguration(config__);

标签: c#sap-dotnet-connector

解决方案


推荐阅读