Sometime we need to split purchase order line into multiple lines with Quantity = 1, here is a piece of code through which you can split purchase order line into multiple lines. You can easily alter the below code based on your Quantity factor.
static void SplitPurchLine(Args _args)
{
PurchQty qty;
PurchTable purchTable;
PurchLine purchLine;
purchTable = PurchTable::find("PO-0001");
while select forUpdate purchLine
where purchLine.PurchId == purchTable.PurchId && purchLine.PurchQty > 1
{
qty = purchLine.PurchQty;
while (qty > 1)
{
PLPurchLineSplit::update(purchLine, 1);
qty -= 1;
}
}
}
4 comments:
Hi Muhammad,
It seems that you missed to post code for the class PLPurchSplitLine.
Best Regards,
Michael Brown
Yes, the above code is only split purchase order lines. Posting can be done via a PurchFormLetter class like this:
//Posting PO Invoice
purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable, strFmt("POInvoice_%1", purchTable.PurchId));
Hi Muhammad,
I'm sorry for the misunderstanding. I meant that code for class PLPurchLineSplit is not present in this blog post and doesn't seem to be available in our environment.
Could you help to verify whether this is a custom class. If it isn't a custom one, what verion / build of AX 2012 are you using. We are using AX 2012 RTM + CU3.
Best Regards,
Michael Brown
Mike, I think this class is introduced in DAX 2012 R2 release.
Post a Comment