on 01-29-2008 3:54 PM
Hi,
I'm having a hard time to transfers the Freights of the delivery to the ARInvoice from the DI API
I did try all kind of things from that code :
//---------------------------------------------------------------------------------------------------------------------------
// Seems to work WITH and WITHOUT FREIGHT but I'm not sure of the procedure to do it and on SDN forum there's no explaination
// and the documentation is silent about it :(
//---------------------------------------------------------------------------------------------------------------------------
if (DeliveryDocument.Expenses.ExpenseCode != 0)
{
ARInvoiceDocument.Expenses.ExpenseCode = DeliveryDocument.Expenses.ExpenseCode;
ARInvoiceDocument.Expenses.LineTotal = DeliveryDocument.Expenses.LineTotal;
ARInvoiceDocument.Expenses.TaxCode = DeliveryDocument.Expenses.TaxCode;
}
to that code :
//// Trying to add the Freights rows but getting No matching record found...
//if (DeliveryDocument.Lines.Expenses.Count > 0)
//{
// for (int iFreight = 0; iFreight < DeliveryDocument.Lines.Expenses.Count; iFreight++)
// {
// DeliveryDocument.Lines.Expenses.SetCurrentLine(iFreight);
// ARInvoiceDocument.Lines.Expenses.ExpenseCode = DeliveryDocument.Lines.Expenses.ExpenseCode;
// ARInvoiceDocument.Lines.Expenses.LineTotal = DeliveryDocument.Lines.Expenses.LineTotal;
// ARInvoiceDocument.Lines.Expenses.TaxCode = DeliveryDocument.Lines.Expenses.TaxCode;
// if (iFreight < DeliveryDocument.Lines.Expenses.Count - 1)
// ARInvoiceDocument.Lines.Expenses.Add();
// }
//}
this commented code gives the error : No matching records found
All this to say that I really don't know how to transfers the Expenses from Delivery to AR INvoice
when there are multiple Freight rows
For everything else it works perfectly. I mean, BaseLine, BaseEntry etc..
if I do not play with Freight, the transfers occur perfectly.
Even the first piece of code above works for just 1 Freight
but as soon as there are more then one line in Freights, it is a mystery !
Not that I didn't check in the Documentation, which is very silent about it and on the forum here, well nothing clear about to do it.
Thank you for any help.
Meanwhile, I'm still trying all kind of things.
Found the solution. Check the message above
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok after HOURS of Trying and Errors here's the working solution :
//----------------------------------------
// Additional expenses at the HEADER level
//----------------------------------------
if (DeliveryDocument.Expenses.Count > 0)
{
for (int iFreight = 0; iFreight < DeliveryDocument.Expenses.Count; iFreight++)
{
DeliveryDocument.Expenses.SetCurrentLine(iFreight);
if (DeliveryDocument.Expenses.ExpenseCode != 0)
{
ARInvoiceDocument.Expenses.BaseDocEntry = DeliveryDocument.DocEntry;
ARInvoiceDocument.Expenses.BaseDocType = (int)BoAPARDocumentTypes.bodt_DeliveryNote;
ARInvoiceDocument.Expenses.BaseDocLine = DeliveryDocument.Expenses.LineNum;
ARInvoiceDocument.Expenses.LineTotal = DeliveryDocument.Expenses.LineTotal;
if (iFreight < DeliveryDocument.Expenses.Count - 1)
ARInvoiceDocument.Expenses.Add();
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry
The Expenses are at the HEADER level not at the Lines level
I did try this :
if (DeliveryDocument.Expenses.ExpenseCode != 0)
{
//ARInvoiceDocument.Expenses.ExpenseCode = DeliveryDocument.Expenses.ExpenseCode;
//ARInvoiceDocument.Expenses.LineTotal = DeliveryDocument.Expenses.LineTotal;
//ARInvoiceDocument.Expenses.TaxCode = DeliveryDocument.Expenses.TaxCode;
ARInvoiceDocument.Expenses.BaseDocEntry = DeliveryDocument.DocEntry;
ARInvoiceDocument.Expenses.BaseDocType = (int)BoAPARDocumentTypes.bodt_DeliveryNote;
ARInvoiceDocument.Expenses.BaseDocLine = DeliveryDocument.DocNum;
}
And this gives No matching records found.
and I have 2 Freights. One at 5.00 and one at -5.00
Lets try to make it work for the Header freight. And yet, I've been unsuccessful at transfering the Freights from the Delivery to the ARInvoice.
God this is hard. The documentation is so poor at everything we can do with the DI API !
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ok, iam getting confused. (let's try a dirty code)
you told - this works:
DeliveryDocument.Expenses.SetCurrentLine(0);
ARInvoiceDocument.Expenses.ExpenseCode = DeliveryDocument.Expenses.ExpenseCode;
ARInvoiceDocument.Expenses.LineTotal = DeliveryDocument.Expenses.LineTotal;
ARInvoiceDocument.Expenses.TaxCode = DeliveryDocument.Expenses.TaxCode;
than just add
DeliveryDocument.Expenses.SetCurrentLine(1);
ARInvoiceDocument.Expenses.Add();
ARInvoiceDocument.Expenses.SetCurrentLine(ARInvoiceDocument.Expenses.Count -1);
ARInvoiceDocument.Expenses.ExpenseCode = DeliveryDocument.Expenses.ExpenseCode;
ARInvoiceDocument.Expenses.LineTotal = DeliveryDocument.Expenses.LineTotal;
ARInvoiceDocument.Expenses.TaxCode = DeliveryDocument.Expenses.TaxCode;
don't link it, just try this.
Hi
Ok
#1 gives me 5002 Internal Error
#2 I don't understand this one
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i meant that you should act tactical.
(i have many addons with freight and it always works.)
add a single document line with TWO freight.
use a document where the line has two freight costs
iLine = 0
DeliveryDocument.Lines.SetCurrentLine(iLine);
ARInvoiceDocument.Lines.SetCurrentLine(iLine);
ARInvoiceDocument.Lines.BaseType = (int)BoAPARDocumentTypes.bodt_DeliveryNote;
ARInvoiceDocument.Lines.BaseEntry = DeliveryDocument.DocEntry;
ARInvoiceDocument.Lines.BaseLine = DeliveryDocument.Lines.LineNum;
iFreight = 0;
DeliveryDocument.Lines.Expenses.SetCurrentLine(iFreight);
ARInvoiceDocument.Lines.Expenses.SetCurrentLine(iFreight);
ARInvoiceDocument.Lines.Expenses.ExpenseCode = DeliveryDocument.Lines.Expenses.ExpenseCode;
ARInvoiceDocument.Lines.Expenses.LineTotal = DeliveryDocument.Lines.Expenses.LineTotal;
ARInvoiceDocument.Lines.Expenses.TaxCode = DeliveryDocument.Lines.Expenses.TaxCode;
iFreight++;
DeliveryDocument.Lines.Expenses.SetCurrentLine(iFreight);
ARInvoiceDocument.Lines.Expenses.Add();
ARInvoiceDocument.Lines.Expenses.SetCurrentLine(iFreight);
ARInvoiceDocument.Lines.Expenses.ExpenseCode = DeliveryDocument.Lines.Expenses.ExpenseCode;
ARInvoiceDocument.Lines.Expenses.LineTotal = DeliveryDocument.Lines.Expenses.LineTotal;
ARInvoiceDocument.Lines.Expenses.TaxCode = DeliveryDocument.Lines.Expenses.TaxCode;
Same trouble
The SetCurrentLine is probably not the problem since I never used it and I always had all the lines of the delivery before using the Freights
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marc,
don't give up.
1. try once to reduce the lines count... you are starting with zero !
for (int iLine = 0; iLine < DeliveryDocument.Lines.Count - 1; iLine++)
if this fails
2. try to add once only two lines per code, and use setcurrentline. it might worked in past but
i recommend you to use it.
regards
I also have this piece of code on the HEADER level which I don't even know if this is necessary. But what I know is that if I do not use the Lines level
this piece works as for ONE Freight row
//---------------------------------------------------------------------------------------------------------------------------
// Seems to work WITH and WITHOUT FREIGHT but I'm not sure of the procedure to do it and on SDN forum there's no explaination
// and the documentation is silent about it :(
//---------------------------------------------------------------------------------------------------------------------------
if (DeliveryDocument.Expenses.ExpenseCode != 0)
{
ARInvoiceDocument.Expenses.ExpenseCode = DeliveryDocument.Expenses.ExpenseCode;
ARInvoiceDocument.Expenses.LineTotal = DeliveryDocument.Expenses.LineTotal;
ARInvoiceDocument.Expenses.TaxCode = DeliveryDocument.Expenses.TaxCode;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seems that even if I do a SetCurrentLine a still have the problem. I tought that .Add() place the SetCurrentLine on it automaticly.
here's the actual context in which I'm trying that :
//----------------------------------------------------------------------------------------------------------------------
// Now lets link the lines from the base document that means, the Invoice lines will be those from the Delivery document
// This is the way SAP works when time comes to transfers a Delivery to AR Invoice.
//----------------------------------------------------------------------------------------------------------------------
for (int iLine = 0; iLine < DeliveryDocument.Lines.Count; iLine++)
{
DeliveryDocument.Lines.SetCurrentLine(iLine);
ARInvoiceDocument.Lines.BaseType = (int)BoAPARDocumentTypes.bodt_DeliveryNote;
ARInvoiceDocument.Lines.BaseEntry = DeliveryDocument.DocEntry;
ARInvoiceDocument.Lines.BaseLine = DeliveryDocument.Lines.LineNum;
//// Trying to add the Freights rows but getting No matching record found...
if (DeliveryDocument.Lines.Expenses.Count > 0)
{
for (int iFreight = 0; iFreight < DeliveryDocument.Lines.Expenses.Count; iFreight++)
{
DeliveryDocument.Lines.Expenses.SetCurrentLine(iFreight);
ARInvoiceDocument.Lines.Expenses.ExpenseCode = DeliveryDocument.Lines.Expenses.ExpenseCode;
ARInvoiceDocument.Lines.Expenses.LineTotal = DeliveryDocument.Lines.Expenses.LineTotal;
ARInvoiceDocument.Lines.Expenses.TaxCode = DeliveryDocument.Lines.Expenses.TaxCode;
if (iFreight < DeliveryDocument.Lines.Expenses.Count - 1)
{
ARInvoiceDocument.Lines.Expenses.Add();
ARInvoiceDocument.Lines.Expenses.SetCurrentLine(ARInvoiceDocument.Lines.Expenses.Count);
}
}
}
TotalBeforeDiscount += DeliveryDocument.Lines.Price; // Calculating the Total before discount...
for (int iUDF = 0; iUDF < DeliveryDocument.Lines.UserFields.Fields.Count; iUDF++)
ARInvoiceDocument.Lines.UserFields.Fields.Item(DeliveryDocument.Lines.UserFields.Fields.Item(iUDF).Name).Value = DeliveryDocument.Lines.UserFields.Fields.Item(iUDF).Value;
if (iLine < DeliveryDocument.Lines.Count - 1)
ARInvoiceDocument.Lines.Add();
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh Really ?
I really have to SetCurrentLine even if its a .Add() ?
if I do so I presume I have to do SetCurrentLine(ARInvoice.Lines.Expenses.Count) ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marc,
iam a bit confused about the 2nd code snipped.
you want to add a new ARInvoiceDocument - ok.
i dont see ARInvoiceDocument.Lines.Expenses.SetCurrentLine
ok - you add a new row but you never set the correct line, the new lines
dont have a expensecode because you overwrite always the first line
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
99 | |
11 | |
11 | |
6 | |
6 | |
4 | |
4 | |
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.