I found this code to create a purchase order and invoice in X++ listed below, but when I run it I get the error message: "Inventory dimension Size is a product dimension and must consequently be specified."
I'm not sure how to specify the product dimension size (which should be "01") in X++.
static void CreatePOAndInvoice(Args _args) { PurchTable purchTable; PurchLine purchLine; VendTable vendTable = VendTable::find("1103"); 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(21\12\2014); axPurchTable.parmPurchStatus(PurchStatus::Backorder); axPurchTable.doSave(); //Create PurchLine for item 10001 purchLine.initFromPurchTable(purchTable); axPurchLine = AxPurchLine::newPurchLine(purchLine); axpurchLine.parmItemId("10001"); 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)); }
*This post is locked for comments
Hi,
To do that you need to know what InventDim is. This is a good explanation http://basicax.blogspot.hk/2013/03/ax2012-understanding-inventdimid.html.
Once you know that, you just populate an InventDim record, then use the findOrCreate method to get the InventDimId and put it into AxPurchLine.
e.g.
inventDim.clear(); inventDim.InventSizeId = "01"; axPurchLine.parmInventDimId(inventDim::findOrCreate(inventDim).inventDimId);
André Arnaud de Cal...
291,996
Super User 2025 Season 1
Martin Dráb
230,853
Most Valuable Professional
nmaenpaa
101,156