Hi Everyone,
Need urgent help.
I want to create Counting Journal through X++ code.
So I have created two Jobs one for creating Journal and another is to add Lines into Journal.
Could anyone please review my code and let me know if I am skipping any parameter and which I should add it to my code?
Though the Journals are getting created through below Jobs , I want to review my Code mentioned below,
Also please reply what does the line "inventJournalTable.InventDimFixed = " signify in Create Journal code ? What value I should pass into it?
///Create Journal/<Start>
static void createCountingJournal_RR(Args _args)
{
InventParameters inventParameters=InventParameters::find();
InventJournalName inventJournalName;
InventJournalTable inventJournalTable;
;
inventJournalTable.selectForUpdate(true);
inventJournalName = InventJournalName::find(inventParameters.CountJournalNameId);
inventJournalTable.initFromInventJournalName(inventJournalName);
inventJournalTable.InventDimFixed = 255;
inventJournalTable.insert();
info("Counting Journal created");
}
///Create Journal/<End>
///Create Journal Lines/<Start>
static void createCountingJournalLines_RR(Args _args)
{
InventTable _inventTable;
InventJournalTable _inventJournalTable = InventJournalTable::find("00082");
InventDim _inventDimFrom;
Qty _qty = 4;
InventJournalTrans inventJournalTrans;
InventDimParm inventDimParm;
InventMov_Jour_Loss_Sumup movement;
InventSum inventSum;
;
select firstOnly inventSum where inventSum.ItemId == "L0101";
select _inventDimFrom where _inventDimFrom.inventDimId == inventSum.InventDimId;
info(inventSum.InventDimId);
_inventTable = InventTable::find(inventSum.ItemId);
inventDimParm.initFromInventDim(_inventDimFrom);
inventJournalTrans.selectForUpdate(true);
inventJournalTrans.initFromInventJournalTable(_inventJournalTable);
inventJournalTrans.initFromInventTable(_inventTable);
inventJournalTrans.InventDimId = _inventDimFrom.inventDimId;
inventJournalTrans.InventOnHand = InventSumDatePhysicalDim::onHandQty(systemDateGet(),_inventTable.itemId,_inventDimFrom,inventDimParm);
inventJournalTrans.Counted = _qty;
inventJournalTrans.TransDate = 20\06\2013;
movement = InventMov_Jour_Loss_Sumup::newFromInventJournalTrans(inventJournalTrans);
movement.journalSetCounted();
inventJournalTrans.setCostPrice(inventJournalTrans.InventDimId);
inventJournalTrans.insert();
info("Counting Journal Line created");
}
///Create Journal Lines/<End>
Thank you in advance.