Create Purchase order or Sales order and invoice through X++
static void
CreatePOAndInvoice(Args _args)
{
PurchTable purchTable;
PurchLine purchLine;
VendTable vendTable = VendTable::find("1000");
AxPurchTable axPurchTable;
AxPurchLine axPurchLine;
PurchFormLetter purchFormLetter;
;
//Create Purchase order
purchTable.initFromVendTable(vendTable);
axPurchTable =
axPurchTable::newPurchTable(purchTable);
axPurchTable.parmPurchaseType(PurchaseType::Purch);
axPurchTable.parmDocumentStatus(DocumentStatus::PurchaseOrder);
//
axPurchTable.parmAccountingDate(systemDateGet());
axPurchTable.parmDeliveryDate(01\06\2012);
axPurchTable.parmPurchStatus(PurchStatus::Backorder);
axPurchTable.doSave();
//Create PurchLine for item 1000
purchLine.initFromPurchTable(purchTable);
axPurchLine =
AxPurchLine::newPurchLine(purchLine);
axpurchLine.parmItemId("Test29");
axpurchLine.parmInventDimId('00000063_069');
axPurchLine.parmPurchQty(10);
axPurchLine.parmPurchPrice(100);
axPurchLine.doSave();
//Posting PO Confirmation,I guess its
mandatory
//You cannot do invoice without doing PO
confirm
purchTable = axPurchTable.purchTable();
purchFormLetter =
PurchFormLetter::construct(DocumentStatus::PurchaseOrder);
purchFormLetter.update(purchTable,
strFmt("Inv_%1", purchTable.PurchId));
//Posting PO Invoice
purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);
purchFormLetter.update(purchTable,
strFmt("Inv_%1", purchTable.PurchId));
}
thanks for post,
ReplyDeleteI am new ax technology and i am to learn ax2012 and this blog help to me increase my knowledge..
Hi Amir,
ReplyDeleteGood to see you here!!
You can go through the blog to help enhance your technical skills in AX.
If anyone have any doubts, can also post that.
Hi Vishal
ReplyDeleteCan u please give me you mail Id and Contact Number.
http://shrishailtechnologies.wordpress.com/2012/04/27/ax-2012-x-code-to-create-and-post-purchase-order-invoice/
ReplyDeleteThis code will not invoice because it needs document date for posting, only pending invoice will be created
ReplyDeleteInteresting stuff guys. Now almost in all the countries of world prefer to buy products online to save time as well as the money. I also prefer digital portals for saving time instead of visiting the market. This information will be the basis for comparison. As an object of benchmarking, you need to choose areas of guts(.)pk/ where the indicators significantly lag behind the standard. Thanks for it
ReplyDelete