web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Specify an Inventory Dimension for a Purchase Order with X++ code

(0) ShareShare
ReportReport
Posted on by 275

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)
  • Suggested answer
    dolee Profile Picture
    11,279 on at
    RE: Specify an Inventory Dimension for a Purchase Order with X++ code

    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);

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Tocauer Profile Picture

Martin Tocauer 4

#2
AlissonGodoy Profile Picture

AlissonGodoy 2

#2
NNaumenko Profile Picture

NNaumenko 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans