static void Krishh_AcctStructureExport(Args _args)
{
DimensionHierarchy dimensionHierarchy;
DimensionHierarchyLevel dimensionHierarchyLevel;
DimensionAttribute dimensionAttribute;
DimensionConstraintNode dimensionConstraintNode;
DimensionConstraintNodeCriteria dimensionConstraintNodeCriteria;
FileIOPermission fileIoPermission;
CommaIO csvFile;
container writecon;
Dialog dialog;
DialogField dfFileName;
FileName fileName;
boolean firstRow = true;
Counter countRows;
#File
dialog = new Dialog("Export account structure text file");
dfFileName = dialog.addField(extendedTypeStr(FileNameSave));
dialog.filenameLookupFilter(["CSV files", #AllFilesName+#CSV, "All files", #AllFiles]);
if (dialog.run())
filename = dfFileName.value();
else
throw error("Export cancelled");
fileIoPermission = new FileIOPermission(filename ,'W');
fileIoPermission.assert();
csvFile = new CommaIO(filename, 'w');
csvFile.outFieldDelimiter(';');
while select dimensionHierarchy order by dimensionHierarchy.Name, dimensionHierarchyLevel.Level, dimensionConstraintNodeCriteria.RangeFrom, dimensionConstraintNodeCriteria.RangeTo, dimensionConstraintNodeCriteria.WildCardString
where !dimensionHierarchy.IsSystemGenerated
join dimensionHierarchyLevel
where dimensionHierarchyLevel.DimensionHierarchy == dimensionHierarchy.RecId
join dimensionAttribute
where dimensionAttribute.RecId == dimensionHierarchylevel.DimensionAttribute
join dimensionConstraintNode
where dimensionConstraintNode.DimensionHierarchyLevel == dimensionHierarchyLevel.RecId
join dimensionConstraintNodeCriteria
where dimensionConstraintNodeCriteria.DimensionConstraintNode == dimensionConstraintNode.RecId
{
if (firstRow)
{
writeCon = [ "Account structure",
"Level",
"Dimension",
"From",
"To",
"Wildcard"];
csvFile.write(writecon);
firstRow = false;
}
writeCon = [ dimensionHierarchy.Name,
int2str(dimensionHierarchyLevel.Level),
dimensionAttribute.Name,
dimensionConstraintNodeCriteria.RangeFrom,
dimensionConstraintNodeCriteria.RangeTo,
dimensionConstraintNodeCriteria.WildCardString];
csvFile.write(writecon);
countRows++;
}
CodeAccessPermission::revertAssert();
info(strFmt("%1 rows written to %2.", countRows, fileName));
}
No comments:
Post a Comment
Thanks for visiting my blog,
I will reply for your comment within 48 hours.
Thanks,
krishna.