on 10-25-2010 2:29 PM
Hi all,
I am trying to create an invoice based on a sales order.
I have this code which worked fine in SBO 2007 but now in 8.8 I get -2010 : Internal error
oDoc = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
oDoc.CardCode = sCardcode;
oDoc.Lines.BaseType = 17;
oDoc.Lines.BaseEntry = int.Parse(docentry);
oDoc.Lines.BaseLine = 0;
Can anyone help me with this?
Thanks
Hi,
I have the same problem. Order -> Invoice works in 2007, but in 8.8 not. For me it occures when there is a modification in the order. If I just use a plain order (not modified) it works fine for me. Did you get any solution?
Szilard Pal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gordon,
It is a variable, but that is not the issue I think.
But just in case: here is the complete code
oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
try
{
SAPbobsCOM.Documents oDoc = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
Matrix matrix = Matrix.GetFromUID(pVal.Form, "10");
int rowcount = matrix.Rows.Count;
string prev_docnum = "";
string docnum = "";
string docentry = "";
string cardcode = "";
int retval = 0;
for(int i = 0;i <= rowcount-1;i++)
{
docnum = matrix.GetValue("11", i);
cardcode = matrix.GetValue("10", i);
string regel = matrix.GetValue("12", i);
string itemcode = matrix.GetValue("8", i);
if(prev_docnum != docnum)
{
if(prev_docnum != "")
{
retval = oDoc.Add();
if(retval != 0)
{
int errcode;
string errmsg;
oCompany.GetLastError(out errcode, out errmsg);
StatusBar.WriteError(String.Format("Fout bij verkooporder {0} - {1}: [{2}] {3}",
docnum,
cardcode,
errcode.ToString(),
errmsg));
}
else
{
string newdoc;
oCompany.GetNewObjectCode(out newdoc);
SAPbobsCOM.Recordset oRs = (SAPbobsCOM.Recordset) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
try
{
oRs.DoQuery(String.Format("SELECT DocNum, convert(varchar(8),DocDate,112), CardName FROM OINV WHERE DocEntry = '{0}'", newdoc));
StatusBar.WriteSucess(String.Format("Nieuwe factuur aangemaakt: {0} - {1}",
oRs.Fields.Item(0).Value.ToString(),
oRs.Fields.Item(2).Value.ToString()));
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRs);
oRs = null;
GC.Collect();
}
}
oDoc = null;
oDoc = (SAPbobsCOM.Documents) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
}
// GET DOCENTRY
SAPbobsCOM.Recordset oRsDoc = (SAPbobsCOM.Recordset) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
try
{
oRsDoc.DoQuery(String.Format("SELECT DocEntry FROM ORDR WHERE DocNum = '{0}'", docnum));
docentry = oRsDoc.Fields.Item(0).Value.ToString();
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRsDoc);
oRsDoc = null;
GC.Collect();
}
oDoc.CardCode = cardcode;
oDoc.DocDate = DateTime.Now;
}
oDoc.Lines.BaseType = 17;
oDoc.Lines.BaseEntry = int.Parse(docentry);
oDoc.Lines.BaseLine = int.Parse(regel) - 1;
oDoc.Lines.Add();
oDoc.Lines.SetCurrentLine(int.Parse(regel) - 1);
prev_docnum = docnum;
}
// ADD LAST INVOICE
retval = oDoc.Add();
if(retval != 0)
{
int errcode;
string errmsg;
oCompany.GetLastError(out errcode, out errmsg);
StatusBar.WriteError(String.Format("Fout bij verkooporder {0} - {1}: [{2}] {3}",
docnum,
cardcode,
errcode.ToString(),
errmsg));
}
else
{
string newdoc;
oCompany.GetNewObjectCode(out newdoc);
SAPbobsCOM.Recordset oRs = (SAPbobsCOM.Recordset) oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset);
try
{
oRs.DoQuery(String.Format("SELECT DocNum, convert(varchar(8),DocDate,112), CardName FROM OINV WHERE DocEntry = '{0}'", newdoc));
StatusBar.WriteSucess(String.Format("Nieuwe factuur aangemaakt: {0} - {1}",
oRs.Fields.Item(0).Value.ToString(),
oRs.Fields.Item(2).Value.ToString()));
}
finally
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRs);
oRs = null;
GC.Collect();
}
}
oDoc = null;
}
catch(Exception ex)
{
StatusBar.WriteError(ex.Message);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Gordon,
Thanks for the quick reply...
The small section of code I typed sits in a larger code block.
The variable "docentry" is set for every new found sales order in a grid
Basically what I am trying to do is to capture the "Delivery" button on the pick and pack manager and create not a delivery but an invoice...
Kind regards,
Joeri
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
How do you get Sales Order docentry from this line: oDoc.Lines.BaseEntry = int.Parse(docentry);?
Thanks,
Gordon
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
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.