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
I have the same question (0)


Report
All responses (
Answers (