CommaTextIO csvFile;
container readCon;
Dialog dialog;
DialogField dfFileName;
int insertCount,updateCount;
str 200 DistributionId;
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
InventJournalTrans _InventJournalTrans;
InventDim _InventDim;
WMSJournalTrans _WMSJournalTrans;
InventLocation _InventLocation,_InventLocationTo;
InventLocationId _InventLocationId,_InventLocationIdTo;
InventSerialId _InventSerialId;
NumberSeq numberSeq;
NumberSequenceReference numberSequenceReference;
int ProgramDay;
#define.JournalID(1)
#define.TransDate(2)
#define.ItemID(3)
#define.Qty(4)
#define.Serial(5)
#define.LocationFrom(6)
#define.LocationTo(7)
super();
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if (readCon)
{
ttsBegin;
_InventJournalTrans.clear();
// numberSeq = new NumberSeq();
// numberSequenceReference = InventParameters::numRefInventJournalVoucherId();
// numberseq = NumberSeq::newGetNum(numberSequenceReference);
_InventJournalTrans.initFromInventJournalTable(InventJournalTable::find(_InventJournalTrans.JournalId));
// _InventJournalTrans.Voucher = numberseq.num();
_InventJournalTrans.JournalType = InventJournalType::Transfer;
_InventJournalTrans.JournalId= conPeek(readCon,#JournalID); //cells.item(row, 1).value().bStr();
_InventJournalTrans.transdate= str2Date(conPeek(readCon,#TransDate),123); //cells.item(row, 2).value().date();
_InventJournalTrans.itemId= conPeek(readCon,#ItemID); //cells.item(row,3).value().bStr();
_InventJournalTrans.qty= str2num(conPeek(readCon,#Qty)); //cells.item(row,4).value().double()*-1;
_InventLocation = InventLocation::find(conPeek(readCon,#LocationFrom));//InventLocation::find(cells.item(row,6).value().bStr());
_InventLocationTo = InventLocation::find(conPeek(readCon,#LocationTo));//InventLocation::find(cells.item(row,7).value().bStr());
_InventDim.clear();
_InventDim.InventSiteId=_InventLocation.InventSiteId;
_InventDim.InventSerialId = conPeek(readCon,#Serial);//cells.item(row,5).value().bStr();
_InventDim.InventLocationId = _InventLocation.InventLocationId;
_InventJournalTrans.inventDimId=InventDim::findOrCreate(_InventDim).inventDimId;
_InventDim.clear();
_InventDim.InventSiteId=_InventLocationTo.InventSiteId;
_InventDim.InventSerialId = conPeek(readCon,#Serial);//cells.item(row,5).value().bStr();
_InventDim.InventLocationId = _InventLocationTo.InventLocationId;
_InventJournalTrans.ToInventDimId= InventDim::findOrCreate(_InventDim).inventDimId;
_InventJournalTrans.insert();
ttsCommit;
updateCount++;
progress.setCaption("Uploading transfer journal");
progress.setAnimation(#AviUpdate);
progress.setText(strfmt("%1 line uploaded", updateCount));
// progress.setCount(updateCount, 1);
}
}
}
info(strFmt("%1 records inserted ",updateCount));
container readCon;
Dialog dialog;
DialogField dfFileName;
int insertCount,updateCount;
str 200 DistributionId;
#AviFiles
SysOperationProgress progress = new SysOperationProgress();
InventJournalTrans _InventJournalTrans;
InventDim _InventDim;
WMSJournalTrans _WMSJournalTrans;
InventLocation _InventLocation,_InventLocationTo;
InventLocationId _InventLocationId,_InventLocationIdTo;
InventSerialId _InventSerialId;
NumberSeq numberSeq;
NumberSequenceReference numberSequenceReference;
int ProgramDay;
#define.JournalID(1)
#define.TransDate(2)
#define.ItemID(3)
#define.Qty(4)
#define.Serial(5)
#define.LocationFrom(6)
#define.LocationTo(7)
super();
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr("FilenameOpen"));
dialog.filenameLookupFilter(["All files", #AllFiles]);
if (dialog.run())
{
csvFile = new CommaTextIo(dfFileName.value(), 'r');
csvFile.inFieldDelimiter(',');
readCon = csvFile.read();
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if (readCon)
{
ttsBegin;
_InventJournalTrans.clear();
// numberSeq = new NumberSeq();
// numberSequenceReference = InventParameters::numRefInventJournalVoucherId();
// numberseq = NumberSeq::newGetNum(numberSequenceReference);
_InventJournalTrans.initFromInventJournalTable(InventJournalTable::find(_InventJournalTrans.JournalId));
// _InventJournalTrans.Voucher = numberseq.num();
_InventJournalTrans.JournalType = InventJournalType::Transfer;
_InventJournalTrans.JournalId= conPeek(readCon,#JournalID); //cells.item(row, 1).value().bStr();
_InventJournalTrans.transdate= str2Date(conPeek(readCon,#TransDate),123); //cells.item(row, 2).value().date();
_InventJournalTrans.itemId= conPeek(readCon,#ItemID); //cells.item(row,3).value().bStr();
_InventJournalTrans.qty= str2num(conPeek(readCon,#Qty)); //cells.item(row,4).value().double()*-1;
_InventLocation = InventLocation::find(conPeek(readCon,#LocationFrom));//InventLocation::find(cells.item(row,6).value().bStr());
_InventLocationTo = InventLocation::find(conPeek(readCon,#LocationTo));//InventLocation::find(cells.item(row,7).value().bStr());
_InventDim.clear();
_InventDim.InventSiteId=_InventLocation.InventSiteId;
_InventDim.InventSerialId = conPeek(readCon,#Serial);//cells.item(row,5).value().bStr();
_InventDim.InventLocationId = _InventLocation.InventLocationId;
_InventJournalTrans.inventDimId=InventDim::findOrCreate(_InventDim).inventDimId;
_InventDim.clear();
_InventDim.InventSiteId=_InventLocationTo.InventSiteId;
_InventDim.InventSerialId = conPeek(readCon,#Serial);//cells.item(row,5).value().bStr();
_InventDim.InventLocationId = _InventLocationTo.InventLocationId;
_InventJournalTrans.ToInventDimId= InventDim::findOrCreate(_InventDim).inventDimId;
_InventJournalTrans.insert();
ttsCommit;
updateCount++;
progress.setCaption("Uploading transfer journal");
progress.setAnimation(#AviUpdate);
progress.setText(strfmt("%1 line uploaded", updateCount));
// progress.setCount(updateCount, 1);
}
}
}
info(strFmt("%1 records inserted ",updateCount));
No comments:
Post a Comment