I have added a new movement journal and I want to change the Description
which is stored on table Invent JournalTable...
How am i going to change the value of "Description" through code
here is my code
******************************
Public void uploadFromCSV() //returns container
{
int row = 1;//, failedCtr = 0;
//boolean blnFail = false;
//Tables
InventJournalTable journalTable;
InventJournalTrans journalTrans;
//Classes
InventJournalTableData journalTableData;
InventJournalTransData journalTransData;
//InventJournalStatic journalStatic;
InventDim inventDim, itemInventDim;
InventTable InventTable;
MainAccountNum _account;
DimensionDynamicAccount ledgerDim;
DimensionDynamicAccount defaultDim;
ItemId localItemId;
//SIStype sisType;
//SISType sisType;
Counter failedCtr = 0;
JournalCheckPost journalCheckPost;
InventJournalTable inventJournalTable;
;
[filepath, fileNameOnly, type] = fileNameSplit(fileName);
importFile = new AsciiIo(fileName,'R');
importFile.inFieldDelimiter(#Delimiter);
record = importFile.read();
if(!(importFile) || (importFile.status() != IO_Status::Ok))
{
warning('Error in opening log file.');
throw(Exception::Error);
}
ttsBegin;
journalTableData = journalTableData::newTable(journalTable);
journalTransData = journalTableData.journalStatic().newJournalTransData(
journalTrans, journalTableData);
journalTable.clear();
journalTable.JournalId = journalTableData.nextJournalId();
journalTable.JournalType = InventJournalType::Movement;
//journalTable.Description = "TEST DESCRIPTION";
journalTable.journalNameId = journalNameId;
journalTable.initFromInventJournalName(InventJournalName::find(
journalTable.JournalNameId));
while (importFile.Status() == IO_Status::Ok)
{
try
{
record = importFile.Read();
if (record)
{
row++;
localItemId = conPeek(record, column2);
//sisType = conPeek(record, column17);
//sisType = "SISAR"
// sisType = str2enum(SISType,"1");
//sisType = str2enum(SISType,"SISAR");
//sisType = conPeek(record, column17);
info(conPeek(record,column17));
InventTable = InventTable::find(localItemId);
if (InventTable)
{
account = conPeek(record, column14);
finDim1 = conPeek(record, column15);
finDim2 = conPeek(record, column16);
finDim3 = conPeek(record, column18);
finDim4 = conPeek(record, column19);
finDim5 = conPeek(record, column20);
//ledgerDim = this.getLedgerAccount(account,finDim1,finDim2,finDim3,finDim4,finDim5,finDim6,finDim7);
//ledgerDim = 5637144578;
//ledgerDim 0
ledgerDim = this.getLedgerAccount(account,'','','','','','','');
//5637144578
//LedgerDim = 5637144578;
// Main
//ledgerDim =DimensionStorage::getDefaultAccountForMainAccountNum
_account = account;
ledgerDim = DimensionStorage::getDefaultAccountForMainAccountNum(_account);
//LedgerDimensionDefaultAccount::getDefaultAccountforMainAccountNum(account);
//LedgerDimensionDefaultAccount getDefaultAccountForMainAccountNum
defaultDim = this.getDefaultDimension(finDim1,finDim2,finDim3,
finDim4,finDim5,finDim6,finDim7);
journalTrans.clear();
journalTrans.initFromInventJournalTable(journalTable);
journalTrans.TransDate = str2Date(conPeek(record,column1),213);
journalTrans.ItemId = localItemId;
//journalTrans.SISType = sisType;
if (conPeek(record,column17) == "SISCash")
{
journalTrans.SISType=SISType::SISCash;
}
else if (conPeek(record,column17) == "SISAR"){
journalTrans.SISType=SISType::SISAR;
}
else if (conPeek(record,column17)== "SISCompexp"){
journalTrans.SISType=SISType::SISCompexp;
}
//journalTrans.SISType=SISType::SISCash; //= conPeek(record,column17);
//journalTrans.SISType = sisType;
//journalTrans.SISType = conPeek(record,column17);
//journalTrans.SISType = str2enum(sisType, conPeek(record, column17));
//journalTrans.SISType = conPeek(record, column17);
//journalTrans.SISType =str2enum(sisType,conPeek(record, column17));
//journalTrans.SISType = conPeek(record,column17);
//journalTrans.SISType = str2enum(sisType,conPeek(record,column17));
//info(sisType)
// info(conPeek(record,column17));
// info(str2enum(SISType,conPeek(record,column17)));
itemInventDim = inventDim::find(journalTrans.ItemId);
//Product Dimension
//configuration Id
if (conPeek(record, column3) == '')
{
inventDim.configId = itemInventDim.configId;
}
else
{
inventDim.configId = conPeek(record, column3);
}
//color Id
if (conPeek(record, column4) == '')
{
inventDim.InventColorId = itemInventDim.InventColorId;
}
else
{
inventDim.InventColorId = conPeek(record, column4);
}
//size Id
if (conPeek(record, column5) == '')
{
inventDim.InventSizeId = itemInventDim.InventSizeId;
}
else
{
inventDim.InventSizeId = conPeek(record, column5);
}
//style Id
if (conPeek(record, column6) == '')
{
inventDim.InventStyleId = itemInventDim.InventStyleId;
}
else
{
inventDim.InventStyleId = conPeek(record, column6);
}
// storage dimension
// site
if (conPeek(record, column7) == '')
{
inventDim.InventSiteId = itemInventDim.InventSiteId;
}
else
{
inventDim.InventSiteId = conPeek(record, column7);
}
//warehouse
if (conPeek(record, column8) == '')
{
inventDim.InventLocationId = itemInventDim.InventLocationId;
}
else
{
inventDim.InventLocationId = conPeek(record, column8);
}
//location
if (conPeek(record, column9) == '')
{
inventDim.wMSLocationId = itemInventDim.wMSLocationId;
}
else
{
inventDim.wMSLocationId = conPeek(record, column9);
}
// tracking dimension
// Batch Id
if (conPeek(record, column10) == '')
{
inventDim.InventBatchId = itemInventDim.InventBatchId;
}
else
{
inventDim.InventBatchId = conPeek(record, column10);
}
//Serial Number
if (conPeek(record, column11) == '')
{
inventDim.InventSerialId = itemInventDim.InventSerialId;
}
else
{
inventDim.InventSerialId = conPeek(record, column11);
}
if (conPeek(record, column17) == '')
{
inventDim.InventSISType = itemInventDim.InventSISType;
}
else
{
inventDim.InventSISType = conPeek(record, column17);
}
journalTrans.inventDimId = inventDim::findOrCreate(inventDim).inventDimId;
journalTrans.LedgerDimension = ledgerDim;
journalTrans.DefaultDimension = defaultDim;
journalTrans.Qty = str2num(conPeek(record,column12));
journalTrans.CostPrice = str2num(conPeek(record,column13));
journalTrans.CostAmount = journalTrans.Qty * journalTrans.CostPrice;
journalTransData.create();
}
else
{
error(strFmt('Item %1 does not exist.', localItemId));
throw(Exception::Error);
}
}
}
catch
{
failedCtr++;
info(strFmt('Line # %1 was not saved.', row));
continue;
}
this.resetValues();
}
if (failedCtr)
{
ttsAbort;
}
else
{
journalTable.insert();
ttsCommit;
// movement journal posting
try
{
inventJournalTable = inventJournalTable::find(journalTable.JournalId);
journalCheckPost = InventJournalCheckPost::newPostJournal(inventJournalTable);
journalCheckPost.run();
}
catch
{
throw error(strFmt('Error during posting of Journal %1',
inventJournalTable.JournalId));
}
info('Uploading successfully completed.');
}
//move file
importFile.finalize();
}
**************************************
I want to change the description of the movement journal that will be uploaded. Hope you'd help :D