public void CreateCountingJournal(JournalDescription _journalDescription, ItemId _itemId, InventQtyCounted _countedQuantity)
{
JournalCheckPost journalCheckPost;
InventDim inventDim;
InventDimParm tmpInventDimParm;
InventJournalTrans journalTrans;
InventJournalTable inventJournal;
InventJournalName inventJournalName;
JournalTableData journalTableData;
InventSum inventSum;
NumberSeq numberSeq;
NumberSeq num;
str journalName;
str journalNum;
int lineNum = 0;
boolean errors;
;
journalName = InventParameters::find().CountJournalNameId;num = new NumberSeq();
num = NumberSeq::newGetNum(InventParameters::numRefInventJournalId());
journalNum = num.num();
inventJournalName = InventJournalName::find(journalName);
ttsbegin;
inventJournal.initFromInventJournalName(inventJournalName);
inventJournal.JournalNameId = journalName;
inventJournal.JournalId = journalNum;
inventJournal.JournalType = InventJournalType::Count;
inventJournal.Description = _journalDescription;
inventJournal.insert();journalTableData = JournalTableData::newTable(inventJournal);
inventDim.clear();
journalTrans.clear();inventDim.initValue();
inventDim.InventSiteId = “9”;
inventDim.InventLocationId = “99”;
inventDim.wMSLocationId = “Loc”;
inventDim = InventDim::findOrCreate(inventDim);journalTrans.initValue();
journalTrans.initFromInventJournalTable(inventJournal);JournalTrans.TransDate = today();
journalTrans.ItemId = _itemId;InventQty ItemOnHandQty = InventSumDatePhysicalDim::onHandQty(JournalTrans.TransDate,journalTrans.ItemId,inventDim,tmpInventDimParm);
JournalTrans.LineNum = 1;
journalTrans.InventDimId = inventDim.inventDimId;
journalTrans.InventOnHand = ItemOnHandQty;
journalTrans.JournalType = inventJournal.JournalType;journalTrans.initFromInventTable(InventTable::find(journalTrans.ItemId));
journalTrans.InventOnHand = ItemOnHandQty;
journalTrans.Counted = _countedQuantity;
journalTrans.Counted = decRound(journalTrans.Counted,InventTable::inventDecimals(journalTrans.ItemId));
journalTrans.Qty = journalTrans.Counted – journalTrans.InventOnHand;
journalTrans.validateWrite();
journalTrans.insert();
lineNum ++;
inventJournal.NumOfLines = lineNum;
inventJournal.update();journalTableData.updateBlock(JournalBlockLevel::InUse,JournalBlockLevel::None);
if(!infolog.num(Exception::Error))
{
infolog.clear(0);
//journalCheckPost = InventJournalCheckPost::newJournalCheckPost(JournalCheckPostType::Post,inventJournal);
//journalCheckPost.parmAutoBlock(true);
//journalCheckPost.run();
}
ttscommit;}