AX 2012 – X++ Code to ‘Create and Post Purchase Order Invoice’

Find below job to create and post purchase order in Dynamics AX 2012

Note: Referring contoso demo data, ‘CEU’ company

static void CreatePOAndInvoice(Args _args)
{

PurchTable      purchTable;
PurchLine       purchLine;
VendTable       vendTable = VendTable::find(“3008”);
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(016\2012);
axPurchTable.parmPurchStatus(PurchStatus::Backorder);
axPurchTable.doSave();

//Create PurchLine for item 1000
purchLine.initFromPurchTable(purchTable);

axPurchLine = AxPurchLine::newPurchLine(purchLine);
axpurchLine.parmItemId(“1000”);
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));

}

Advertisements

About ShriShail Technologies Pvt Ltd

ShriShail Technologies is a company founded by a group of aspirants, from diversified domains and work experience. We provide smart, technology-enabled solutions to solve our clients' toughest challenges, demonstrating a commitment to not only excel, but also drive with our passion to exceed expectations. Our organization is efficient in delivering intelligent solutions that are cost effective on various work areas such as Business Management Solutions, Microsoft and Open Source platforms. ShriShail Technologies allows you to achieve the agility, flexibility and adaptability that are essential to succeed in today’s highly competitive global market.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s