Following is job which will create and post the Inventory Journal in ax 2009 :-
static void createMovJournal(Args _args)
{ InventJournalTable journalTable;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventTable inventTable;
InventDim inventDim;
Counter cnt;
InventJournalCheckPost journalCheckPost = new InventJournalCheckPost();
DialogButton dbtn;
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
// Init JournalTable
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
journalTable.JournalNameId = journalTableData.journalStatic().standardJournalNameId(journalTable.JournalType);
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
// Init JournalTrans
select firstonly inventTable;
for(cnt=1;cnt<10;cnt++)
{
journalTrans.clear();
journalTransData.initFromJournalTable();
journalTrans.TransDate = systemdateget() + 1 div 2;
journalTrans.ItemId ='1103'; //inventTable.ItemId;
journalTrans.Qty = 100;
journalTrans.CostAmount = 100;
journalTrans.LedgerAccountIdOffset='110170';
// Dimension details
inventDim.InventLocationId = '11';
journalTrans.InventDimId ='00000061_069'; //InventDim::findOrCreate(inventDim).inventDimId;
journalTransData.create();
}
journalTable.insert();
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
if(box::yesNo("Do you want to Post Now?",DialogButton::No)==DialogButton::Yes)
{
InventJournalCheckPost::newPostJournal(journalTable).run();
}
else
{
box::info("Not Posted");
}
info("done");
}
static void createMovJournal(Args _args)
{ InventJournalTable journalTable;
InventJournalTrans journalTrans;
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
InventTable inventTable;
InventDim inventDim;
Counter cnt;
InventJournalCheckPost journalCheckPost = new InventJournalCheckPost();
DialogButton dbtn;
;
journalTableData = JournalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(journalTrans,journalTableData);
// Init JournalTable
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
journalTable.JournalNameId = journalTableData.journalStatic().standardJournalNameId(journalTable.JournalType);
journalTableData.initFromJournalName(journalTableData.journalStatic().findJournalName(journalTable.JournalNameId));
// Init JournalTrans
select firstonly inventTable;
for(cnt=1;cnt<10;cnt++)
{
journalTrans.clear();
journalTransData.initFromJournalTable();
journalTrans.TransDate = systemdateget() + 1 div 2;
journalTrans.ItemId ='1103'; //inventTable.ItemId;
journalTrans.Qty = 100;
journalTrans.CostAmount = 100;
journalTrans.LedgerAccountIdOffset='110170';
// Dimension details
inventDim.InventLocationId = '11';
journalTrans.InventDimId ='00000061_069'; //InventDim::findOrCreate(inventDim).inventDimId;
journalTransData.create();
}
journalTable.insert();
// Call the static method to post the journal
if(InventJournalCheckPost::newPostJournal(journalTable).validate())
if(box::yesNo("Do you want to Post Now?",DialogButton::No)==DialogButton::Yes)
{
InventJournalCheckPost::newPostJournal(journalTable).run();
}
else
{
box::info("Not Posted");
}
info("done");
}
No comments:
Post a Comment