How to import Transfer journal through code in ax 2012

Description: - Here I have import transfer journal through code in ax 2012. For that you have to need from dimension and to dimension so in dimension you have to mension configurationId, ColorId, SizeId, StyleId etc.

Code:-

static void CreateTransferJournal(Args _args)
{
    InventJournalTable      inventJournalTable;
    InventJournalTrans      inventJournalTrans;
    InventJournalCheckPost  inventJournalCheckPost;
    NumberSeq               num;
    boolean                 _throwserror    =   true;
    boolean                 _showinforesult =   true;
    InventDim               frominventDim,ToinventDim;
    ;
    ttsbegin;
    inventJournalTable.clear();
    num = new NumberSeq();
    num = NumberSeq::newGetNum
    (InventParameters::numRefTransferId());
    inventJournalTable.initFromInventJournalName(InventJournalName::find(InventParameters::find().TransferJournalNameId));
    inventJournalTable.Description = "Inventory Transfer Journal";
    inventJournalTable.SystemBlocked = true;
    inventJournalTable.insert();
    inventJournalTrans.clear();
    inventJournalTrans.initFromInventJournalTable(inventJournalTable);
    inventJournalTrans.ItemId = "xxxxxx";
    frominventDim.InventLocationId="xx";
    frominventDim.inventSiteId ="xx";
    ToinventDim.InventLocationId = "xxxx";
    ToinventDim.InventSiteId = "xx";
    ToinventDim = InventDim::findOrCreate(ToinventDim);
    frominventDim = InventDim::findOrCreate(frominventDim);
    inventJournalTrans.InventDimId = frominventDim.inventDimId;
    inventJournalTrans.initFromInventTable(InventTable::find("1101"));
    inventJournalTrans.Qty = 10;
    inventJournalTrans.ToInventDimId = ToinventDim.inventDimId;
    inventJournalTrans.TransDate = SystemDateget();
    inventJournalTrans.insert();
    inventJournalTable.SystemBlocked = false;
    inventJournalTable.update();
    ttscommit;

    if(InventJournalCheckPost::newPostJournal(inventJournalTable).validate())
        InventJournalCheckPost::newPostJournal(inventJournalTable).run();
}

Related Posts

Previous
Next Post »

Thanks for comments.....