AX Consulting

Just another WordPress.com site

Create and Post inventory journal by code : Dynamics AX

How to create and post inventory journal using X++ by create inventjournalTable and adding inventJournalTrans, you can use the below code to import data from another system during integration between AX and others application with adding some to fetch data from, which it may be from Excel file or connect to any data base, and you can find in the blog another posts related to read from Excel file and how to connect to DB using X++.

        InventJournalTable              inventJournalTable;
        InventJournalTrans              inventJournalTrans;

        InventJournalNameId             inventJournalName;
        InventDim                            inventDim;
        JournalCheckPost               journalCheckPost;
       

//Below code creates journal header       

        inventJournalTable.clear();

        inventJournalName =  InventJournalName::standardJournalName(InventJournalType::Movement);
        inventJournalTable.initFromInventJournalName(InventJournalName::find(inventJournalName ));

        inventJournalTable.insert();

       

//Below code creates journal lines

        inventJournalTrans.clear();

        inventJournalTrans.initFromInventJournalTable(inventJournalTable);

        inventJournalTrans.TransDate = systemDateGet();

        inventJournalTrans.ItemId = “MDJ0001”;

        inventJournalTrans.initFromInventTable(InventTable::find(“MDJ0001”));

        inventJournalTrans.Qty = 2500;

        inventDim.InventSiteId  = ’12’;

        inventDim.InventLocationId = ‘1201’;

        inventDim.wMSLocationId = ‘BULK-001’;

        inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;

        inventJournalTrans.insert();

       

//The below code posts the journal
        journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
        journalCheckPost.run();

Advertisements

One response to “Create and Post inventory journal by code : Dynamics AX

  1. Przemysław Marek April 15, 2016 at 6:45 am

    Hi,
    Where, in what class is updated Cost and Price?
    In Inventory management->Journals->Movement (Journal lines) I added manually cost, by when Posting, on General ledger are different costs? Where to change, for my specific Journal Name, to don’t update cost?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: