How to Create Movement in Dynamics AX 2012 Through X++


How to Create Movement in Dynamics AX 2012 Through X++

static void createMovement(Args _args)
{

    InventJournalTable          inventJournalTable;
    InventJournalTrans          inventJournalTrans;
    InventDim                       inventDim;
    container                         ledgerDimensions;
    JournalCheckPost           journalCheckPost;



    //Journal
    inventJournalTable.clear();
    inventJournalTable.JournalType = InventJournalType::Movement;
    inventJournalTable.initFromInventJournalName(InventJournalName::find('Journal Name '));
    inventJournalTable.insert();



    //Lines
    inventJournalTrans.clear();
    inventJournalTrans.initFromInventJournalTable(inventJournalTable);
    inventJournalTrans.TransDate = systemDateGet();
    inventJournalTrans.ItemId = '10001';
    inventJournalTrans.initFromInventTable(InventTable::find(inventJournalTrans.ItemId));
    inventJournalTrans.Qty = 1;

    ledgerDimensions = ["1000000","1000000", 0];
    inventJournalTrans.LedgerDimension = AxdDimensionUtil::getLedgerAccountId(ledgerDimensions);

    inventDim.InventLocationId = '01';
    inventDim.modifiedField(fieldNum(inventDim,InventLocationId));
    inventJournalTrans.InventDimId = inventDim::findOrCreate(inventDim).inventDimId;
    inventJournalTrans.insert();


     //Post
     journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
     journalCheckPost.run();
}

Comments

Popular posts from this blog

How to loop through enum in dynamics ax 2012 using x++

How to read from csv file in Dynamics AX 2012 Through X++

How to Create Transfer Journal in Dynamics AX 2012 Through X++