cancel
Showing results for 
Search instead for 
Did you mean: 

SAP MII/SAPUI5 using ODataModel with a Table

Former Member
0 Kudos

Hello,

We are trying to use the OData service in MII to create an ODataModel in SAPUI5 to populate a Table.  We are currently on SAP MII 15.0 SP3 Patch 2.

We have a Query in MII named: ODataTest\messages

We are using the OData Help Page, and are using the URL: http://server:port/XMII/IlluminatorOData/Rowsets('ODataTest/messages')/Rowset

This url works in the web browser as well as in an HTTP Post Action Block, and returns with the records that are expected.  The problem comes when we try using it in an ODataModel in SAPUI5. 


var oModel  = new sap.ui.model.odata.ODataModel("http://server:port/XMII/IlluminatorOData/Rowsets('ODataTest/messages')/Rowset");

We get an error on the line above trying to retrieve the metadata information:

http://server:port/XMII/IlluminatorOData/Rowsets('ODataTest/messages')/Rowset/$metadata

From the help page above the metadata should be fetched from http://server:port/XMII/IlluminatorOData/$metadata, however I do not think we can manually override where SAPUI5 looks for the metadata. 

Does someone know what we do in order to get the ODataModel working an MII Query?  We have tried different types of queries (FixedQuery, ExecuteQuery, etc) in MII, and we can access them all in the browser, but fail when creating the ODataModel. Thank You

Regards,

Jacob

Accepted Solutions (1)

Accepted Solutions (1)

Private_Member_14935
Active Participant
0 Kudos

Hi Jacob,

You could try the below snippet:

In the example below columns get bound dynamically with the columns in the query result. If you already know the columns to be mapped then you could chose the columns to bind individually.

var oDataURL = "http://server:port/XMII/IlluminatorOData?QueryTemplate=ODataTest/messages";

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

var oTable = new sap.ui.table.DataTable({

id : "queryTable",

title: "MII Query Data",

width : "100%",

selectionMode : sap.ui.table.SelectionMode.Single});

//Table Column Definitions

    var oMeta = oModel.getServiceMetadata();

          var oControl;

         

     for ( var i = 0; i < oMeta.dataServices.schema[0].entityType[2].property.length; i++) {

     var property = oMeta.dataServices.schema[0].entityType[2].property[i];

    

           oControl = new sap.ui.commons.TextField().bindProperty("value",property.name);

           oTable.addColumn(new sap.ui.table.Column({label:new sap.ui.commons.Label({text: property.name}), template: oControl}));

       }

var oTable = sap.ui.getCore().byId("queryTable");

oTable.setModel(oModel);

//Bind the Data to the Table

oTable.bindRows("/Rowset(QueryTemplate='ODataTest/messages',RowsetId=1)/Row");

oTable.placeAt('tableId');

Hope this helps!

Thanks and Best Regards,

Ria

Former Member
0 Kudos

Thank you Ria,

This was very helpful and we were able to get the data into the table.  However, we are still getting an error when the Table is asking for the count from the server:

http://server:port/XMII/IlluminatorOData/Rowset(QueryTemplate='ODataTest/messages',RowsetId=1)/Row/$...

The error we get is 'Not Implemented'.  So, does this mean that the count is not implemented in MII? and if not, then will that cause issues for the Paginator used for the table?  Thank you.

Regards,

Jacob

Private_Member_14935
Active Participant
0 Kudos

Hi Jacob,

Yes, the error that you see is because Count method is not implemented in MII oData service. When oData model is bound to the SAP ui5 table, I think it might expect these methods to be implemented, which might cause problems to pagination as mentioned by you. However, I haven't tried it yet to be certain.

Do update if you find something on this.

Thanks and Best Regards,

Ria

alex_dim
Explorer
0 Kudos

Hi Jacob,

Do you find a fix for this issue? I am experiencing the same problem. Also, I tried already to add pagination for the table, but, an additional issue would be that once I reach the last entry, the pagination starts again with the start of the table.

BR,

Alex

Former Member
0 Kudos

There was no fix for this issue.  SAP informed me that there was no plan to implement the missing features so we decided not use SAPUI5 for that project.

Answers (0)