on 12-11-2015 6:52 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Kinyanjui,
For service types, you need the quotation.Lines.AccountCode
Regards
Edy
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
11 | |
11 | |
6 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.