Author Topic: Create and post Inventory Movement Journal by Code: AX 2012  (Read 3966 times)

0 Members and 1 Guest are viewing this topic.

ForumAdmin

  • Administrator
  • Jr. Member
  • *****
  • Posts: 25
  • Point: +0/-0
Create and post Inventory Movement Journal by Code: AX 2012
« on: September 16, 2014, 01:10:46 PM »
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();