static void UpdateCustomerDimension(Args _args)
{
CommaTextIO csvFile;
container readCon;
counter icount;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
Struct struct;
DimensionDefault DimensionDefault;
CustAccount custAccount;//VendAccount
CustTable custTable; //VendTable
container ledgerDimension;
int i;
#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();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
custAccount = conPeek(readCon,1);
custTable = CustTable::find(custAccount,true);
struct = new Struct();
struct.add('Sector',conPeek(readCon,3)); //(DimensionName,Value)
struct.add('Division', conPeek(readCon,4));
struct.add('SubDivision', conPeek(readCon,5));
struct.add('SubDivision', conPeek(readCon,6));
ledgerDimension = conNull();
ledgerDimension += struct.fields();
for (i = 1; i <= struct.fields(); i++)
{
ledgerDimension += struct.fieldName(i);
ledgerDimension += struct.valueIndex(i);
}
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable.DefaultDimension = DimensionDefault;
custTable.update();
}
}
ttsCommit;
}
}
{
CommaTextIO csvFile;
container readCon;
counter icount;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
Struct struct;
DimensionDefault DimensionDefault;
CustAccount custAccount;//VendAccount
CustTable custTable; //VendTable
container ledgerDimension;
int i;
#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();
ttsBegin;
while(csvFile.status() == IO_Status::OK)
{
readCon = csvFile.read();
if(readCon)
{
icount++;
custAccount = conPeek(readCon,1);
custTable = CustTable::find(custAccount,true);
struct = new Struct();
struct.add('Sector',conPeek(readCon,3)); //(DimensionName,Value)
struct.add('Division', conPeek(readCon,4));
struct.add('SubDivision', conPeek(readCon,5));
struct.add('SubDivision', conPeek(readCon,6));
ledgerDimension = conNull();
ledgerDimension += struct.fields();
for (i = 1; i <= struct.fields(); i++)
{
ledgerDimension += struct.fieldName(i);
ledgerDimension += struct.valueIndex(i);
}
DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);
custTable.DefaultDimension = DimensionDefault;
custTable.update();
}
}
ttsCommit;
}
}
No comments:
Post a Comment