Skip to Content

how to call GetEntity method from SAPUI5

Hi community, i have a problem be cause i know how to consult get_entityset method

// /sap/opu/odata/sap/ZERP_ACTIVIDADES_SRV/ReservaSet?$filter=Asesor
eq '10000324'	    		
                        var asesor = sessionStorage['asesor'];
	    		var oTable = this.getView().byId("tabla");
	    		var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
	    		var oDataModel = new ODataModel(sURI, true);
	    		var oModel = new sap.ui.model.json.JSONModel();
	    		var oFilter = new Filter("Asesor", "EQ", asesor);
	    		oDataModel.read("/ReservaSet", {
	    			filters: [oFilter],
	    			success: function(oData, response) {
	    	        var oResults = oData.results;
	    	        oModel.setData(oData.results);
	    	        oTable.setModel(oModel);
	    			 }
	            });

but what if i want to consult this

/sap/opu/odata/sap/ZERP_ACTIVIDADES_SRV/TileInfoSet('10002122')

is not the same and it's simpler but i tried this withouth success

	        var x = 10002122;
                var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
    		var oDataModel = new ODataModel(sURI, true);
    		var oModel = new sap.ui.model.json.JSONModel();
//    		var oFilter = new Filter("title", "EQ", x);
    		oDataModel.read("/TileInfoSet" + "('" + x + "')", {
//                      filters: [oFilter],
    			success: function(oData, response) {
    	        var oResults = oData.results;
    	        oModel.setData(oData.results);  	        
    			 }
    		});



i tried this also:


	        var sURI = "/sap/opu/odata/SAP/ZERP_ACTIVIDADES_SRV";
    		var oDataModel = new ODataModel(sURI, true);
    		var oModel = new sap.ui.model.json.JSONModel();
    		var oFilter = new Filter("('" + x + "')");
    		oDataModel.read("/TileInfoSet", {
    			filters: [oFilter],
    			success: function(oData, response) {
    	        var oResults = oData.results;
    	        oModel.setData(oData.results);  	        
    			 }
    		});


and i've tried some variants of this , can someone guide me ?

and it tells me that oData is not defined too.

UPDATE.

i think the problem is in the app ui5, i put a break in my odata and it's receiving the parameter:

and this is some screen of my network tab and console:

UPDATE.

This is my view

and when i put a break in the success function never get in, just jump to line 188 (message.setText (this line is for test))

this is the debug of odatamodel.read

this is the responde of the handlerequest

Final UPDATE.

after debug for 1 hour :O there are my functios and i read them ver detaily jaja i retrieve these:

oModel.setData(oData);

instead

oModel.setData(oData.results);

Exmaple: console.log(oData.icon) // sap-icon://appointment

i don't know exctly why be cause i had used like this "oData.results" without problem, well new learning, only doubt that i have is why my tile works fine in the launchpad designer but is not updated in my launchad as a user ???? :/

error.png (27.4 kB)
error-tile2.png (7.6 kB)
error-tile-3.png (33.8 kB)
error-tile.png (16.0 kB)
viewtile.png (28.7 kB)
successdebug.png (25.7 kB)
debugsuccess.png (87.1 kB)
requesthandle.png (30.6 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Apr 09 at 06:55 PM

    Hi Naoto, please take a screen grab of the network response , as the issue could be the service url

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 09 at 11:23 PM

    Hi Naoto,

    Can you put debug in success and error callbacks?

    Regards,

    Tri

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 09 at 11:52 PM

    I guess problem is with your binding in the view.

    Please share the code for that.

    Your odata call is working fine.

    you are getting odata not defined because you are checking it in some other js call. You need to be in the put a breakpoint in the success-handler function to get this value.

    Regards,

    Sarbjeet Singh

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 09 at 03:49 PM

    did you try the end point to be, "/TileInfo" instead of "/TileInfoSet" ?

    the Set part gets appended when querying the service

    Add comment
    10|10000 characters needed characters exceeded