cancel
Showing results for 
Search instead for 
Did you mean: 

manipulating data returned by Odata service

Former Member
0 Kudos

Hi All,

https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/ODataModel.html

As per the above link,

I could infer that OdataModel is a server side model .

Is it possible to manipulate the Odata result before feeding it to UI component ?

ie Example,

A Odata service returns a set of key values pairs ,i want to remove the rows for which description of key is not available

After removing the unwanted rows , i want to feed it to UI 5 table component

Fro another Odata service , i want to convert the json object into another json abject of desired structure before feeding it to Pie Chart component .

Is manipulation possible in Server side model like OdataModel?

Regards,

Madhumitha

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Madhumitha,

You can get the result into an array for maniuplate it. When you've got it, you can parse it to a custom array for do the data binding. This is an example:

var auxArray = new Array();

                    odmDataModel.read("/XXXXX",

                                        null, null, false, function(oData, oResponse){

                              auxArray = oData;

                    });

                    var myDataBinding = new Array();

                    for(var i = 0; i < auxArray.length; i++){

                              //SOME PARSE TO YOUR CUSTOM DATABINDING

                    }

                    var jsonModelCustomJSONModel = new sap.ui.model.json.JSONModel();

                    jsonModelCustomJSONModel.setData({data: myDataBinding});

                    table.setModel(jsonModelCustomJSONModel);

                    table.bindRows("/data");

Regards

Jose Manuel

Former Member
0 Kudos

Hi Jose ,

Thanks for your timely  help

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi ,

I am working withe same kind of request.I need to assign the values of Odata model / JSON Model to an array.

  odmDataModel.read("/XXXXX"


which value i have to give for XXXXX ??



Thanks,

Sandeep

Former Member
0 Kudos

XXXXX is the last part of the OOdata URL .

XXXXX is the EntitySetName with or without query param.

If you still cannot understand , reply back with the Odata URL you used to test the Odata service in the REST client .

Former Member
0 Kudos

Hi Madumitha ,

My Odata URL will look like this,

var url = "/xxx/xxx/services.xsodata/uid(xid=" + xid + ",y_id=" + y_id + ",xx_id=" + xx_id +

  ",yy_id=" + yy-id + ",xxx_id=" + sessionStorage.getItem("xxx_id") + ",yyy_id=" + sessionStorage.getItem(

  "yyy_id") + ")/Results/?$format=json";

can you please which part is entity set in URL ?

thanks,

Sandeep

former_member184238
Participant
0 Kudos

Hi Madhumitha,

You can change the JSON object from one form to another form  by using formatter .

Please refer below link.

https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/BindingProperties.html

Thanks&Regards

Sridevi