Skip to Content
author's profile photo Former Member
Former Member

Error: (-10) In "To Whse" fields

An apology for my English, I'm insert Invoices but in some I get this error:

Error: (-10) In "To Whse" fields

This is part of the code that I use to add and works fine, only in some Invoices does not work.

public static int syncInvoices(DataRow stObject, DataTable stLinesObject)
        {
            oInvoices = (SAPbobsCOM.Documents)(oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices));
            oInvoices.Comments  = stObject["Comments"].ToString();
            oInvoices.DocDate   = new DateTime(Convert.ToInt32(stObject["DocDateAnio"].ToString()), Convert.ToInt32(stObject["DocDateMes"].ToString()), Convert.ToInt32(stObject["DocDateDia"].ToString()));
            oInvoices.NumAtCard = "Fac: " + stObject["NumAtCard"].ToString() +"-"+ stObject["DocDate"].ToString();
            oInvoices.CardCode  = stObject["CardCode"].ToString();

            for (int i=0; i<stLinesObject.Rows.Count; ++i)
            {
                oInvoices.Lines.ItemCode = stLinesObject.Rows<i>["ItemCode"].ToString();
                oInvoices.Lines.Quantity = Convert.ToDouble(stLinesObject.Rows<i>["Quantity"].ToString());
                oInvoices.Lines.UnitPrice = Convert.ToDouble(stLinesObject.Rows<i>["UnitPrice"].ToString());
                oInvoices.Lines.DiscountPercent = Convert.ToDouble(stLinesObject.Rows<i>["DiscountPercent"].ToString());
                oInvoices.Lines.TaxCode = stLinesObject.Rows<i>["TaxCode"].ToString();
                oInvoices.Lines.TaxPercentagePerRow = Convert.ToDouble(stLinesObject.Rows<i>["TaxPercentagePerRow"].ToString());
                oInvoices.Lines.Add();
            }

            int DocNum = 0;
            lRetCode = oInvoices.Add();
            if (lRetCode != 0)
                oCompany.GetLastError(out lErrCode, out sErrMsg);
            else
                DocNum = oInvoices.DocNum;

            return DocNum;
        }

Any ideas why?

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Posted on Oct 08, 2010 at 05:35 AM

    Hi,

    In first view i have doubt that you have to changes in your loop as:

    for (int i=0; i<stLinesObject.Rows.Count; ++i)
                {
                                   If (i > 0) Then
                                         oInvoices.Lines.Add();
                                    End If
                    oInvoices.Lines.ItemCode = stLinesObject.Rows<i>["ItemCode"].ToString();
                    oInvoices.Lines.Quantity = Convert.ToDouble(stLinesObject.Rows<i>["Quantity"].ToString());
                    oInvoices.Lines.UnitPrice = Convert.ToDouble(stLinesObject.Rows<i>["UnitPrice"].ToString());
                    oInvoices.Lines.DiscountPercent = Convert.ToDouble(stLinesObject.Rows<i>["DiscountPercent"].ToString());
                    oInvoices.Lines.TaxCode = stLinesObject.Rows<i>["TaxCode"].ToString();
                    oInvoices.Lines.TaxPercentagePerRow = Convert.ToDouble(stLinesObject.Rows<i>["TaxPercentagePerRow"].ToString());
                  
                }
    

    also try to post with same data you are passing through this code via UI SAP invoice screen and look whether it prompts anything..

    regards:

    Sandy

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 08, 2010 at 08:10 AM

    Hello

    Do you have a default warehouse set for these items you are issuing in the invoice?

    The error messages says, that th warehouse is not defined in the document!

    You may add the warehouse into you code in the document lines, and it will work properly

    oInvoices.Lines.WareHouse= stLinesObject.Rows<i>["Warehouse"].ToString();

    Regards

    János

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Oct 12, 2010 at 04:05 PM

    I found the error, one item was deleted and that sent the error, the weird is that the error didn't say it was a item didn't exist

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.