Skip to Content
Author's profile photo Munagala Uday

Search String using Get_Entityset and Adding additional Fields at Gateway Level…

This Document is to understand the Search String Concept in Get_Entityset. This doc will be helpful for those who are new to Odata gateway..

Task#1: Fetching Data based on Search String:

get_search_String( ) is a standard method to capture the Search string Value


IO_TECH_REQUEST_CONTEXT is one of the standard parameter of Get_Entityset method. By using that parameter we can capture the search string with get_search_string() method.

Create a Project:

Create an EntityType using an Abap DDIC Structure.

Choose the Required fields from the structure to create Entity type.

Choose Userid as key field.

Save the project and click on “Generate Runtime Objects”.

Now Go to Data Provider Extension class and choose change and Select Get_Entityset method, then Redefine.

Here we have 2 standard parameters in Get_Entityset for capturing the search string Input i.e IV_SEARCH_STRING and IO_TECH_REQUEST_CONTEXT and ET_ENTITYSET for displaying the output.

Implement the below code:


data  searchstring TYPE  STRING.


  select * from zuserinfo 

            into  corresponding fields of  table lt_user

            where FIRSTNAME  =  searchstring.


      ET_ENTITYSET  = lt_user.

Activate the class, Register the service and Maintain the Service.

Now we will test the Search string using the Gateway Client.



and Execute.



                                                                    entityset  Keyword value


You’ll get the Records based on Search String Value from DDIC Table we used.

Note: In this Scenario, Get_Entityset method is executed, but not Get_Entity method.

Task#2: Fetching the data based on Conditions by generating NEW COLUMNS at Gateway service level:

I want to generate some new Columns when my Gateway service is Executed  and when frontend users are accessing the service from UI5 applications.

Apart from the existing 8 columns in the table, I want to generate 2more columns like Status and Currency along with execution of Service based on conditions.

Even we can do the same at Front-end level, but let’s do this at service level.

Create New Project.

Create Data Model with Reference to DDIC Structure.

Apart from the above fields, I want to add 2more fields in Entity set Properties as Status and Currency.

Click Append Row and add 2 more fields.

Now, If you check the syntax it will throw the below error.

To Avoid this Error, go to Entity and Remove the Abap Structure.

As we added new fields in Service level which are not exiting in DDIC table, we need to remove the mapping and check.

Note : STATUS ,  CURRENCY  is not physically available in the data base

          so, STATUS , CURRENCY can be generated virtually at SERVICE LEVEL

NOTE : Inside ENTITY TYPE,  based on requirement, we can add new fields/properties

but we need to “remove the ABAP DDIC STRUCTURE

Save the Project.


open DATA PRovider EXTENSION CLASS, choose change,

select  GET_ENTITYSET method and click on “REDEFINE”.

Implement the below code.

  data  lt_itab  TYPE  ZCL_ZPROJECT2_MPC=>TT_USER.
data  lt_itab2  TYPE  ZCL_ZPROJECT2_MPC=>TT_USER.

data  ls_itab  TYPE  ZCL_ZPROJECT2_MPC=>TS_USER.

select  * from ZUSERINFO  into
corresponding fields of  table  lt_itab.

Loop  at lt_itab  into ls_itab.

if ls_itabSALARY  < 12000.

ls_itabSTATUS  = ‘Basic’.

elseif  ls_itabSALARY  >=  12000 and ls_itabSALARY  <= 30000.


elseif  ls_itabSALARY > 30000.

ls_itabSTATUS  = ‘GOOD’.


if ls_itabCOUNTRY  = ‘INDIA’.


elseif  ls_itabCOUNTRY  = ‘US’.



append ls_itab  to lt_itab2.


ET_ENTITYSET  lt_itab2.

Activate the class.

Register the service and Maintain the service.

Click on Go to Gateway Client and provide


and execute.

              HTTP Response:

In the above HTTP Response, Status and Currency field values got executed from the Code and based on conditions we implemented.

This is a simple and small approach of Generating new columns which might be helpful for you in multiple scenarios.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.