Technical Articles
Custom Selection for Analytical Report
Introduction
Multidimensional /Analytical reports(using Design Studio) currently don’t have provision to store selection parameter values in a variant.To avoid this limitation, we developed a Fiori list report to provide the selection screen for the user and save selection screen values in view if needed and a custom button to execute the analytical report from the list report. The blog here explains the steps for manually navigating to multidimensional report result screen without displaying the query prompt screen.
The list report was created from the odata service generated from same CDS view used for analytical report. So the reports shared same parameter names for filter values.
How to pass values to Analytical Report
Analytical Report accepts parameters in the following format(This is one of the format, there may be other formats available for passing the parameters):
{"selectionVariant":{"SelectOptions":[{
"PropertyName":"ChartOfAccounts","Ranges":[
{"Sign":"I","Low":"CACG","LowType":"STRING","Option":"EQ"}]},
{"PropertyName":"ProfitCenter","Ranges":[
{"Sign":"I","Low":"12725","LowType":"STRING","Option":"EQ"},
{"Sign":"I","Low":"12726","LowType":"STRING","Option":"EQ"},
{"Sign":"I","Low":"12728","LowType":"STRING","Option":"EQ"},
{"Sign":"I","Low":"12729","LowType":"STRING","Option":"EQ"}]}]}}
To manually pass the values to analytical report we need to generate query string in the above format.
If there are more values selected by user, we have a long URL with all selected values. Instead we can pass parameters using sap-xapp-state-data as below. As a result the parameters are passed through a sap-xapp-state id field generated by the application.
var t = sap.ushell.Container.getService("CrossApplicationNavigation");
t.toExternal({
target: {
semanticObject: "<AnalyticalReportSemanticObject>",
action: "<AnalyticalReportSemanticObjectActionName>"
},
params: {
"sap-xapp-state-data": JSON.stringify({
"selectionVariant": {
"SelectOptions":[{"PropertyName":"prctr",
"Ranges":parms[{"Sign":"I","Low":"12736","Option":"EQ"}]}]}})});
Steps to extend list report and add navigation to analytical report
- Extend List Report to add custom button to the report
- Go to List report extension controller
- Write following code to dynamically read all selected values and construct the property values for analytical report.
getParams: function (e) {
var t ="<listreport-filterid>";
var a = this.getView().byId(t);
var r = a.getFilterData();
var i = Object.keys(r);
var o, arr_op = [],
arr_sel = [];
for (var n = 0; n < i.length; n++) {
arr_op = [];
if (r[i[n]].items.length !== 0) {
var l = r[i[n]].items;
for (var p = 0; p < l.length; p++) {
o = {
"Sign": "I",
"Low": l[p].key,
"Option": "EQ"
};
arr_op.push(o);
}
} else if (r[i[n]].ranges.length !== 0) {
var c = r[i[n]].ranges;
for (var p = 0; p < c.length; p++) {
if (c[p].exclude === false) {
o = {
"Sign": "I",
"Option": c[p].operation,
"Low": c[p].value1,
"High": c[p].value2
};
} else {
o = {
"Sign": "E",
"Option": c[p].operation,
"Low": c[p].value1,
"High": c[p].value2
};
}
arr_op.push(o);
}
}
if (arr_op.length > 0) {
arr_sel.push({
"PropertyName": i[n],
"Ranges": arr_op
});
}
}
return arr_sel;
}
- Add following code in onAction method of the custom button to do the navigation.
onClickActionZCR2R_DSOQUERYResults1: function (oEvent) { var selParms = this.getParams(); var t = sap.ushell.Container.getService("CrossApplicationNavigation"); t.toExternal({ target: { semanticObject: "ZR2R_DSO", action: "display" }, params: { "sap-xapp-state-data": JSON.stringify({ "selectionVariant": { "SelectOptions": selParms } }) } }); }
- Add following in launchpad configuration of analytical report to provide “Jump to” target to list report:
Conclusion:
This blog is useful for the scenarios where we need to programmatically navigate to analytical reports. Instead of list report, we can develop custom UI5 application to provide the selection screen for the report.
As per SAP note#2847056 variant management and state managent are isolated from each other.
Your requirement is state management which is easy to handle using "Send Email" or "Save as Tile" option rather than custom list report just to store selection parameters.
Thanks Anup. Yes "Send Email" or "Save as Tile" are some of the options to save selection field values. But it does't give flexibility to users to modify the values in the saved tile in future and its not always feasible to create multiple tiles for storing different set of values for running the report.