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

Demystifying the SysOperation Framework in D365 F&O: Building Scalable and Maintainable Batch Jobs

 If you've been developing in Dynamics 365 Finance and Operations for a while, chances are you've either worked with or heard about ...