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

Sales Quotation not adding through SDK

Hi.

I am trying to add a sales quotation through SDK but I get an error where the variable ret returns -10. This is for a service quotation.

What am I doing wrong?

try

{

SAPbobsCOM.Documents quotation = (SAPbobsCOM.Documents)SboConnection.Company.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations);

SboConnection.Company.StartTransaction();

// Do the header

quotation.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service;

quotation.CardCode = cardCode;

quotation.DocDate = docDate;

quotation.DocDueDate = docDueDate;

quotation.HandWritten = SAPbobsCOM.BoYesNoEnum.tNO;

// Do the lines

quotation.Lines.ItemDescription= description;

quotation.Lines.LineTotal = total;

quotation.Lines.DiscountPercent = 0;

quotation.Lines.Add();

// Try to add the sales quotation to the database

if (quotation.Lines.Count > 1)

{

int ret = quotation.Add();

if (ret != 0)

{

Regards,

Kinyanjui

Add a comment
10|10000 characters needed characters exceeded

Related questions

2 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 11, 2015 at 06:56 PM

    Hi Kinyanjui,

    For Service Quotation, the Accountcode and Location should be mandatory. Kindly refer this code.

    I hope this will work..


    Sample Code VB.Net:


    Dim oSQ As SAPbobsCOM.Documents

    oSQ = objSBOAPI.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations)

    Dim I As Integer

    oSQ.CardCode = "C000816"

    oSQ.CardName = "050telecom"

    oSQ.DocDate = "12-12-2015"

    oSQ.DocDueDate = "12-12-2015"

    oSQ.TaxDate = "12-12-2015"

    oSQ.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service

    oSQ.Lines.LineTotal = 120

    oSQ.Lines.AccountCode = "200501"

    oSQ.Lines.LocationCode = 1

    oSQ.Lines.Add()

    I = oSQ.Add

    If I <> 0 Then

    objSBOAPI.oCompany.GetLastError(objSBOAPI.oCompany.GetLastErrorCode, objSBOAPI.oCompany.GetLastErrorDescription)

    objSBOAPI.SBO_Appln.MessageBox(objSBOAPI.oCompany.GetLastErrorCode & " - " & objSBOAPI.oCompany.GetLastErrorDescription)

    End If


    Sample Code C#:

    SAPbobsCOM.Documents oSQ = default(SAPbobsCOM.Documents);

    oSQ = objSBOAPI.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oQuotations);

    int I = 0;

    oSQ.CardCode = "C000816";

    oSQ.CardName = "050telecom";

    oSQ.DocDate = "12-12-2015";

    oSQ.DocDueDate = "12-12-2015";

    oSQ.TaxDate = "12-12-2015";

    oSQ.DocType = SAPbobsCOM.BoDocumentTypes.dDocument_Service;

    oSQ.Lines.LineTotal = 120;

    oSQ.Lines.AccountCode = "200501";

    oSQ.Lines.LocationCode = 1;

    oSQ.Lines.Add();

    I = oSQ.Add;

    if (I != 0) {

    objSBOAPI.oCompany.GetLastError(objSBOAPI.oCompany.GetLastErrorCode, objSBOAPI.oCompany.GetLastErrorDescription);

    objSBOAPI.SBO_Appln.MessageBox(objSBOAPI.oCompany.GetLastErrorCode + " - " + objSBOAPI.oCompany.GetLastErrorDescription);

    }

    Thanks

    P.T.Sampath

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 11, 2015 at 07:27 AM

    Hi Kinyanjui,

    For service types, you need the quotation.Lines.AccountCode

    Regards
    Edy

    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.