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
2. Posting of Purchase order.
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"));