Pages

Banner 468 x 60px

 

Wednesday, November 20, 2013

0 comments

AX2012 R2 : X++ code to create and post Inventory Movement Journal

Below is X++ code which is good to keep handy. It can be used to create and post inventory movement journals in AX 2012 R2. I have use hard coded values for illustration purpose:


        InventJournalTable              inventJournalTable;
        InventJournalTrans              inventJournalTrans;
        InventJournalName             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.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();

0 comments:

A financial dimension value is based on the LAND-00013 record and has been used on a transaction. You cannot delete the LAND-00013 record AX 2012

 A financial dimension value is based on the LAND-00013 record and has been used on a  transaction. You cannot delete the LAND-00013 record ...