In purchase order form - Line - Tab Quantity, there is Received, Delivery Reminder and Ordered.
I want to be able to entry those field by X++ code, because currently our company still entry data into old system.
I can retrieve the arrival purchase order goods data from that old system, then I want to entry those retrieved data by code into Axapta.
What table and field should I consider when doing that? What functions available to easily update each PO lines received quantity? Sample Code is nice.
How to create a purchase orders?
Sample code for sales orders can be found in jinx's AX blog.
Skip or translate the German text, the code is at the bottom, the essential being the createLine
method call. A global replace of "sales" to "purch" will do the trick for you.
Which fields to consider?
Lots and lots but start with the identity numbers, quantities and item units.
Quantities are in purchase units (PurchQty
) and inventory units (QtyOrdered
). You will have to set both, but one of the arguments to createLine
will do it for you.
Update:
To update the received quantities you have to update a packing slip. Besides updating the quantities it updates/creates inventory transactions.
You can do this by updating the PurchReceivedNow
and InventReceivedNow
fields on the PurchLine
table, the second field can be set by calling the setInventReceivedNow
method.
Then you update the packing slip (you will need the purchase order and a packing slip id):
void postPackingSlip(PurchTable purchTable, PackingSlipId packingSlipId)
{
PurchFormLetter letter = PurchFormletter::construct(DocumentStatus::PackingSlip, true);
letter.update(purchTable, packingSlipId, letter.transDate(), PurchUpdate::ReceiveNow);
}