static void importDepartmentfromCSV(Args _args) // Costcentre,Department,Business Unit, from csv
{
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
OMOperatingUnit OMOperatingUnit;
FileName fileName;
#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(',');
ttsBegin;
while (csvFile.status() == IO_Status::Ok)
{
readCon = csvFile.read();
OMOperatingUnit.clear();
OMOperatingUnit.OMOperatingUnitNumber = conPeek(readCon,1); //"OU_4771"
OMOperatingUnit.Name = conPeek(readCon,2); //"Accounting"
OMOperatingUnit.NameAlias = conPeek(readCon,2); //"Accounting"
OMOperatingUnit.OMOperatingUnitType = OMOperatingUnitType::OMDepartment; //Department;
OMOperatingUnit.LanguageId = 'en-us'; //language
OMOperatingUnit.insert();
}
ttsCommit;
}
}
{
CommaTextIO csvFile;
container readCon;
counter icount,inserted;
Dialog dialog;
DialogField dfFileName;
OMOperatingUnit OMOperatingUnit;
FileName fileName;
#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(',');
ttsBegin;
while (csvFile.status() == IO_Status::Ok)
{
readCon = csvFile.read();
OMOperatingUnit.clear();
OMOperatingUnit.OMOperatingUnitNumber = conPeek(readCon,1); //"OU_4771"
OMOperatingUnit.Name = conPeek(readCon,2); //"Accounting"
OMOperatingUnit.NameAlias = conPeek(readCon,2); //"Accounting"
OMOperatingUnit.OMOperatingUnitType = OMOperatingUnitType::OMDepartment; //Department;
OMOperatingUnit.LanguageId = 'en-us'; //language
OMOperatingUnit.insert();
}
ttsCommit;
}
}
No comments:
Post a Comment