Click here to Skip to main content
15,886,110 members

SAP .net connector error Please enter sold to party or ship to party

Naveedathar asked:

Open original thread
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:
C#
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:

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


Thanks,
Naveed
Tags: .NET (.NET 3.0), SAP, Integration

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900