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

Notifications

Announcements

No record found.

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

I have the same question (0)
  • 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans