I just came across a scenario where I had to import the Projects as WIPs from legacy system. For that I imported Projects and Project Contracts in the System, partly using DIXF and partly using excel add-in. During the import, I figured out that Funding Rules Allocation were not updated, so I had to write a custom job to updated that. Later, I saw that Financial Dimensions on Projects were imported correctly but those on Funding Source were empty, so I wrote following job to see which dimensions are currently attached to the Project Contract. I am sharing it with you all so somebody might not need to reinvent the wheel. Happy DAXing! ☺
static void getProjContractDims(Args _args)
{
InventTable inventTable;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row,col;
ProjFundingSource projFundingSource;
DimensionAttributeValueSetItem dimensionSet;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
cell = cells.item(1,1);
cell.value("ProjContractId");
cell = cells.item(1,2);
cell.value("Dimension");
cell = cells.item(1,3);
cell.value("BusinessLine");
cell = cells.item(1,4);
cell.value("Customer");
cell = cells.item(1,5);
cell.value("Department");
cell = cells.item(1,6);
cell.value("ItemGroup");
cell = cells.item(1,7);
cell.value("Project");
cell = cells.item(1,8);
cell.value("Region");
row = 1;
while select ContractId, DefaultDimension from projFundingSource {
info(projFundingSource.ContractId);
row++;
cell = cells.item(row, 1);
cell.value(projFundingSource.ContractId);
cell = cells.item(row, 2);
cell.value(projFundingSource.DefaultDimension);
while select DimensionAttributeValueSet, DimensionAttributeValue, DisplayValue from dimensionSet
where dimensionSet.DimensionAttributeValueSet == projFundingSource.DefaultDimension
{
switch(DimensionAttribute::find((DimensionAttributeValue::find(dimensionSet.DimensionAttributeValue).DimensionAttribute)).Name)
{
case 'BusinessLine':
cell = cells.item(row, 3);
cell.value(dimensionSet.DisplayValue);
break;
case 'Customer':
cell = cells.item(row, 4);
cell.value(dimensionSet.DisplayValue);
break;
case 'Department':
cell = cells.item(row, 5);
cell.value(dimensionSet.DisplayValue);
break;
case 'ItemGroup':
cell = cells.item(row, 6);
cell.value(dimensionSet.DisplayValue);
break;
case 'Project':
cell = cells.item(row, 7);
cell.value(dimensionSet.DisplayValue);
break;
case 'Region':
cell = cells.item(row, 8);
cell.value(dimensionSet.DisplayValue);
}
}
}
application.visible(true);
}
static void getProjContractDims(Args _args)
{
InventTable inventTable;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row,col;
ProjFundingSource projFundingSource;
DimensionAttributeValueSetItem dimensionSet;
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
cell = cells.item(1,1);
cell.value("ProjContractId");
cell = cells.item(1,2);
cell.value("Dimension");
cell = cells.item(1,3);
cell.value("BusinessLine");
cell = cells.item(1,4);
cell.value("Customer");
cell = cells.item(1,5);
cell.value("Department");
cell = cells.item(1,6);
cell.value("ItemGroup");
cell = cells.item(1,7);
cell.value("Project");
cell = cells.item(1,8);
cell.value("Region");
row = 1;
while select ContractId, DefaultDimension from projFundingSource {
info(projFundingSource.ContractId);
row++;
cell = cells.item(row, 1);
cell.value(projFundingSource.ContractId);
cell = cells.item(row, 2);
cell.value(projFundingSource.DefaultDimension);
while select DimensionAttributeValueSet, DimensionAttributeValue, DisplayValue from dimensionSet
where dimensionSet.DimensionAttributeValueSet == projFundingSource.DefaultDimension
{
switch(DimensionAttribute::find((DimensionAttributeValue::find(dimensionSet.DimensionAttributeValue).DimensionAttribute)).Name)
{
case 'BusinessLine':
cell = cells.item(row, 3);
cell.value(dimensionSet.DisplayValue);
break;
case 'Customer':
cell = cells.item(row, 4);
cell.value(dimensionSet.DisplayValue);
break;
case 'Department':
cell = cells.item(row, 5);
cell.value(dimensionSet.DisplayValue);
break;
case 'ItemGroup':
cell = cells.item(row, 6);
cell.value(dimensionSet.DisplayValue);
break;
case 'Project':
cell = cells.item(row, 7);
cell.value(dimensionSet.DisplayValue);
break;
case 'Region':
cell = cells.item(row, 8);
cell.value(dimensionSet.DisplayValue);
}
}
}
application.visible(true);
}
Comments
Post a Comment