on ‎2015 Jan 09 7:52 PM
I have got all the data from Gateway Server to my SAPUI5 program. Now, I dont want to show all the data which I got but want to show only one particular line item. I tried putting filter but it is not working.
Can some one please help me how to use filter in OData model. Please note that I am trying to filter at client side and not at server side
Request clarification before answering.
Hello All,
Firstof all thanks for the help provided by all of you which made me learn baby steps in creating a OData service and access it through SAP UI5 program. I am almost done but have one last stage issue, request your help.
I have implemented getEntity() method so that I can pass a parameter in the URL and get the line item related to that URL. The below URL is working fine when I execute it from browser or from netweaver gateway server directly .... below is the URL which works fine (reads a specific record as per URL parameter)
http://<NetWeaver Gateway Domain>:8000/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet('123098')
The above URL gives me one expected entry in XML format.
However, if I use below code in my SAPUI5 program it still retrives all the three records. Please see below code.
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/");
oModel.read("/UserInfoSampleSet('123098')/");
var oTable = new sap.ui.table.Table({width : "100%", visibleRowcount : 5});
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "UserID"}), template : new sap.ui.commons.TextView({text : "{Zuserid}"})}));
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "User Address"}), template : new sap.ui.commons.TextView({text : "{Zaddr}"}), visible : true}));
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Country"}), template : new sap.ui.commons.TextView({text : "{Zcountry}"}), visible : true}));
oTable.setModel(oModel);
oTable.bindRows({path : "/UserInfoSampleSet"});
return oTable;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You are binding the table to the "/UserInfoSampleSet" path which will return all the collection of results.
oTable.bindRows({path : "/UserInfoSampleSet"});
If I understand correctly you want to only display the single item, which you should use the filter. The table needs to be bound to a collection rather than individual entity.
Regards,
Jason
I have to slightly disagree here but correct me if I am wrong.
I have implemented getEntity() method which basically takes an input (like Emp ID) and then queries the database and gives back that particular record. I can say that the getEntity() method is working as I am getting the expected result using below URL which I ran in browser as well as in gateway client.
http://<NetWeaver Gateway Domain>:8000/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet('123098')
oTable.bindRows(),...I guess this method is not going to the server,...it binds the data which OData has already retrieved to the SAPUI5 program from gateway server.
I guess I should be using oModel.read() .... but not sure how to pass parameters to achieve expected result.
Having said that,...I also tried below way but in vain. This gave me 'No Data'. I have checked the 'filter' check-box of the property Zuserid.
oTable.bindRows({path: "/UserInfoSampleSet?$filter=Zuserid eq '123098'"});
Hi,
How about using something like this:
oTable.bindAggregation("items","/UserInfoSampleSet",oTableItems,null,oFilter);
where oTableItems is the instance of sap.m.ColumnListItem
and oFitler = new sap.ui.model.Filter("Zuserid", "EQ",'123098')
Also make sure the Zuserid has a the same case as in your oData model entity properties.
Hope this helps.
Just to clarify:
I don't understand you metadata, is the unique identifier Zuserid or scid? I would recommend checking the HTTP request has the correct parameters being passed to gateway and then ensure you have the necessary filtering mechanism setup in gateway.
Regards,
Jason
Let me explain you Jason.
Since I had an issue with my previous example I thought of creating a new service....which is below.
'Zuserid' field is the Key..
My MetaData when I used URL : http://domain:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/$metadata
----------------
<edmx:Edmx xmlns:edmx="http://schemas.microsoft.com/ado/2007/06/edmx" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"xmlns:sap="http://www.sap.com/Protocols/SAPData" Version="1.0">
<edmx:DataServices m:DataServiceVersion="2.0">
<Schema xmlns="http://schemas.microsoft.com/ado/2008/09/edm" Namespace="ZUI5_SAMPLEUSERINFO_SRV" xml:lang="en" sap:schema-version="0000">
<EntityType Name="UserInfoSample" sap:content-version="1">
<Key>
<PropertyRef Name="Zuserid"/>
</Key>
<Property Name="Zuserid" Type="Edm.String" Nullable="false" MaxLength="12" sap:label="Chgd by" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
<Property Name="Zaddr" Type="Edm.String" Nullable="false" MaxLength="50" sap:label="Address" sap:creatable="false" sap:updatable="false" sap:sortable="false"sap:filterable="false"/>
<Property Name="Zcountry" Type="Edm.String" Nullable="false" MaxLength="50" sap:label="Address" sap:creatable="false" sap:updatable="false" sap:sortable="false"sap:filterable="false"/>
</EntityType>
<EntityContainer Name="ZUI5_SAMPLEUSERINFO_SRV_Entities" m:IsDefaultEntityContainer="true">
<EntitySet Name="UserInfoSampleSet" EntityType="ZUI5_SAMPLEUSERINFO_SRV.UserInfoSample" sap:creatable="false" sap:updatable="false" sap:deletable="false" sap:pageable="false"sap:content-version="1"/>
</EntityContainer>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="self" href="http://domain:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/$metadata"/>
<atom:link xmlns:atom="http://www.w3.org/2005/Atom" rel="latest-version" href="http://domain:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/$metadata"/>
</Schema>
</edmx:DataServices>
</edmx:Edmx>
-----------------
Now I used URL to test my getEntity() function which I implemented and it worked fine. URL is : http://domain:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet('123098')
-------------------
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xml:base="http://nwcedev1.amat.com:8000/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/">
<id>
http://domain:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet('123098')
</id>
<title type="text">UserInfoSampleSet('123098')</title>
<updated>2015-01-14T19:12:09Z</updated>
<category term="ZUI5_SAMPLEUSERINFO_SRV.UserInfoSample" scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme"/>
<link href="UserInfoSampleSet('123098')" rel="self" title="UserInfoSample"/>
<content type="application/xml">
<m:properties>
<d:Zuserid>123098</d:Zuserid>
<d:Zaddr>SORENIA STREET</d:Zaddr>
<d:Zcountry>SOMANIA</d:Zcountry>
</m:properties>
</content>
</entry>
-------------------
So whatever I am able to fetch using the above url (getting ne specific record) is what I what I want to achieve using my SAPUI5 program. Please advise.
What do you get if you try the following URL?
http://xxxx:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet$filter=Zuserid eq '123098'
If it returns the 3 results I expect that the filter code hasn't been implemented in the
_GET_ENTITYSET method? i.e. Task 2 in the document.
if you are trying to display in a table you will need to bind to the EntitySet i.e. "/UserInfoSampleSet"
Regards,
Jason
So Jason,...the filter need to be implemented in _GET_ENTITYSET method ? I thought it needs to be implemented in _GET_ENTITY METHOD.
When I use below URL
http://nwcedev1.amat.com:8000/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet$filter=Zus... eq '123098'
I am getting below error message
<error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<code>005056A509B11EE1B9A8FEC11C21D78E</code>
<message xml:lang="en">
Resource not found for the segment 'UserInfoSampleSet$filter=Zuserid%20eq%20'123098''.
</message>
<innererror xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<transactionid>54B6DF5C7E800A10E10000000A298945</transactionid>
<timestamp>20150115072944.2021590</timestamp>
<Error_Resolution>
<SAP_Transaction>
Run transaction /IWFND/ERROR_LOG on SAP NW Gateway hub system and search for entries with the timestamp above for more details
</SAP_Transaction>
<SAP_Note>
See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)
</SAP_Note>
</Error_Resolution>
</innererror>
</error>
I will also go through the link provided by you. Thanks again Jason..
Hi Chandrasekhar
I infact have created my OData service using your blog only.Thanks for that first.
However, in your blog you have implemented two methods ..._GET_ENTITYSET & _GET_ENTITY.
In _GET_ENTITYSET method : your code is retrieving the whole set of data from database and there is no condition applied on the query.
I did same way so I am getting all the data which is there in the table. So fine till here.
In _GET_ENTITY method : You have written a query based on a condition. I have implemented same way. When
I use URL : http://domain:port/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/UserInfoSampleSet('123098') in Netweaver Gateway client it gives me one record in XML format.
It is all fine until here. But my actual requirement : To implement code in SAPUI5 program where I can pass a parameter to Gateway server and depending upon the parameter the record is retrieved.
Say, I want to a record to be retrieved depending upon the UserID. In my SAPUI5 program I will be sending userId value to gateway server and depending upon the UserId value that particular record should be given back to my SAPUI5 program. So this is what I am struggling to achieve.
Now to achieve this, will I have to write code in _GET_ENTITYSET method or _GET_ENTITY method?
Please advise.
If UserID is your key property in entity User (entity collection may be UserCollection) then you need to implement to get_entity to get that particular record. Check the code in Read operation of the blog.
*Get the key property values
READ TABLE it_key_tab WITH KEY name = 'UserID' INTO ls_key_tab.
lv_userid = ls_key_tab-value.
it_key_tab is your importing parameter of the method.
in your UI5 application, you will be able to read the record as below for e.g.,
oModel.read('/Products(1)', null, null, true, function(oData, oResponse){
alert("Read successful: " + JSON.stringify(oData));
},function(){
alert("Read failed");});
Check OData Write Support - SAPUI5 Developer Guide - SAP Library
Regards,
Chandra
Hi Chandra,
Thanks for helping me with the oModel.read() method.
So now when I used the oModel.read() method code posted by you, I am getting an alert with OData content which has only 1 item which is what is expected....but my table shows all three items. So I see some problem with the binding here. Below is my SAPUI5 code ... please advice where changes are required.
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZUI5_SAMPLEUSERINFO_SRV/");
oModel.read("/UserInfoSampleSet('123098')", null, null, true, function(oData, oResponse){
alert("Read successful: " + JSON.stringify(oData));
},function(){
alert("Read failed");});
<created table and created columns here>
oTable.setModel(oModel);
oTable.bindRows({path : "/UserInfoSampleSet"});
Though I am reading only one line item in oModel.read() method, I some how not able to know how to bind only that single line item retrieved
by oModel.read() to oTable.
I think my last line of code is binding my oTable to all rows. : oTable.bindRows({path : "/UserInfoSampleSet"});
If I cannot bind oTable to a single entry then please let me know which control I need to use to show this one line item in the browser.
Hi,
here you are binding aggregation to table. it means bindRows expect entity collection which is /UserInfoSampleSet. hence the call will go to get_entityset method of DPC_EXT class.
you can put the filter logic in get_entityset method and then get the value of UserID and accordingly get the filtered data into collection
| OData Query | Method Parameter | Alternative way to get the value | Coding required to implement Query Operation |
|---|---|---|---|
| UserCollection?$filter=UserID eq '123' and LastName eq 'Mahajan' | IT_FILTER_SELECT_OPTIONS and IV_FILTER_STRING | DATA: my_filter_options TYPE/iwbep/t_mgw_select_option, my_filter_string TYPE string. my_filter_options =io_tech_request_context->get_filter( )->get_filter_select_options( ). my_filter_string = io_tech_request_context->get_filter( )->get_filter_string( ). | Yes |
As mentioned in the table, you will get the value in method importing parameter or by using code provided in alternative way. Check the code in
put external breakpoint in method get_entityset and accordingly put the logic. once you will get the UserID say in variable lv_userid, pass it to select query as below
METHOD usercollection_get_entityset.
DATA: lt_userinfo TYPE TABLE OF zuserinfo,
ls_userinfo LIKE LINE OF lt_userinfo,
ls_entity LIKE LINE OF et_entityset.
*Get data from ZUSERINFO table
SELECT * FROM zuserinfo INTO TABLE lt_userinfo where userid = lv_userid.
*Fill ET_ENTITYSET
LOOP AT lt_userinfo INTO ls_userinfo .
ls_entity-userid = ls_userinfo-userid.
ls_entity-firstname = ls_userinfo-firstname.
ls_entity-lastname = ls_userinfo-lastname.
ls_entity-email = ls_userinfo-email.
ls_entity-phone = ls_userinfo-phone.
ls_entity-country = ls_userinfo-country.
APPEND ls_entity TO et_entityset.
ENDLOOP.
ENDMETHOD.
On UI5 side, you can put the code as mentioned here JS Bin - Collaborative JavaScript Debugging
Regards,
Chandra
I think I am just a step away in achieving it.
As you said, below is the what I implemented in get_entitySet() method.
---------------------------------
DATA: lt_filters TYPE /iwbep/t_mgw_select_option,
ls_filter TYPE /iwbep/s_mgw_select_option,
ls_so TYPE /iwbep/s_cod_select_option,
my_filter_string TYPE string,
lt_userinfo TYPE table of zuser_info,
ls_userinfo like line of lt_userinfo,
ls_entity LIKE LINE OF et_entityset,
str TYPE string.
lt_filters = io_tech_request_context->get_filter( )->get_filter_select_options( ).
my_filter_string = io_tech_request_context->get_filter( )->get_filter_string( ).
str = my_filter_string+9(12).
REPLACE ALL OCCURRENCES OF '=' IN str WITH ''.
SELECT single * FROM zuser_info INTO ls_userinfo WHERE Zuserid = str.
if sy-subrc = 0.
ls_entity-zuserid = ls_userinfo-Zuserid.
ls_entity-Zaddr = ls_userinfo-Zaddr.
ls_entity-Zcountry = ls_userinfo-Zcountry.
APPEND ls_entity TO et_entityset.
else.
SELECT * FROM zuser_info INTO table et_entityset.
endif.
------------
However I am not getting expected result. sy-subrc value is not 0 meaning the query is not retrieving any rows so it is going to else part. What I found in debugging is
'my_filter_string' value is coming as : ( ZUSERID = '123098' ).
I did not know how to get the value from this string...so I substring so that I can get only the digit part. Below is the code.
str = my_filter_string+9(12).
REPLACE ALL OCCURRENCES OF '=' IN str WITH ''.
Now if I see in the debug the value of str is : '123098'.
But the query "SELECT single * FROM zuser_info INTO ls_userinfo WHERE Zuserid = str." is not retrieving any rows.
Whereas, if I hard code the condition in the query as below then it works..
SELECT single * FROM zuser_info INTO ls_userinfo WHERE Zuserid = '123098'.
May be I am doing a very silly mistake but since I am from java/portal developer so finding it tough with ABAP programming. Thanks in advance.
Hi ,
For general purpose filtering of odata you can use ?$filter = property eq 'value'
I your case you can use abc.xsodata/TDataSet?$filter = Scid eq 'value'
This should filter your odata values as Scid = value
You can refer :Home | OData - The Protocol for REST APIs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks all for the help.
Today I learned few things though was not able to fix my filter issue.
But after going through few other posts and specially which Jason mentioned, I feel I have not properly set-up my Odata service which I would be working upon now.
Thanks again.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you want to filter an OData model, the filter logic is on the server. Or, as the SAPUI5 docs mention it:
The OData model is a server-side model: the dataset is only available on the server and the client only knows the currently visible rows and fields. Sorting and filtering is done on the server. The client has to send a request to the server to accomplish these tasks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the response Robin. I have this problem going on for many days now and it is 10th day today.
I got your point that we have to do filtering at server side and not at client side. But can you tell how we can do it. I tried multiple ways in my SAP UI5 program but failed in every way. Please see where I need to correct.
Entity Set : TDataSet
Property with which I want to filter : Scid
I am sending request to client in below ways...
1) This gives me all the data as before which makes me believe that filter is not working.
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/",["$filter=val eq '1000940272' and key eq 'Scid'"]);
oTable.setModel(oModel);
oTable.bindRows({path: "/TDataSet"});
2) This also gives me all data as before which makes me think that filter is not working with this approach as well.
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/");
oTable.setModel(oModel);
oTable.bindRows({path: "/TDataSet?$filter=Scid eq '1000940272'"});
With the definition which you pasted in your reply, I guess the second way of filtering is wrong as I am here trying to filter at client and not at server. Having said that, someone on the blog said that the second way of filtering worked for him.
Hi Sun,
I believe the 2nd option should be correct, although I;m not sure if you can directly specify a filter in pthe path when doing bindRows().
Alternatively, you could try the following:
var filter = new sap.ui.model.Filter("Scid", sap.ui.model.FilterOperator.EQ, : "12345");
table.bindRows("/TDataset",null,null,[filter]);
NB: Although you specify the filter in the client, the actual filtering takes place on the server, and it will only return the filtered data
Tried Robin...but still getting all rows
----------------
var filter = new sap.ui.model.Filter("Scid", sap.ui.model.FilterOperator.EQ, "1000940272");
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/");
oModel.read("/TDataSet", null, filter);
oTable.setModel(oModel);
oTable.bindRows({path: "/TDataSet"});
return oTable;
-----------------
Do I need to implement getEntity(Read) method in gateway server ?
If you look in the developer tools, on the network tab, do you see the filter parameters as part of the HTTP request?
Also, have you checked that your oData service supports filtering? http://scn.sap.com/docs/DOC-43000
Regards,
Jason
Hi Jason,
I have attached the screenshot which has the trace. From the trace I can see the filter appended to the URL but not doing the job. I am still getting all the items which means filter is not working. Below is the code I have used.
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/");
oTable.setModel(oModel);
oTable.bindRows({path: "/TDataSet?$filter=Scid eq '1000940272'"});
Thanks in advance.
Now if I change the filtering slightly like below then it still load me all the data without filtering. However, in the developer tools I see a message which says that 'I have not implemented 'TDATASET_GET_ENTITY' METHOD. Below is the code which I used and the error message.
var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/");
oModel.read("/TDataSet('1000940272')/Scid",[ "$filter=val eq '1000940272' and key eq 'Scid'"]);
--------------------------------------
2015-01-12 18:28:06 The following problem occurred: HTTP request failed500,Internal Server Error,<?xml version="1.0" encoding="utf-8"?><error xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata"><code>SY/530</code><message xml:lang="en">Method 'TDATASET_GET_ENTITY' not implemented in data provider class</message><innererror><transactionid>54A97706DD470A12E10000000A298945</transactionid><timestamp>20150112125759.8021610</timestamp><Error_Resolution><SAP_Transaction>Run transaction /IWFND/ERROR_LOG on SAP NW Gateway hub system and search for entries with the timestamp above for more details</SAP_Transaction><SAP_Note>See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)</SAP_Note></Error_Resolution><errordetails><errordetail><code>/IWBEP/CX_MGW_NOT_IMPL_EXC</code><message>Method 'TDATASET_GET_ENTITY' not implemented in data provider class</message><propertyref/><severity>error</severity></errordetail></errordetails></innererror></error> -
------------------------------------------
Jason,
to your second question whether OData service supports filtering...
I have checked in the properties in the gateway project and it has the filter option ticked. When I checked the metadata I do not see the filterable attribute....please check below..the filterable attribute for some other properties is 'false' but for Scid it is not showing up. But when I chekedin the Gateway project the property has the filterable check-box checked.
---------------
<Property Name="Amnt" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Char20" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
<Property Name="Scid" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Character Field Length = 10" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
<Property Name="Zdesc" Type="Edm.String" Nullable="false" MaxLength="40" sap:label="Char" sap:creatable="false" sap:updatable="false" sap:sortable="false" sap:filterable="false"/>
<Property Name="Curr" Type="Edm.String" Nullable="false" MaxLength="3" sap:label="3-Byte field" sap:creatable="false" sap:updatable="false" sap:sortable="false"sap:filterable="false"/>
<Property Name="Sctyp" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Character Field Length = 10" sap:creatable="false" sap:updatable="false" sap:sortable="false"sap:filterable="false"/>
<Property Name="Createdby" Type="Edm.String" Nullable="false" MaxLength="20" sap:label="Char20" sap:creatable="false" sap:updatable="false" sap:sortable="false"/>
<Property Name="Pdate" Type="Edm.String" Nullable="false" MaxLength="10" sap:label="Character Field Length = 10" sap:creatable="false" sap:updatable="false" sap:sortable="false"sap:filterable="false"/>
-------------
I am basically a Java portal developer so definitely I think I did not do proper set-up at gateway server and that could be leading to these issues.
Coming to your question of implementing TDATASET_GET_ENTITY method....what I did is..
right click on GET_ENTITY(query) and then did the mapping using RFC. And then generated artifacts.
Attached screenshot
Message was edited by: Sun 197895
https://cdchsb401.tyson.com/sap/ui5/1/sdk/#docs/api/symbols/sap.ui.model.odata.ODataModel.html
you may use the OData query syntax:
http://www.odata.org/documentation/odata-version-2-0/uri-conventions/
or you could also use the
oData.read function and passing filters.. look into the sdk and look for the filter object
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sergio,
For some reason filter is not working even though the syntax seems to be correct. Do we have to do any configuration at the Gateway server to make the filter work? Please advice. Below is the code which I using to filter.
-----------------
| var oModel = new sap.ui.model.odata.ODataModel("/sap/opu/odata/sap/ZSCAPP_SRV/"); | ||||||
| new sap.ui.getCore().setModel(oModel); | ||||||
var oTable = new sap.ui.table.Table({width : "100%", visibleRowcount : 5});
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Scid"}), template : new sap.ui.commons.TextView({text : "{Scid}"}), visible : true})); |
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Amnt"}), template : new sap.ui.commons.TextView({text : "{Amnt}"}), visible : true}));
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Zdesc"}), template : new sap.ui.commons.TextView({text : "{Zdesc}"}), visible : true}));
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Sctyp"}), template : new sap.ui.commons.TextView({text : "{Sctyp}"}), visible : true}));
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Createdby"}), template : new sap.ui.commons.TextView({text : "{Createdby}"}), visible : true}));
oTable.addColumn(new sap.ui.table.Column({label : new sap.ui.commons.Label({text : "Pdate"}), template : new sap.ui.commons.TextView({text : "{Pdate}"}), visible : true}));
oTable.setModel(oModel);
//oTable.bindRows({path: "/TDataSet"});
| oTable.bindRows({path: "/TDataSet?$filter=Scid eq '1000940272'"}); | ||||||||||||
return oTable;
----------------
.
Thanks for your reply Dennis ..
oModel.read("/EntitySet('15')/Items", null,[ "$filter=val eq 'full' and key eq 'one'"]);
Can you please guide me what I should substitute for my scenario...like
In my case :
Entity Set : TDataSet
Property which I want to filter is : Scid
Vaue of the Scid I am looking for is : Scid = '12345'
So now, please tell me how my statement should look like .... should it look like below ?
oModel.read("/TDataSet('12345')/Scid", null,[ "$filter=val eq '12345' and key eq 'Scid'"]);
Hi Dennis,
No luck....I am still getting all data . Used below code.
var oModel = new sap.ui.model.odata.ODataModel();
oModel.read("/sap/opu/odata/sap/ZSCAPP_SRV/", null,[ "$filter=val eq '1000940272' and key eq 'Scid'"]);
in the above line when I use 'null' as one of the parameter it throws ''null pointer error". But when I remove the 'null' value then it works but then it gives me whole data which means it is not filtering.
| User | Count |
|---|---|
| 15 | |
| 9 | |
| 6 | |
| 4 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.