Thursday, April 16, 2020

How to create and post Inventory Movement Journal through x++ in D365 FO


One of the most common requirements these days is to create Inventory Movement Journal through code. Mostly when the input is coming from another 3rd Party application.

Here is the code show below :-



       InventJournalTable              inventJournalTable;
       InventJournalTrans              inventJournalTrans;
       InventJournalNameId             inventJournalName;
       InventDim                            inventDim;
       JournalCheckPost               journalCheckPost;
     

       // Creation of Inventory Journal Header     

        inventJournalTable.clear();

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

        inventJournalTable.insert();

     

        //Creation of Inventory Journal Lines

        inventJournalTrans.clear();

        inventJournalTrans.initFromInventJournalTable(inventJournalTable);

        inventJournalTrans.TransDate = systemDateGet();

        inventJournalTrans.ItemId = “Product88987”;

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

        inventJournalTrans.Qty = 11;

        inventDim.InventSiteId  = 'A1';

        inventDim.InventLocationId = 'Loc1';

        inventDim.wMSLocationId = ‘WS1’;

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

        inventJournalTrans.insert();

     

        //Posting the journal

        journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
        journalCheckPost.run();





No comments:

Post a Comment

How to reverse Free Text Invoice Voucher entries without Dialog

 Hey Folks ,  This blog post is in continuation of the previous post for Reversing Free Text Invoice Voucher entries with Dialog. Only diffe...