我将3个表传递给IRfcFunction,该函数在SAP上创建订单。
当我尝试调试该程序时,它没有给出任何错误消息,
但这并未在SAP上创建任何订单。

我正在寻找解决该问题的任何帮助或技巧。
感谢您的时间。

IRfcFunction orderDetails = _rfcDest.Repository.CreateFunction(strBapi);

RfcStructureMetadata metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_PART");

IRfcStructure structPartners = metaData.CreateStructure();
            structPartners.SetValue("PARTN_ROLE", "SP");
            structPartners.SetValue("PARTN_NUMB", "110024");

            IRfcTable tblPartner = orderDetails.GetTable("PARTNERS");
            tblPartner.Append(structPartners);

            structPartners = metaData.CreateStructure();
            structPartners.SetValue("PARTN_ROLE", "SH");
            structPartners.SetValue("PARTN_NUMB", "110005");


            tblPartner.Append(structPartners);
            orderDetails.SetValue("PARTNERS", tblPartner);



            metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_COND");
            IRfcStructure structConditions = metaData.CreateStructure();
            structConditions.SetValue("ITM_NUMBER", "10");
            structConditions.SetValue("COND_TYPE", "PR00");
            structConditions.SetValue("COND_VALUE", "30");
            structConditions.SetValue("CURRENCY", "USD");

            IRfcTable tblConditions = orderDetails.GetTable("CONDITIONS");
            tblConditions.Append(structConditions);
            orderDetails.SetValue("CONDITIONS", tblConditions);

            metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_ITEM");
            IRfcStructure structItems = metaData.CreateStructure();
            structItems.SetValue("MATERIAL", "F500");
            structItems.SetValue("TARGET_QTY", "3");

            IRfcTable tblItems = orderDetails.GetTable("ITEMS");
            tblItems.Append(structItems);
            orderDetails.SetValue("ITEMS", tblItems);

            RfcSessionManager.BeginContext(_rfcDest);
            orderDetails.Invoke(_rfcDest);

            IRfcStructure bapiTable = orderDetails.GetStructure("RETURN");

            RfcSessionManager.EndContext(_rfcDest);

最佳答案

IRfcFunction orderDetails = _rfcDest.Repository.CreateFunction(strBapi);

RfcStructureMetadata metaData = _rfcDest.Repository.GetStructureMetadata  ("ZBAPI_A_STRU_ORDER_CREATE_PART");

IRfcStructure structPartners = metaData.CreateStructure();
        structPartners.SetValue("PARTN_ROLE", "SP");
        structPartners.SetValue("PARTN_NUMB", "0011001234");

        IRfcTable tblPartner = orderDetails.GetTable("PARTNERS");
        tblPartner.Append(structPartners);

        structPartners = metaData.CreateStructure();
        structPartners.SetValue("PARTN_ROLE", "SH");
        structPartners.SetValue("PARTN_NUMB", "0011567890");


        tblPartner.Append(structPartners);
        orderDetails.SetValue("PARTNERS", tblPartner);



        metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_COND");
        IRfcStructure structConditions = metaData.CreateStructure();
        structConditions.SetValue("ITM_NUMBER", "10");
        structConditions.SetValue("COND_TYPE", "PR00");
        structConditions.SetValue("COND_VALUE", "30");
        structConditions.SetValue("CURRENCY", "USD");

        IRfcTable tblConditions = orderDetails.GetTable("CONDITIONS");
        tblConditions.Append(structConditions);
        orderDetails.SetValue("CONDITIONS", tblConditions);

        metaData = _rfcDest.Repository.GetStructureMetadata("ZBAPI_A_STRU_ORDER_CREATE_ITEM");
        IRfcStructure structItems = metaData.CreateStructure();
        structItems.SetValue("MATERIAL", "F500");
        structItems.SetValue("TARGET_QTY", "3");

        IRfcTable tblItems = orderDetails.GetTable("ITEMS");
        tblItems.Append(structItems);
        orderDetails.SetValue("ITEMS", tblItems);

        RfcSessionManager.BeginContext(_rfcDest);
        orderDetails.Invoke(_rfcDest);

        IRfcStructure bapiTable = orderDetails.GetStructure("RETURN");

        RfcSessionManager.EndContext(_rfcDest);

关于c# - 如何使用.Net中的IRFC函数将多个表传递给SAP,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/8157561/

10-13 06:54