cancel
Showing results for 
Search instead for 
Did you mean: 

Sales Quotation not adding through SDK

kinyanjui_kamau
Participant
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Answers (1)

Answers (1)

edy_simon
Active Contributor
0 Kudos

Hi Kinyanjui,

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

Regards
Edy