Groovy - Data push and Smart push support for (E)PBCS - Part 1 Smart Push

Hello folks,

Follow up post of my earlier post https://uniquehyperionsolution.blogspot.in/2017/09/groovy-simple-script-to-move-data-from.html on Groovy script where I demonstrated use of Groovy to move data from one cube to another cube. The disadvantage of that script was it moved only the data which was there in the form.

Oracle in their latest Nov patch update (http://www.oracle.com/webfolder/technetwork/tutorials/tutorial/cloud/pbcs/1711-pbcs-wn.htm) release a Groovy script to call Data Push and Smart Push.

Today, I am going to show some examples on how that can be used.

1. Push only edited cells on Data Form (Smart Push)

//Get current Data Form
DataGrid curGrid = operation.Grid

//Additional step to check whether the data map exists
if(! operation.application.hasDataMap('BSO to ASO')) {
println ("Datamap BSO to ASO not found")
    return
}

// Holds the value for the cells that have changed
Set<String> entityList = []
Set<String> partnerList = []
Set<String> productList = []
Set<String> periodList = []
Set<String> accountList = []
Set<String> scenarioList = []
Set<String> versionList = []
Set<String> costcenterList = []
Set<String> dsList = []
Set<String> yearList = []

// Iterater which gives you only the edited cells
curGrid.dataCellIterator({DataCell cell -> cell.edited}).each { DataCell cell ->
  if (cell.getPeriodName() in ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'] ){
    println("""$cell.memberNames, cell data: $cell.data""")
    periodList  << cell.getPeriodName()
    entityList  << cell.getEntityName()
    partnerList << cell.getMemberName("Partner")
    productList << cell.getMemberName("Product")
    accountList << cell.getAccountName()
    scenarioList << cell.getScenarioName()
    versionList << cell.getVersionName()
    costcenterList << cell.getMemberName("Cost Center")
    dsList << cell.getMemberName("DS")
    yearList << cell.getYearName()
  }
}

// Holds the list of members from the POV – the function returns an array, so this
// parsed the array and places quotes around each member and separates them with a comma
// if cells are edited only then go for smart push
if (entityList) {
  String sEntities = """ "${entityList.join('","')}" """
  String sPartners = """ "${partnerList.join('","')}" """
  String sProducts = """ "${productList.join('","')}" """
  String sPeriods  = """ "${periodList.join('","')}" """
  String sAccounts  = """ "${accountList.join('","')}" """
  String sScenario  = """ "${scenarioList.join('","')}" """
  String sVersion  = """ "${versionList.join('","')}" """
  String sCostCenter  = """ "${costcenterList.join('","')}" """
  String sDS = """ "${dsList.join('","')}" """
  String sYears = """ "${yearList.join('","')}" """

  println ("SmartPush started")
  println ("Account : $sAccounts, Cost Center: $sCostCenter, DS: $sDS, Partner: $sPartners, Product: $sProducts, Scenario: $sScenario, Entity: $sEntities, Years: $sYears, Version: $sVersion")

//Create smartpush and then execute
def smartpush = operation.application.getDataMap('BSO to ASO').createSmartPush()
// Loop through currency list for every currency execute the datamap with overrides
['EUR','USD'].each { String sCurrency ->
println("Currency = $sCurrency")
    smartpush.execute(["Account":sAccounts, "Cost Center":sCostCenter, "DS":sDS, "Partner":sPartnera, "Product":sProducts, "Scenario":sScenario, "Currency":sCurrency, "Entity":sEntities, "Years":sYear, "Version":sVersion])
}
  println ("SmartPush completed")
} else {
println("Smart Push not executed: No cells were edited ")
}

You can see how powerful the script is, it pushes only those cells which are edited and loops through currency (EUR and USD). This opens all new doors to control your smart push. You can club this with Data validations.

In the next post will demonstrate how Data Push can be done using groovy script.

Hope you enjoyed it :)

Cheers
-- 

Comments