如何有效地循环调用RFC

2020-09-21 23:23发布

         点击此处--->   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;
}

         点击此处--->   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;
}

付费偷看设置
发送
2条回答
宇峰
1楼 · 2020-09-21 23:31.采纳回答

我无法评论您的C#代码的效率,但是在功能上,您必须调用列表bapi来获取生产订单,然后遍历结果表以为每个细节调用bapi的详细信息(如果要保留) 在SAP标准中。 通过在ABAP中编写自定义包装函数可以提高性能,该函数将在后端执行第二步,并向您返回所有已识别订单的详细信息。 这将大大减少RFC调用的数量,并且在几乎所有情况下都应比每个订单的单个RFC调用产生更好的性能。

亦是此间程序员
2楼-- · 2020-09-21 23:32

谢谢。

一周热门 更多>