You are on page 1of 2

5/16/12

laboni.bhowmik: Filtration of data on SAP MII i... | SCN


Getting Started New sletters Store

Welcome, Guest

Login

Register

Search the Community

Solutions Industries Lines of Business

SAP Services & Support Training & Education University Alliances

About SCN Partnership Events & Webinars

Downloads Developer Center Idea Place


Activity Brow se Communications Actions

laboni.bhowmik

Filtration of data on SAP MII iGrid


Posted by Laboni Bhowmik in laboni.bhowmik on Oct 19, 2011 11:42:50 AM Previous Next

Just about a month ago I came to know about a requirement of developing a data filter functionality for SAP MII iGrid, quite similar to SAP Webdynpro or SAP MII admin pages table filter. User will enter a keyword as an input and iGrid data should be filtered based on that input. The first thing that came into my mind is to explore all iGrid API methods/functions but unfortunately didnt find any standard way to support this feature. As we all know that MII iGrid is not editable which causes the first barrier to support the iGrid data filter feature. Replacing the iGrid with Dojo or Ajax grid can make our work much easier in some cases. But in my case I had to support this feature on existing SAP MII iGrid itself so I decided to build something very simple and easy to implement. The first thing that we need to do here is to add a blank row as a first row in the iGrid as shown in Fig: 1. So used the postpost below code snippet to add a top row containing HTML input box for each individual column of the iGrid to take the input for data filtration: document.iGridName.getGridOb ject().setCellValue(rowNumb er, columnNumb er ," "); The above code snippet will change the grid as shown below and it will offer the filtering possibility through the filtering row.

Fig: 1 Next there should be a provision to enter filter input; this can be supported in several ways like developing a custom html/css based popup window etc. But I used standard JavaScript prompt() function to support the same.

Fig: 2 After clicking OK it filters the data based on the column of the grid according the filter value located at the top of a column and user can see the filtered data on the grid and the filter input value 14M on the top row.

Fig: 3 To display the filter criteria on the selected column I have used the following code snippet: customText = " "; document. iGridName.getGridOb ject().setCellValue(1, selectedColumnNumb er ,customText); Filtering capabilities: The iGrid data filter has the following capabilities: Strings: if user enter filter input value a it returns any fields that has a in it irrespective of the position of a in the string. Numeric values, dates timestamp: It filters for the exact numeric value, date and timestamp.

scn.sap.com/people/laboni.bhowmik/blog/2011/10/19/filtration-of-data-on-sap-mii-igrid

1/2

5/16/12

laboni.bhowmik: Filtration of data on SAP MII i... | SCN

Filter implementation: When user clicks the OK button then the filter () gets triggered and it takes two parameters: one is selected column name by document.iGridName.getGridOb ject().getColumnName(int) method and another is the column value which is entered by the user . Following is the code to take those two user inputs: filterCriteria=prompt("Please enter filter criteria here"); if(filterCriteria!=null && filterCriteria!="") { document.DisplayBufferMessage.getGridOb ject().setCellValue(1, selectedColumnNumb er ,filterCriteria); filterExprsn = selectedColumnName+" "+"LIKE"+" "+"'%"+filterCriteria+"%'"+" "; if(selectedColumnNumb er == 5 || selectedColumnNumb er ==6){ filterCriteria = filterCriteria.replace("T", " "); filterExprsn = selectedColumnName+" "+"=TO_TIMESTAMP('"+filterCriteria+"','YYYY-MM-DD HH24:MI:SS' )"; } fetchQueryResult(); } Inside fetchQueryResult() method the created filter expression is passed to the Xacute query of the transaction to query the set of data from the database based on this filter expression. document.DisplayBufferMessage.getQueryOb ject().setParam(1,filterExprsn); document.DisplayBufferMessage.updateGrid(true); This filter transaction needs two parameters to do this data filtration. One is query path and another is the filter expression. This query path has been used to fetch all the unfiltered data in the grid and the incoming parameter, Columns, of the SQL query has been used to get the list of Column names of the database table. I have used those exact column names to generate the output XML document for the grid to display the data and while filtering the data I have used only that exact column name as the selected column for the filter expression. So that this iGrid data filter can work as a generic iGrid filter and it can be reused.

6 View s

Average User Rating (0 ratings)

My Rating:

0 Comments
There are no comments on this post

Contact Us Privacy

SAP Help Portal Terms of Use

Legal Disclosure

Copyright

Follow SCN

scn.sap.com/people/laboni.bhowmik/blog/2011/10/19/filtration-of-data-on-sap-mii-igrid

2/2

You might also like