InventDim inventDim;
InventJournalTrans journalTrans;
TmpImportInventJournal tableBuffer;
InventJournalTable inventJournal;
real lineNum = 1;
TmpImportInventJournal tmpTable; // tmpTable here is used to stored item counting data
InventJournalName inventJournalName;
NumberSeq numberSeq;
;
ttsbegin;
select forupdate * from inventJournal
where inventJournal.JournalId == inventJournalId;
select firstonly inventJournalName
where inventJournalName.JournalNameId == InventParameters::find().CountJournalNameId;
numberSeq = NumberSeq::newGetVoucherFromCode(inventJournalName.VoucherSeqId);
while select * from tmpTable
{
inventDim.clear();
journalTrans.clear();
inventDim.initValue();
inventDim.configId = tmpTable.configId;
inventDim.inventBatchId = tmpTable.inventBatchId;
inventDim.InventLocationId = tmpTable.InventLocationId;
inventDim.inventSerialId = tmpTable.inventSerialId;
inventDim.InventSiteId = tmpTable.InventSiteId;
inventDim.wMSLocationId = tmpTable.wMSLocationId;
inventDim = InventDim::findOrCreate(inventDim);
journalTrans.Voucher = numberSeq.voucher();
journalTrans.initValue();
journalTrans.initFromInventJournalTable(inventJournal);
journalTrans.LineNum = lineNum;
journalTrans.JournalType = inventJournal.JournalType;
journalTrans.TransDate = tmpTable.TransDate;
journalTrans.ItemId = tmpTable.ItemId;
journalTrans.initFromInventTable(InventTable::find(tmpTable.ItemId));
journalTrans.Counted = tmpTable.Counted;
journalTrans.InventDimId = inventDim.inventDimId;
journalTrans.validateWrite();
journalTrans.insert();
lineNum ++;
}
inventJournal.NumOfLines = lineNum -1;
inventJournal.update();
tmpTable.clear();
delete_from tmpTable;
ttscommit;
Try replacing the statement
journalTrans.Counted = tmpTable.Counted with:
journalTrans.Counted = tmpTable.Counted;
journalTrans.InventOnHand = InventSumDatePhysicalDim::onHandQty(countDate, itemId, inventDim,tmpInventDimParm);
/* where tmpInventDimParm holds flags for the enabled dimensions */
Also, replace the call to journalTrans.inser() with:
JournalTrans.insert(NoYes::Yes);
JournalTrans.inventMovement().journalSetCounted();
JournalTrans.update();
InventJournalTrans journalTrans;
TmpImportInventJournal tableBuffer;
InventJournalTable inventJournal;
real lineNum = 1;
TmpImportInventJournal tmpTable; // tmpTable here is used to stored item counting data
InventJournalName inventJournalName;
NumberSeq numberSeq;
;
ttsbegin;
select forupdate * from inventJournal
where inventJournal.JournalId == inventJournalId;
select firstonly inventJournalName
where inventJournalName.JournalNameId == InventParameters::find().CountJournalNameId;
numberSeq = NumberSeq::newGetVoucherFromCode(inventJournalName.VoucherSeqId);
while select * from tmpTable
{
inventDim.clear();
journalTrans.clear();
inventDim.initValue();
inventDim.configId = tmpTable.configId;
inventDim.inventBatchId = tmpTable.inventBatchId;
inventDim.InventLocationId = tmpTable.InventLocationId;
inventDim.inventSerialId = tmpTable.inventSerialId;
inventDim.InventSiteId = tmpTable.InventSiteId;
inventDim.wMSLocationId = tmpTable.wMSLocationId;
inventDim = InventDim::findOrCreate(inventDim);
journalTrans.Voucher = numberSeq.voucher();
journalTrans.initValue();
journalTrans.initFromInventJournalTable(inventJournal);
journalTrans.LineNum = lineNum;
journalTrans.JournalType = inventJournal.JournalType;
journalTrans.TransDate = tmpTable.TransDate;
journalTrans.ItemId = tmpTable.ItemId;
journalTrans.initFromInventTable(InventTable::find(tmpTable.ItemId));
journalTrans.Counted = tmpTable.Counted;
journalTrans.InventDimId = inventDim.inventDimId;
journalTrans.validateWrite();
journalTrans.insert();
lineNum ++;
}
inventJournal.NumOfLines = lineNum -1;
inventJournal.update();
tmpTable.clear();
delete_from tmpTable;
ttscommit;
Try replacing the statement
journalTrans.Counted = tmpTable.Counted with:
journalTrans.Counted = tmpTable.Counted;
journalTrans.InventOnHand = InventSumDatePhysicalDim::onHandQty(countDate, itemId, inventDim,tmpInventDimParm);
/* where tmpInventDimParm holds flags for the enabled dimensions */
Also, replace the call to journalTrans.inser() with:
JournalTrans.insert(NoYes::Yes);
JournalTrans.inventMovement().journalSetCounted();
JournalTrans.update();