static void importVendorCSV(Args _args)
{
CommaIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
DirPartyRecId partyRecId,contactPartyRecid;
Name name,contactName;
VendTable vendtable;
FileName fileName;
;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr(FileNameOpen));
dialog.filenameLookupFilter(["All files",#AllFiles]);
if (dialog.run())
{
filename = dfFileName.value();
}
csvFile = new CommaIO(filename, 'r');
if (csvFile)
{
readCon = csvFile.read();
while (csvFile.status() == IO_Status::OK)
{
icount++;
if (readCon)
{
vendtable.clear();
vendtable.initValue();
vendtable.Party = partyRecId;
vendtable.AccountNum = conPeek(readCon,1);
vendtable.VendGroup = conPeek(readCon,2);
vendtable.Currency = conPeek(readCon,3);
ttsBegin;
vendtable.insert();
ttsCommit;
}
//icount++;
break;
}
inserted++;
}
info(strfmt("%1 records inserted out of %2",inserted,icount));
}
{
CommaIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
DirPartyRecId partyRecId,contactPartyRecid;
Name name,contactName;
VendTable vendtable;
FileName fileName;
;
#File
dialog = new Dialog("Pick the file");
dfFileName = dialog.addField(extendedTypeStr(FileNameOpen));
dialog.filenameLookupFilter(["All files",#AllFiles]);
if (dialog.run())
{
filename = dfFileName.value();
}
csvFile = new CommaIO(filename, 'r');
if (csvFile)
{
readCon = csvFile.read();
while (csvFile.status() == IO_Status::OK)
{
icount++;
if (readCon)
{
vendtable.clear();
vendtable.initValue();
vendtable.Party = partyRecId;
vendtable.AccountNum = conPeek(readCon,1);
vendtable.VendGroup = conPeek(readCon,2);
vendtable.Currency = conPeek(readCon,3);
ttsBegin;
vendtable.insert();
ttsCommit;
}
//icount++;
break;
}
inserted++;
}
info(strfmt("%1 records inserted out of %2",inserted,icount));
}
No comments:
Post a Comment