web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Insert transfer journal through x++

(0) ShareShare
ReportReport
Posted on by 576

Hello ..

i want to insert about 1000 lines in one journal , so i found the next code and it help me to insert one line 

but i need to insert 1000 liens from another ax table 
Original code is 

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(); 
inventJournalCheckPost =
InventJournalCheckPost::newJournalCheckPost
(JournalCheckpostType::Post,inventJournalTable);
inventJournalCheckPost.parmThrowCheckFailed(_throwserror);
inventJournalCheckPost.parmShowInfoResult(_showinforesult);
inventJournalCheckPost.run(); 
inventJournalTable.SystemBlocked = false;
inventJournalTable.update(); 
ttscommit;
}

so now i edited the code and added while select from the other table

static void CopyOfCreateTransferJournal(Args _args)
{
    aaaT                     aaa1;
    InventJournalTable      inventJournalTable;
    InventJournalTrans      inventJournalTrans;
    InventJournalCheckPost  inventJournalCheckPost;
    NumberSeq               num;
    boolean                 _throwserror    =   true;
    boolean                 _showinforesult =   true;
    InventDim               frominventDim,ToinventDim;
    ;


    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();
    while select * from aaa1
    {
    ttsbegin;
    inventJournalTrans.clear();
    inventJournalTrans.initFromInventJournalTable(inventJournalTable);
    inventJournalTrans.ItemId = aaa1.ItemId;
    frominventDim.InventLocationId = aaa1.InventLocationIdFrom;
    frominventDim.inventSiteId = aaa1.InventSiteIdFrom;
    ToinventDim.InventLocationId = aaa1.InventLocationIdTO;
    ToinventDim.InventSiteId = aaa1.InventSiteIdTo;
    ToinventDim = InventDim::findOrCreate(ToinventDim);
    frominventDim = InventDim::findOrCreate(frominventDim);
    inventJournalTrans.InventDimId = frominventDim.inventDimId;
    inventJournalTrans.initFromInventTable(InventTable::find(aaa1.ItemId));
    inventJournalTrans.Qty = aaa1.Qty;
    inventJournalTrans.ToInventDimId = ToinventDim.inventDimId;
    inventJournalTrans.TransDate = SystemDateget();
    inventJournalTrans.insert();
    //inventJournalTable.SystemBlocked = false;
    //select  forUpdate  inventJournalTable;// where  inventJournalTable.
    //inventJournalTable.update();

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



}


Now there is an error after start the job

(Maximum number of decimals for the stockkeeping unit is 8)

thanks

*This post is locked for comments

  • Verified answer
    Ismail Mohamed Profile Picture
    576 on at

    Thanks the problem was in some data

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans