Showing results for 
Search instead for 
Did you mean: 

SAPUI5 Analytical Table Binding issue

Former Member
0 Kudos

Hello Experts,

We need to design UI5 application by using Analytical Table because we need ALV features like Export, Grouping, Total, Sub Total, Sorting etc. So Designed ALV table by using AnalyticalTable Class but when we try to bind oData Service with Analytical Table, giving  below error and not displaying output.( if oData service is not used then this Analytical table is displaying empty table wihtout any errors.)

Error in F12 Debugger is:

Error in AnalyticalBinding - The QueryResult 'ZInvDataSet' could not be retrieved. Please check your service definition.

I am able to use same oData Service for Normal table (Class: sap.ui.table.Table) and everything working fine but ALV features are not coming.

So please find JS code below and provide your suggestions to fix this issue.

View JS Code:

var oPanel = new sap.ui.commons.Panel('Panel');

var oLayout = new sap.ui.commons.layout.MatrixLayout('layout');

var oTable = new sap.ui.table.AnalyticalTable({id:this.createId("ALVTable")}).addStyleClass('alternate-color');


            oTable.addColumn(new sap.ui.table.AnalyticalColumn({ Id: "InvNo",

                  label: new sap.ui.commons.Label({text: "Invoice No."}),

                  template: new sap.ui.commons.TextView().bindProperty("text", "InvNo").bindProperty("helpId","InvNo"),


                  sortProperty: "InvNo",

                  filterProperty: "InvNo"


            oTable.addColumn(new sap.ui.table.AnalyticalColumn({ Id: "SuppInvDate",

              label: new sap.ui.commons.Label({text: "Supp Inv Date"}),

              template: new sap.ui.commons.TextView().bindProperty("text", "SuppInvDate").bindProperty("helpId","SuppInvDate"),


              sortProperty: "SuppInvDate",

              filterProperty: "SuppInvDate"





Controller JS Code:

onInit: function() {

    var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZTEST_ODATA_SRV/", true);

    var view = this.getView();

    var oTable = view.byId("ALVTable");



Index HTML Code:




        <meta http-equiv="X-UA-Compatible" content="IE=edge">

        <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>


        <script src="resources/sap-ui-core.js"





        <!-- add sap.ui.table,sap.ui.ux3 and/or other libraries to 'data-sap-ui-libs' if required -->

   var view = sap.ui.view({id:"idZtest11", viewName:"Testalv.ViewALV", type:sap.ui.core.mvc.ViewType.JS});


    <body class="sapUiBody" role="application">

   <div id="content"></div>



View Entire Topic
Former Member
0 Kudos


   This issue was resolved by using Smart Table with type "AnalyticalTable" looks like it is not possible to use Analytical Table directly. Please find the sample code to define Analytical Table by using Smart Table.

var oTable = new sap.ui.comp.smarttable.SmartTable("SmartTable", {
   tableType : 'AnalyticalTable', 
   entitySet : 'SmartTableSet',
   useVariantManagement : false,

    beforeRebindTable: [function(oEvent)


    }, oController], //Created "onBeforeRebindTable" Method in Controller File

initialise: [function(oEvent) {oController.initialise(oEvent); }, oController],

//Created "initialise" Method in Controller File

dataReceived: [function(oEvent) {oController.onDataReceived(oEvent); }, oController],

//Created "onDataReceived" Method in Controller File

initiallyVisibleFields : 'Field1,Field2,Field3,Field4',   //Which Fields need to appear in output Initially 
header : 'Your Output Heading:', 
persistencyKey : 'ST',
enableAutoBinding : true,
showRowCount : false,
enableCustomFilter : true,

useExportToExcel : true,

customToolbar : new sap.m.Toolbar("button",

                    { enabled : true, content : new sap.ui.commons.Button({

                    text : "Email",

                    icon: "sap-icon://email",

                    style: sap.ui.commons.ButtonStyle.Emph,

                    tooltip : "Send Email",

                    height: "40px",

                    press :

                        [function(oEvent) { sap.ui.getCore().byId("Dialog1").open(); }], /          






In Controller File:

getModel: function(){ 

        var oDataUrl = "/sap/opu/odata/SAP/Your oData Service/";

        var oModel = new sap.ui.model.odata.v2.ODataModel(oDataUrl, true);


        var oView = this.getView();       




   hope this code useful.

Best Regards,

Sasidhar V.

Former Member
0 Kudos

Hey Sasidhar,

I am able to display the oData with the SmartTable, but the ALV funktions are not working properly, I annotated the Properties as aggregation-role dimension and measures and the EntityType sap:semantics as aggregated.

Is there something else I need to do or configure in the oData Service?

Former Member
0 Kudos

Hi Julian,

For totals and subtotals you have to check following code.

In Method “IF_SADL_GW_QUERY_CONTROL~SET_QUERY_OPTIONS” (Class DPC or DPC_EXT of oData Service) write following code:

io_query_options->set_aggregation( VALUE #(
( element = '<your numeric Field>' alias = 'VALUE'
type = if_sadl_gw_query_options=>co_aggregation_type-sum ) ) ).

And in “Define” Method (Class MPC or MPC_EXT of oData Service):

lo_property = lo_entity_type->get_property( '<your numeric Field>' ).
lo_annotation =
/iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-measure-measure ).

But if you are asking about Sorting, filter and Grouping functionalities and expecting to work these functionalities with standard code then you have to map odata EntitySet properties with Database table fields. If you are mapped EntitySet properties in odata with Function Module or BAPI fields then these functionalities will not work with standard code and you have to write custom code.

So currently to work ALL standard functionalities with standard code, we have created custom table and updating this table before executing standard code in Get_EntitySet Method (Class DPC or DPC_EXT).

Hope this info useful.

Thanks & Regards,

Sasidhar V.

0 Kudos

Hi Sasidhar,

Your inputs have been really helpful in implementing functionalities in the analytical table which has so limited documentation.

I noticed that in the analytical table after grouping the rows are somehow duplicated for each group.

You can refer the thread

Did you face a similar issue with grouping in analytical table and if so were you able to resolve it ?



Former Member
0 Kudos

Hi Melwyn,

  I have replied in another thread but pasting same here for future reference.

  I faced same issue but I am not remember exactly how I resolved, but please check below points.

1.  If you are mapping odata Entity set properties with Database table fields then make sure all Key fields are displaying on output. 

or if you are mapping with FM or BAPI fields then you have to write custom code for Sorting, filter and Grouping.

2. Make sure you have created Annotation for ALL output fields in oData Service ("Define" Method in MPC_EXT Class). Sample code shown below.

     DATA(lo_property) = lo_entity_type->get_property( 'GeneratedId' ).
     DATA(lo_annotation) = lo_property->/iwbep/if_mgw_odata_annotatabl~create_annotation(
     /iwbep/if_mgw_med_odata_types=>gc_sap_namespace ).
     iv_key = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_key-aggregation_role
     iv_value = /iwbep/if_ana_odata_types=>gcs_ana_odata_annotation_value-dimension-dimension ).

*" Hide Field

     iv_key = 'visible' iv_value = 'false' ).

3. Make sure GeneratedId (ABAP Field name is GENERATED_ID) created as a key field in oData Service and this is the only key field in oData Service.

Hope this info helpful.

Thanks & Regards,

Sasidhar V.