cancel
Showing results for 
Search instead for 
Did you mean: 

Ordered Quantity does not get copied to Invoice by DIAPI

Former Member
0 Kudos

Hi All,

I am stuck with an issue in Invoice creation using DI API by code.The field Ordered Qty (DB Filed INV1.OrderedQty) does not gets copied to Invoice line from delivery lines. But while we add invoice from delivery >Copy To> AR Invoice , it gets copied to Invoice lines. This OrderedQty field is not exposed through DI API, so we cant set that field throgh code. What I do in Invoice creation code is as follows.

SAPbobsCOM.Documents oINV;

oINV = (SAPbobsCOM.Documents)

modups.oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);

oINV.CardCode = oDLN.CardCode;

for (int i = 0; i < oDLN.Lines.Count; i++)

{

oDLN.Lines.SetCurrentLine(i);

string str = oDLN.Lines.ItemCode;

if (i != 0)

{

oINV.Lines.Add();

}

//oINV.Lines.ItemCode = oDLN.Lines.ItemCode;

//oINV.Lines.Quantity = oDLN.Lines.Quantity;

oINV.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);

oINV.Lines.BaseEntry = oDLN.DocEntry;

oINV.Lines.BaseLine = oDLN.Lines.LineNum;

taxcode = oDLN.Lines.TaxCode;

}

if (DeliveryExpenseCount > 0)

{

for (int i = 0; i < DeliveryExpenseCount; i++)

{

oDLN.Expenses.SetCurrentLine(i);

if (i != 0)

{

oINV.Expenses.Add();

}

//oINV.Expenses.ExpenseCode=i;

oINV.Expenses.ExpenseCode = oDLN.Expenses.ExpenseCode;

oINV.Expenses.LineTotal = oDLN.Expenses.LineTotal;

oINV.Expenses.TaxCode = oDLN.Expenses.TaxCode;

oINV.Expenses.BaseDocEntry = oDLN.DocEntry;

oINV.Expenses.BaseDocLine = oDLN.Expenses.LineNum;

oINV.Expenses.BaseDocType = 15;

}

}

int retVal = oINV.Add();

if (retVal != 0)

{

int lErrCode; string sErrCode;

modups.oCompany.GetLastError(out lErrCode, out sErrCode);

}

Any help will be appreciated..

Deepesh

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Deepesh,

Try

for (int i = 0; i < oDLN.Lines.Count; i++)

{

oDLN.Lines.SetCurrentLine(i);

oINV.Lines.BaseType = Convert.ToInt32(SAPbobsCOM.BoObjectTypes.oDeliveryNotes);

oINV.Lines.BaseEntry = oDLN.DocEntry;

oINV.Lines.BaseLine = oDLN.Lines.LineNum;

oINV.Lines.Add();

}

Thanks,

Gordon

Former Member
0 Kudos

Hi Gordon,

Thank you for your reply.But it didnt fix the problem.The only change of previous code with this one was oINV.Lines.Add() method is called in the last of the loop.But it wont fix issue.

Former Member
0 Kudos

Hi Gordon,

Thank you for your reply.But it didnt fix the problem.The only change of previous code with this one was oINV.Lines.Add() method is called in the last of the loop.But it wont fix issue.

Updated on 20/10/2011

I have found the issue.The issue is causing if we update the resulting invoice's expense lines.

If we copy the expense lines from delivery and update any line with an amount it works fine and resulting invoice has "Ordered Qty" in its lines. Code is

for (int i = 0; i < DeliveryExpenseCount; i++)

{

oDoc.Expenses.SetCurrentLine(i);

if (i != 0)

{

oINV.Expenses.Add();

}

string s = oDoc.Expenses.TaxCode;

oINV.Expenses.TaxCode = oDoc.Expenses.TaxCode;

oINV.Expenses.BaseDocEntry = oDoc.DocEntry;

oINV.Expenses.BaseDocLine = oDoc.Expenses.LineNum;

oINV.Expenses.BaseDocType = 15;

oINV.Expenses.LineTotal = oDoc.Expenses.LineTotal;

if (radioButton2.Checked == true && i == 0)

{

oINV.Expenses.LineTotal = oDoc.Expenses.LineTotal + Convert.ToDouble(txtExp.Text);

}

}

But if the delivery has no expense lines or we are adding a new expense line to the invoice while invoice creation from delivery , the resulting invoice does not have "Ordered Qty " in its lines..

Code is

if (DeliveryExpenseCount > 0)

{

oINV.Expenses.Add();

}

oINV.Expenses.ExpenseCode = 1;

oINV.Expenses.TaxCode = taxcode;

oINV.Expenses.LineTotal = Convert.ToDouble(txtExp.Text);

If I try to add lines

oINV.Expenses.BaseDocEntry = oDoc.DocEntry;

oINV.Expenses.BaseDocType = 15;

to the above code it may show either "Internal error" or " No matching records found".

Is this a bug in DI API?