如何有效地循环调用RFC

2020-09-21 23:23发布

点击此处---> 群内免费提供SAP练习系统(在群公告中)加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)大家好! 我在C#和SAP ...

         点击此处--->   EasySAP.com群内免费提供SAP练习系统(在群公告中)

加入QQ群:457200227(SAP S4 HANA技术交流) 群内免费提供SAP练习系统(在群公告中)


大家好!


我在C#和SAP .NetConnector中使用以下代码来搜索生产订单的某些信息。 我的怀疑是。 如何使其更有效?

公共静态数据集GetOrder()
{
if(!ECCDestinationConfig.conexaoSapInicializada)
{
ECCDestinationConfig cfg = new ECCDestinationConfig();
RfcDestinationManager.RegisterDestinationConfiguration(cfg);
>}
RfcDestination SapRfcDestination = RfcDestinationManager.GetDestination(" PS0");
RfcRepository SapRfcRepository = SapRfcDestination.Repository;

DataSet dsDados = new DataSet();
DataTable dtProdOrdGetDetailGeneral = new DataTable();

IRfcFunction bapiProdOrdGetList = SapRfcRepository.CreateFunction(" BAPI_PRODORD_GET_LIST");

IRfcTable tabSelOrderNumberRange = bapiProdOrdGetList.GetTable(" ORDER_NUMBER_RANGE");
tabSelOrderNumberRange.Append();
tabSelOrderNumberRange.SetValue(" SIGN"," I");
tabSelOrderNumberRange.SetValue(" ," BT");
tabSelOrderNumberRange.SetValue(" LOW"," 000000100000");
tabSelOrderNumberRange.SetValue(" HIGH"," 000000199999");

bapiProdOrdGetList.Invoke(SapRfcDestination);
DataTable dtProdOrdGetList = bapiProdOrdGetList.GetTable(" ORDER_HEADER")。ToDataTable(" dtProdOrdGetList");

//扩展此订单的操作
foreach(dtProdOrdGetList.Rows中的DataRow rowTemp)
{
字符串order = rowTemp [" ORDER_NUMBER"]。ToString();
dtProdOrdGetDetailGeneral.Merge (ExpandOperations(SapRfcDestination,SapRfcRepository,订单));
}
dsDados.Tables.Add(dtProdOrdGetDetailGeneral);
dtListaOrdensFiltradas.Dispose();

return dsDados;
}

私有静态数据表ExpandOperations(RfcDestination _SapRfcDestination,RfcRepository _SapRfcRepository,字符串_order)
{
IRfcFunction bapiProdOrdGetDetail = _SapRfcRepository.CreateFunction(" BAPI_PRODORD_GETS_trus_trus_d ;
structOrderObjects.SetValue(" OPERATIONS"," X");
DataTable dtProdOrdGetDetail = new DataTable();

bapiProdOrdGetDetail.SetValue(" NUMBER",_order);
bapiProdOrdGetDetail.Invoke(_SapRfcDestination);
dtProdOrdGetDetail = bapiProdOrdGetDetail.GetTable(" OPERATION")。ToDataTable(" x");

return dtProdOrdGetDetail;
}