// Define mappings for Account dimension members between PBCS and Strategic Models def smToPbcsAccountNameMap = ['v1000:010' : 'OFS_Product Revenue', 'v1000:020' : 'OFS_Services Revenue', 'v1000:030' : 'OFS_Support Revenue', 'v1020' : 'OFS_Discounts', 'v1040' : 'OFS_Total Cost Of Sales'] def smPbcsYearMap = ['2017':'FY17', '2018':'FY18'] List smYears = smPbcsYearMap.collect {it.key} List pbcsYears = smPbcsYearMap.collect {it.value} //Reversing the key value pair from the existing maps. def pbcsToSMAccountNameMap = smToPbcsAccountNameMap.collectEntries { k, v -> [v, k] } as Map def pbcstoSMScenarioMap = ['OEP_Strategic Planning' : 'Forecast'] String pbcsScenarioName = 'OEP_Strategic Planning' String smScenarioName = pbcstoSMScenarioMap.get(pbcsScenarioName) ?: pbcsScenarioName; ["Operations US East", "Operations US West", "Operations US North", "Operations US South"].each { String modelName -> Cube cube = operation.application.getCube("OEP_FS") DataGridDefinitionBuilder defBuilder = cube.dataGridDefinitionBuilder() defBuilder.addPov(['Period', 'Scenario', 'Currency', 'Version', 'Entity', 'Market', 'Plan Element', 'Product'], [ ['YearTotal'], [pbcsScenarioName], ['USD'], ['OEP_Working'], [modelName], ['US Market'], ['OFS_Direct Input'], ['Smart Phone 6 in'] ]) defBuilder.addColumn(['Years'], [ ['FY17', 'FY18'] ]) defBuilder.addRow(['Account'], [ ['OFS_Product Revenue', 'OFS_Services Revenue','OFS_Support Revenue','OFS_Discounts','OFS_Total Cost Of Sales','OFS_Other Revenue'] ]) DataGridDefinition gridDefinition = defBuilder.build() DataGrid grid = cube.loadGrid(gridDefinition, true) operation.application.getStrategicModel(modelName).withCloseable { smModel -> DataGridBuilder gridBuilder = smModel.dataGridBuilder() gridBuilder.addPov(smScenarioName) gridBuilder.addColumn(smYears as String[]) double millionsScalingFactor = 0.000001 // Push to Strategic Model grid.dataCellIterator('OFS_Product Revenue', 'FY17').each { DataCell productRevenue18 = it.crossDimCell('OFS_Product Revenue', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[it.accountName]], [it.data / millionsScalingFactor, productRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + pbcsToSMAccountNameMap[it.accountName] + ", " + it.data / millionsScalingFactor + ", " + productRevenue18.data / millionsScalingFactor) DataCell servicesRevenue = it.crossDimCell('OFS_Services Revenue', 'FY17') DataCell servicesRevenue18 = it.crossDimCell('OFS_Services Revenue', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[servicesRevenue.accountName]], [servicesRevenue.data / millionsScalingFactor, servicesRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + pbcsToSMAccountNameMap[servicesRevenue.accountName] + ", " + servicesRevenue.data / millionsScalingFactor + ", " + servicesRevenue18.data / millionsScalingFactor) DataCell adjRevenue = it.crossDimCell('OFS_Discounts', 'FY17') DataCell adjRevenue18 = it.crossDimCell('OFS_Discounts', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[adjRevenue.accountName]], [adjRevenue.data / millionsScalingFactor, adjRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + pbcsToSMAccountNameMap[adjRevenue.accountName] + ", " + adjRevenue.data / millionsScalingFactor + ", " + adjRevenue18.data / millionsScalingFactor) DataCell cosRevenue = it.crossDimCell('OFS_Total Cost Of Sales', 'FY17') DataCell cosRevenue18 = it.crossDimCell('OFS_Total Cost Of Sales', 'FY18') gridBuilder.addRow([pbcsToSMAccountNameMap[cosRevenue.accountName]], [cosRevenue.data / millionsScalingFactor, cosRevenue18.data / millionsScalingFactor]) println(it.yearName + ", " + cosRevenue.accountName + ": " + pbcsToSMAccountNameMap[cosRevenue.accountName] + ", " + cosRevenue.data / millionsScalingFactor + ", " + cosRevenue18.data / millionsScalingFactor) DataCell supportRevenue = it.crossDimCell('OFS_Support Revenue', 'FY17') DataCell otherRevenue = it.crossDimCell('OFS_Other Revenue', 'FY17') DataCell supportRevenue18 = it.crossDimCell('OFS_Support Revenue', 'FY18') DataCell otherRevenue18 = it.crossDimCell('OFS_Other Revenue', 'FY18') def totalRev17 = (supportRevenue.data / millionsScalingFactor) + (otherRevenue.data / millionsScalingFactor) def totalRev18 = (supportRevenue18.data / millionsScalingFactor) + (otherRevenue18.data / millionsScalingFactor) gridBuilder.addRow([pbcsToSMAccountNameMap[supportRevenue.accountName]], [totalRev17, totalRev18]) println(it.yearName + ", " + pbcsToSMAccountNameMap[supportRevenue.accountName] + ", " + totalRev17 + "," + totalRev18) } DataGridBuilder.Status status = new DataGridBuilder.Status() gridBuilder.build(status).withCloseable { smGrid -> println("Total number of cells accepted: $status.numAcceptedCells") println("Total number of cells rejected: $status.numRejectedCells") println("First 10 rejected cells: $status.cellsRejected") smModel.saveGrid(smGrid) } } //smModel close grid.close() } //for each entity.