Skip to Content
0
Feb 18, 2009 at 04:42 PM

DI API: Linking A/P Invoice with Purchase Order throught BaseEntry ..

441 Views

Hello

I try to create A/P invoice (using DI API) and their lines link to lines of Purchase Order. I set BaseType, BaseEntry and BaseLine fields and also I set another quantity. This works fine. But I also need to set another unit price (Document_Lines.Price) and here is the problem. After saving A/P invoice there is price from Purchase Order. Is any possibility to change the UnitPrice? On A/P Invoice form this can be done.

my code:

SAPbobsCOM::BoObjectTypes objType = SAPbobsCOM::BoObjectTypes)atoi(header.GetObjType().c_str());
SAPbobsCOM::IDocumentsPtr oDocument = GetDI()->GetBusinessObject(objType);

oDocument->CardCode = header.GetCardCode().c_str();
oDocument->DocDate = header.GetDocDate();
oDocument->DocDueDate = header.GetDocDueDate();
oDocument->TaxDate = header.GetTaxDate();
oDocument->VatDate = header.GetVatDate();
oDocument->DocCurrency = header.GetDocCur().c_str();
oDocument->NumAtCard = header.GetNumAtCard().c_str();

SAPbobsCOM::IDocument_LinesPtr oLines = oDocument->Lines;
for(unsigned i = 0; i < vecLines.size(); i ++)
{
	CDocLine& line = vecLines<i>;

	oLines->BaseType = line.GetBaseType();
	oLines->BaseEntry = line.GetBaseEntry();
	oLines->BaseLine = line.GetBaseLine();

	oLines->Quantity = line.GetQuantity();
	oLines->Currency = oDocument->DocCurrency;
	oLines->Price = line.GetPrice();

	oLines->Add();
}

oDocument->Add()

Thanks Tomas