Click here to Skip to main content
12,999,867 members (56,508 online)
Rate this:
 
Please Sign up or sign in to vote.
I am trying to integrate SAP with a .net web application using SAP nco 3 .net connector. I have successfully connected to the SAP system but when i try to create a sales order in SAP using BAPI "BAPI_SALESORDER_CREATEFROMDAT1" i get the following error: "Please enter sold to party or ship to party". Following is the code snippet I am using:
public class CreateSalesOrder
    {
    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 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 suggest what I am doing wrong in the call. I am properly passing the Partner detalis in the following code snippet:

// Partner
            salesPartnersStruct.SetValue("PARTN_ROLE", "SP");
            salesPartnersStruct.SetValue("PARTN_NUMB", "102003");


Thanks,
Naveed
Posted 25-Apr-13 21:31pm
Updated 21-Aug-16 19:01pm
Comments
Seth Ji 13-Dec-13 3:00am
   
Hi Naveedathar,

If you have got or solve the issue mentioned,
please let me know,
I am also struggling with the same issue.
please reply urgently.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

// Partner
            salesPartnersStruct.SetValue("PARTN_ROLE", "SP");
            salesPartnersStruct.SetValue("PARTN_NUMB", "102003");



replace the above code with
// Partner
salesPartnersStruct.SetValue("PARTN_ROLE", "AG");
salesPartnersStruct.SetValue("PARTN_NUMB", "102003");


It will work.
  Permalink  
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170624.1 | Last Updated 22 Aug 2016
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100