Creating a purchase order
Purchase orders are used throughout the purchasing process to hold the information about
the goods or services that a company buys from its suppliers. Normally, purchase orders are
created from the user interface, but in automated processes, purchase orders can be also
created from code.
1 In the AOT, create a new job named PurchOrderCreate with the following code:
static void PurchOrderCreate(Args _args)
{
NumberSeq numberSeq;
PurchTable purchTable;
PurchLine purchLine;
ttsBegin;
numberSeq = NumberSeq::newGetNum(
PurchParameters::numRefPurchId());
numberSeq.used();
purchTable.PurchId = numberSeq.num();
purchTable.initValue();
purchTable.initFromVendTable(VendTable::find('1001'));
if (!purchTable.validateWrite())
{
throw Exception::Error;
}
purchTable.insert();
purchLine.PurchId = purchTable.PurchId;
purchLine.ItemId = '1205';
purchLine.createLine(true, true, true, true, true, true);
ttsCommit;
info(strFmt(
"Purchase order '%1' has been created",
purchTable.PurchId));
}
2. Run the job to create a new purchase order.
3. Open Procurement and sourcing | Common | Purchase orders | All purchase
orders to view the created purchase order:
and see your purchase order is created..
This Will helps u to create a Purchase Order..!! Now How to do posting of this..
In Dynamics AX, a purchase order goes through a number of statuses in order to reflect its
current position within the purchasing process. This status can be updated either manually by
using the user interface or programmatically from code.
using the user interface or programmatically from code.
1. In the AOT, create a new job named PurchOrderPost with the following code
(replace 000409 with your number):
static void PurchOrderPost(Args _args)
{
PurchFormLetter purchFormLetter;
PurchTable purchTable;
purchTable = PurchTable::find('000409');
purchFormLetter = PurchFormLetter::construct(
DocumentStatus::PurchaseOrder);
purchFormLetter.update(
purchTable,
'',
systemDateGet(),
PurchUpdate::All,
AccountOrder::None,
NoYes::No,
NoYes::Yes);
}
2. Run the job to post the specified purchase order and display the purchase
order document:
3. Open Procurement and sourcing | Common | Purchase orders | All purchase
orders, and notice that the Approval status of the posted order is now different:
and see your order status is Confirmed...!!
I-ace Technologies and Services
No comments:
Post a Comment