Skip to main content

Create and post Purchase order in Axapta 2012

If you want to Create and post Purchase order in Axapta 2012 then you can try following code. In purchase order posting purchase invoice no. is compulsory so you need to mention invoice id  in code also.

1. Create purchase order


  PurchTable purchTable;  
 PurchLine purchLine;  
 VendTable vendTable = VendTable::find("v9009");  
 AxPurchTable axPurchTable;  
 AxPurchLine axPurchLine;  
 PurchFormLetter purchFormLetter;  
 purchTable.initFromVendTable(vendTable);  
 axPurchTable = axPurchTable::newPurchTable(purchTable);  
 axPurchTable.parmPurchaseType(PurchaseType::Purch);  
 axPurchTable.parmDocumentStatus(DocumentStatus::PurchaseOrder);  
 axPurchTable.parmAccountingDate(systemDateGet());  
 axPurchTable.parmDeliveryDate(systemdateget());  
 axPurchTable.parmPurchStatus(PurchStatus::Backorder);  
 axPurchTable.doSave();  
 PurchLine.initFromPurchTable(purchTable);  
 axPurchLine = AxPurchLine::newPurchLine(purchLine);  
 axpurchLine.parmItemId(78788);  
 axPurchLine.parmPurchQty(22);  
 axPurchLine.parmPurchPrice(344);  
 axPurchLine.doSave();  

2. Posting of Purchase order.

 purchTable = axPurchTable.purchTable();  
 purchFormLetter = PurchFormLetter::construct(DocumentStatus::PurchaseOrder);  
 purchFormLetter.update(purchTable, strFmt("P_%1", purchTable.PurchId));  
 purchFormLetter = PurchFormLetter::construct(DocumentStatus::Invoice);  
 purchFormLetter.update(purchTable, strFmt("%1", "In23232"));  

Popular posts from this blog

X++ Code to run SSRS Report with parameter in D365 F&O (Example Sales Invoice )

Below is sample X++ Code to run SSRS Report with parameter in D365 F&O (Example Sales Invoice )      Args                       args = new Args();     CustInvoiceJour            custInvoiceJour;     SalesInvoiceJournalPrint   salesInvoiceJournalPrint;       select firstonly custInvoiceJour where custInvoiceJour.SalesId != '';       // Add record to be printed.     // In order to have the context table we need to set args.record().     args.record(custInvoiceJour);       salesInvoiceController = new SalesInvoiceController();     salesInvoiceController.parmReportName(         PrintMgmtDocType::construct(PrintMgmtDocumentType::SalesOrderInvoice).getDefaultReportFormat());       salesInvoiceContract = salesInvoiceController.parmReportContrac...