locked
SAP .Net integration using SAP .Net connector 3 RRS feed

  • Question

  • User1129265546 posted

    Hi,

    I am trying to integrate SAP with .Net application using SAP .net connector. I want to create a Sales order in SAP. I have successfully connected to SAP but when I try to execute the BAPI "BAPI_SALESORDER_CREATEFROMDAT1" I get the following error:

    "STRUCTURE BAPIRETURN1 { FIELD TYPE=E FIELD ID=VP FIELD NUMBER=112 FIELD MESSAGE=Please enter sold-to party or ship-to party FIELD LOG_NO= FIELD LOG_MSG_NO=000000 FIELD MESSAGE_V1= FIELD MESSAGE_V2= FIELD MESSAGE_V3= FIELD MESSAGE_V4= }"

    Following is the code snippet I am using :

    public string  CreateOrder(RfcDestination destination)
            {
                try
                {
                    RfcRepository repo = destination.Repository;
                    IRfcFunction salesDoc = repo.CreateFunction("BAPI_SALESORDER_CREATEFROMDAT1");
                    IRfcFunction salesDocCommit = repo.CreateFunction("BAPI_TRANSACTION_COMMIT");

                    IRfcStructure salesHeader = salesDoc.GetStructure("ORDER_HEADER_IN");

                    IRfcTable salesItems = salesDoc.GetTable("ORDER_ITEMS_IN");
                    IRfcTable salesPartners = salesDoc.GetTable("ORDER_PARTNERS");

                    IRfcStructure soldtoparty = salesDoc.GetStructure("SOLD_TO_PARTY");
                    
                    IRfcStructure salesItemsStruct = salesItems.Metadata.LineType.CreateStructure();
                    IRfcStructure salesPartnersStruct = salesPartners.Metadata.LineType.CreateStructure();
                    IRfcStructure salesPartnersStructRow2 = salesPartners.Metadata.LineType.CreateStructure();

                    //Sales Header
                    salesHeader.SetValue("DOC_TYPE", "ZDLR");
                    salesHeader.SetValue("SALES_ORG", "1000");
                    salesHeader.SetValue("DISTR_CHAN", "00");
                    salesHeader.SetValue("DIVISION", "00");
                    salesHeader.SetValue("SALES_OFF", "1001");

                    //Sales Items
                    salesItemsStruct.SetValue("ITM_NUMBER", "323");
                    salesItemsStruct.SetValue("PLANT", "1001");
                    salesItemsStruct.SetValue("MATERIAL", "20000206");
                    salesItemsStruct.SetValue("TARGET_QTY", "200");
                    salesItemsStruct.SetValue("REQ_QTY", "200");
                    
                    // Partner
                    salesPartnersStruct.SetValue("PARTN_ROLE", "SP");
                    salesPartnersStruct.SetValue("PARTN_NUMB", "102003");

                    RfcSessionManager.BeginContext(destination);
                    salesDoc.Invoke(destination);
                    salesDocCommit.Invoke(destination);
                    RfcSessionManager.EndContext(destination);
                    return "";
                }

                catch (RfcCommunicationException e)
                {
                    return e.ToString();
                    
                }
                catch (RfcLogonException e)
                {
                    // user could not logon...
                    return e.ToString();
                }
                catch (RfcAbapRuntimeException e)
                {
                    // serious problem on ABAP system side...
                    return e.ToString();
                }
                catch (RfcAbapBaseException e)
                {
                    return e.ToString();
                    // The function module returned an ABAP exception, an ABAP message
                    // or an ABAP class-based exception...
                }

            }

    Please help me resolve this, is there any thing I am missing or anything wrong with my call to BAPI. Any suggestions or solutions will be highly appreciated.

    Thanks..

    Sunday, April 28, 2013 1:47 AM

All replies

  • User-1115607189 posted

    Hi,

    Have you got any solution for this...?

    I am also struggling with this problem, please post ur suggestion.

    Thanks,

    Tuesday, December 10, 2013 10:37 PM
  • User-1623675128 posted

    interaction between SAP and .NET apps with .NET connector may be old idea..tommorrow you may have other apps with other tech then anther type of comunicatinon?

    we had such scenario but replaced with PI Web Services from SAP and its being used by multiple type of apps like .NET or Teradata. (earlier we had .NET connector)

    just a thought....

    Wednesday, December 11, 2013 9:28 AM
  • User-1067017023 posted

    I am trying to integrate SAP with .Net application using SAP .net connector.

    I would suggest you post your question on SAP's forum (scn.sap.com) you might get better help there, because the SAP .NET connector is a component developed by SAP, not Microsoft

    Thursday, December 12, 2013 4:44 AM