Skip to Content
0

Ordered Quantity does not get copied to Invoice by DIAPI

Feb 06, 2017 at 05:29 PM

50

avatar image
Former Member

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;

}

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".

Any body know why this is happening?

Anyhelp will be greatly appreciated.

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers