SAC scripting for tables

Filter main table based on commenting model page filter:

function onSelect() : void

//on Input Control select

var BA = InputControl_3.getInputControlDataSource().getActiveSelectedMembers()[0];
console.log(BA.displayId);

var chk = InputControl_3.getInputControlDataSource().isAllMembersSelected();

if (chk===false)
{
//apply BA filter
Table_4.getDataSource().setVariableValue("ABU_00",BA.displayId);
console.log(chk);
}

if (chk===true)
{
// clear BA filter
Table_4.getDataSource().setVariableValue("ABU_00",[]);
console.log(chk);
}

Get all dimension info:

//on page initialize

var xyz=Table_3.getDataSource().getDimensions();
console.log(xyz);

Filter table & comments based on page Quarter filter:

//Month
var getMonth=InputControl_2.getInputControlDataSource().getActiveSelectedMembers();
console.log("Month:");
console.log(getMonth[0].id);
console.log(getMonth[0].description);
//Year
var getYear=InputControl_1.getInputControlDataSource().getActiveSelectedMembers();
console.log("Year:");
console.log(getYear[0].id);
console.log(getYear[0].description);
var yy=(getYear[0].id.substring(0,4));
console.log("yy:");
console.log(yy);
//refresh table
if(getMonth[0].id === "10"){
  Table_1.getDataSource().setVariableValue("V_FPER", yy+"0" + getMonth[0].id);
console.log("yy:"+"single zero");
}
else if(getMonth[0].id === "11"){
  Table_1.getDataSource().setVariableValue("V_FPER", yy+"0" + getMonth[0].id);
console.log("yy:"+"single zero");
}
else if(getMonth[0].id === "12"){
  Table_1.getDataSource().setVariableValue("V_FPER", yy+"0" + getMonth[0].id);
console.log("yy:"+"single zero");
}
else
{
Table_1.getDataSource().setVariableValue("V_FPER", yy+"00" + getMonth[0].id);
console.log("yy:"+"double zero");
}

Get model id:

//get model id
var tt=Application.getInfo();
console.log(tt);

// get fiscal year
var p1=Table_WorkingCapital.getDataSource().getVariableValues("V_FPER")[0];
console.log(p1);

var xx=Table_30.getDataSource().getDimensions();
console.log(xx);

// set story filter & refresh table
Table_WorkingCapital.getDataSource().setVariableValue("V_FPER",yy+"00"+mnth2);

//Application.getFileDataSource("B9006B832A7049795432AB51DEFB002D").setVariableValue("V_FPER",p1);
Table_WorkingCapital.getDataSource().refreshData();

Filter Dimensions in table:

var v_memberInfos = ArrayUtils.create(Type.MemberInfo);
v_memberInfos.push({id:"US",description:""});
v_memberInfos.push({id:"DE",description:""});
Table_1.getDataSource().setDimensionFilter("ZCNTRY",v_memberInfos);

Filter Measures in table:

//Filter specific measure in table
var v_memberInfos = ArrayUtils.create(Type.MemberInfo);
v_memberInfos.push({id:"6MU9WYQ1ZB8C1B5OA6R0CZPPW",description:"2408A"});
Table_57.getDataSource().setDimensionFilter("@MeasureDimension",v_memberInfos);
//remove measure filter from table
Table.removeDimension(Alias.MeasureDimension); Table.getDataSource().removeDimensionFilter(Alias.MeasureDimension);
//add measure filter from table
Table.addDimensionToColumns(Alias.MeasureDimension); Table.getDataSource().setDimensionFilter(Alias.MeasureDimension,"Id of the measure");
//------------------------------------------------------------------------
var measures = Table_57.getDataSource().getMeasures();
var measure = measures[0];
console.log(measure.description);
console.log(measure.dimensionId);
console.log(measure.id);
console.log(measure.modelId);
//------------------------------------------------------------------------
// practical example:

var array = Table_57.getDataSource().getResultSet();
console.log(array);
console.log(array[0]);
console.log(array[0][Alias.MeasureDimension].id);
var v_memberInfos = ArrayUtils.create(Type.MemberInfo);
//"2408A"
v_memberInfos.push({id:array[0][Alias.MeasureDimension].id,description:array[0][Alias.MeasureDimension].description});
//"2308A"
v_memberInfos.push({id:array[1][Alias.MeasureDimension].id,description:array[1][Alias.MeasureDimension].description});
//"YoY"
v_memberInfos.push({id:array[2][Alias.MeasureDimension].id,description:array[2][Alias.MeasureDimension].description});
//"2312A FY"
v_memberInfos.push({id:"6MU9WYQ1ZB8AB0S0LQWY98TOW",description:"2312A FY"});
Table_57.getDataSource().setDimensionFilter("@MeasureDimension",v_memberInfos);

Add or remove dimension from table:

var sel = DropDown_1.getSelectedKey();
Table_1.getDataSource().removeDimensionFilter("Dim1");
Table_1.getDataSource().setDimensionFilter("Dim1",sel);
Table_1.addDimensionToRows("CustomerUnit",2);
Table_1.removeDimension("CustomerAccountGroup");
Table_1.removeDimension("CustomerReportingGroup");
Table_1.removeDimension("Version");
Table_1.removeDimension("TopContributor");

Get specific measure from table:

//Using a table with 1 dimension & 1 measure this seems to work
var arr = Chart_1.getDataSource().getResultSet();
var value = ArrayUtils.create(Type.number);
for (var i=0;i<arr.length;i++)
{var string = arr[i][Alias.MeasureDimension].formattedValue;
     var number = ConvertUtils.stringToNumber(string);
     value.push(number);}  
console.log(value);

Get specific dimension from table:

var str="";
var selections = Chart_1.getDataSource().getDataSelections();
console.log(selections);
for (var i=0; i<selections.length; i++){
str =str+selections[i].EmployeeUserName+";";
};
console.log(str);

Drill down table:

//Table_1 - onSelect:
Application.setAutomaticBusyIndicatorEnabled(true);
var NoDim=Table_1.getDimensionsOnRows().length;
console.log(NoDim);
SelectionArray_Table1 = Table_1.getSelections();
var CurrentCoCd = SelectionArray_Table1[0]["0COMP_CODE"];
var CurrentGL = SelectionArray_Table1[0]["0GL_ACCOUNT"];
var CurrentDocNo = SelectionArray_Table1[0]["LFIN_DOC"];
console.log(CurrentCoCd);
console.log(CurrentGL);
console.log(CurrentDocNo);
Table_1.getDataSource().setRefreshPaused(true);
if (NoDim===1){
Table_1.getDataSource().setDimensionFilter("0COMP_CODE",CurrentCoCd);
Table_1.addDimensionToRows("0GL_Account",2);
}
if (NoDim===2){
Table_1.getDataSource().setDimensionFilter("0GL_ACCOUNT",CurrentGL);
Table_1.addDimensionToRows("0DOC_DATE",3);
Table_1.addDimensionToRows("LFIN_DOC",4);
Table_1.addDimensionToRows("0ORG_DOC_NO",5);}
if (NoDim===5){
Table_1.getDataSource().setDimensionFilter("0GL_ACCOUNT",CurrentGL);
Table_1.addDimensionToRows("0FISCPER",3);
Table_1.addDimensionToRows("0DOC_CURRCY",7);
Table_1.addDimensionToRows("0LOC_CURRCY",8);
Table_1.addDimensionToRows("0ALLOC_NMBR",9);
Table_1.addDimensionToRows("CBKTXT",10);
Table_1.addDimensionToRows("0POSTXT",11);
Table_1.addDimensionToRows("0DCINDIC",12);
}
if (NoDim===12){
Table_1.getDataSource().setDimensionFilter("0GL_ACCOUNT",CurrentGL);
}
Table_1.getDataSource().setRefreshPaused(false);
Table_1.getDataSource().refreshData();
//Button_RemoveDimension2:
Application.setAutomaticBusyIndicatorEnabled(true);
var NoDim=Table_1.getDimensionsOnRows().length;
console.log(NoDim);
Table_1.getDataSource().setRefreshPaused(true);
if (NoDim===1){
}
if (NoDim===2){
Table_1.removeDimension("0GL_ACCOUNT");
Table_1.getDataSource().removeDimensionFilter("0COMP_CODE", CoCdArray);
}
if (NoDim===5){
Table_1.removeDimension("0DOC_DATE");
Table_1.removeDimension("LFIN_DOC");
Table_1.removeDimension("0ORG_DOC_NO");
Table_1.getDataSource().removeDimensionFilter("0GL_ACCOUNT");
}
if (NoDim===12){
Table_1.removeDimension("0FISCPER");
Table_1.removeDimension("0DOC_CURRCY");
Table_1.removeDimension("0ALLOC_NMBR");
Table_1.removeDimension("0POSTXT");
Table_1.removeDimension("0DCINDIC");
Table_1.removeDimension("0DOC_CURRCY");
Table_1.removeDimension("0LOC_CURRCY");
Table_1.removeDimension("CBKTXT");
}
Table_1.getDataSource().setRefreshPaused(false);
Table_1.getDataSource().refreshData();
//WelcomeChart3 - onSelect:
Application.setAutomaticBusyIndicatorEnabled(true);
Table_2.getDataSource().setDimensionFilter(Alias.MeasureDimension,["6MU9W....","6MU9W...."]);
Table_2.getDataSource().setDimensionFilter("0GL_ACCOUNT",GACaccounts1);
Table_2.addDimensionToRows("0GL_ACCOUNT");
GAC_Open_Items.setSelectedKeys('Tab_2');

एक टिप्पणी भेजें

0 टिप्पणियाँ