Skip to Content
0

how to call GetEntity method from SAPUI5

Apr 09 at 02:44 PM

78

avatar image

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)
10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

4 Answers

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

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

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Thanks for you reply Simphiwe Tshabalala take a look of my post again please.

0
Tri Minh Le Apr 09 at 11:23 PM
1

Hi Naoto,

Can you put debug in success and error callbacks?

Regards,

Tri

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Tri Minh Le, thanks for you reply i updated my post

0

the problem was that i use step over next function call instead step jejeje, please check my update

0
Sarbjeet Singh Apr 09 at 11:52 PM
1

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

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hello Sarbjeet Singh, i try take a look again to my post i updated.

I put a break but never stop it there

0

the problem was that i use step over next function call instead step jejeje, please check my update

0

Execute it further it will for sure come in either success or error afterwards (because of async call).

put the break point in error also.

Regards

0
Sergio Guerrero Apr 09 at 03:49 PM
1

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

the Set part gets appended when querying the service

Show 1 Share
10 |10000 characters needed characters left characters exceeded

Hello Sergio Guerrero, thanks for your reply. Do you have an exmaple ? consulting a get_entity method from sapui5?

0