Thank you for the help!
please have a look at the code.
class CFZCountingJournalImport
{
#define.utility("Counting journal import utility")
CFZ_CountingJournalImportTmp cfzCountingJournalImportTmp;
InventJournalTable inventJournalTable,inventJournalTableParm;
InventJournalTrans inventJournalTrans;
InventJournalTrans inventJournalTrans_pram;
InventTableModule inventTableModule;
InventSum inventSum;
InventItemBarcode inventItemBarcode;
InventDim inventDim,inventDim2,inventDimNew,inventDimFindOrCreation;
JournalId journalId;
InventSiteId inventSiteId;
InventLocationId inventLocationId;
Qty qty;
ItemBarCode itemBarcode;
ItemCostPrice itemCostPrice;
MainAccountNum offsetAccount;
RetailStoreId store;
str referenceStore, referenceDoc;
FormRun forme;
Args arg;
NoYes IsAnyErrorOccured;
int row;
int iQty;
str fileString;
int iTOCount;
str businessUnit,subBusinessUnit,department,location,purpose,worker,natureOfExpense;
//Used to get the File Stream
public List setStream(System.IO.Stream _stream,Args _args)
{
//Parse the file by converting the file to String and passing it to class MTQImportVaidationNParser
arg = _args;
System.IO.StreamReader sr = new System.IO.StreamReader(_stream);
fileString = sr.ReadToEnd();
List mainlist = CFZImportHelper::parseString(fileString);
return mainlist;
}
public void importLogic(List _list)
{
ListIterator iterator;
container cont;
iterator = new ListIterator(_list);
int i;
while(iterator.more())
{
cont = iterator.value();
this.importCountingJounralLines(cont);
cont = conNull();
iterator.next();
}
}
public void importCountingJounralLines(container _journalLines)//, InventSiteId _siteid, InventLocationId _locationid)
{
/*Insert Temp Table*/
/*--------------------- Processing Excel File, Verifying Then Insert into Temp Table-----------------------------*/
if(_journalLines)
{
row ;
if(row > 1)
{
itemBarcode = strLtrim(strRtrim(conpeek(_journalLines, 1)));
qty = any2Real(strLtrim(strRtrim(conpeek(_journalLines,2))));
if (qty == 0)
{
error(strFmt("Row # [%1] found invalid quantity [%2].", row, qty), #utility);
IsAnyErrorOccured = NoYes::Yes;
}
if (IsAnyErrorOccured == NoYes::No)
{
ttsbegin;
// Insert temp table
cfzCountingJournalImportTmp.initValue();
cfzCountingJournalImportTmp.clear();
cfzCountingJournalImportTmp.ItemBarCode = itemBarcode;
cfzCountingJournalImportTmp.Qty = qty;
cfzCountingJournalImportTmp.insert();
ttscommit;
}
else
{
IsAnyErrorOccured = NoYes::No;
}
}
}
}
public void afterTmpTableProcessing(InventSiteId _siteID, InventLocationId _locationId)
{
if (arg.record().TableId == tableNum(InventJournalTable))
{
inventJournalTableParm = arg.record();
}
Info(strFmt("Journal id: %1",inventJournalTableParm.JournalId));
journalId = inventJournalTableParm.JournalId;
if (row <= 1)
{
warning("No data found in csv file");
return;
}
else
{
if (IsAnyErrorOccured == NoYes::Yes)
{
error("Please Find Above Errors List.");
ttsAbort;
// delete_from cfzCountingJournalImportTmp;
return;
}
else
{
iTOCount = 0;
ttsbegin;
while select cfzCountingJournalImportTmp
{
inventItemBarcode = InventItemBarcode::findBarcode(strLTrim(cfzCountingJournalImportTmp.ItemBarCode), false, false, '', false);
inventDim = InventDim::find(inventItemBarcode.inventDimId);
if(inventItemBarcode)
{
info(strFmt("%1",inventItemBarcode.itemId));
inventJournalTrans = null;
inventJournalTrans.initValue();
inventJournalTrans.LineNum = InventJournalTrans::lastLineNum(journalId) 1;
inventJournalTrans.JournalType = 4;
inventJournalTrans.JournalId = journalId;
inventJournalTrans.ItemId = inventItemBarcode.itemId;
inventJournalTrans.Qty = cfzCountingJournalImportTmp.Qty;
info(strFmt("%1",cfzCountingJournalImportTmp.Qty));
/* Find or Create InventDimID */
inventDimFindOrCreation.InventSiteId = _siteID;//cfzCountingJournalImportTmp.InventSiteId;//inventDim.InventSiteId;
inventDimFindOrCreation.InventLocationId = _locationId;//cfzCountingJournalImportTmp.InventLocationId;//inventDim.inventLocationId;
inventDimFindOrCreation.InventSizeId = inventDim.InventSizeId;
inventDimFindOrCreation.INVENTCOLORID = inventDim.INVENTCOLORID;
inventJournalTrans.InventDimId = InventDim::findOrCreate(inventDimFindOrCreation).inventDimId;
/*-----------------------------*/
inventJournalTrans.initFromInventTable(InventTable::find(inventItemBarcode.itemId),false,false);
inventJournalTrans.insert();
iTOCount ;
}
}
if (iTOCount > 0)
{
Box::info(strfmt('Total [%1] Counting journal lines created successfully.',iTOCount));
}
delete_from cfzCountingJournalImportTmp;
ttsCommit;
}
forme = arg.caller();
if(forme)
{
forme.dataSource().research(true);
}
}
}
}
One more problem that i'm facing is that in this line
inventItemBarcode = InventItemBarcode::findBarcode(strLTrim(cfzCountingJournalImportTmp.ItemBarCode), false, false, '', false);"
"inventItemBarcode" variable is showing null value of itembarcode, although there is value in "cfzCountingJournalImportTmp.ItemBarCode" which I checked while Debugging
Please let me know the issue
Regards,