Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to use IT_FILTER_SELECT_OPTIONS to get input for SAP OData service?

vg24
Explorer
8,898

I am new to SAP OData services and am trying to use GET_ENTITYSET for taking input from user using IT_FILTER_SELECT_OPTIONS. Can anyone show me a simple example for the same?

For example, how to use IT_FILTER_SELECT_OPTIONS to take two inputs.

  • SAP Managed Tags:
7 REPLIES 7

subhajit
Active Participant
2,850

it_filter_select_options has Property and a range table..

So ur need is to extract the range table againta the Property that you pass as $filter in URI and use it in ur select query

so if ur query is :

EntitySet?$filter= Name eq ‘XYZ’ and Address eq ‘ZYX‘

then the query should run as :

lt_range_name = it_filtet_select_options[ property = ‘Name’ ]-select_options

lt_range_address = it_filtet_select_options[ property = ‘Address’ ]-select_options

Now in select query you can use it as :

Select whatever from wherever into wheresoever where Name IN lt_range_name And Address IN lt_range_address

  • SAP Managed Tags:

2,850

Maybe its a silly question but what is the type of lt_range_name and lt_range_address because when I enter their type as /IWBEP/T_MGW_SELECT_OPTION or /iwbep/s_cod_select_option it is giving an error saying 'The type of 'SELECT_OPTIONS' cannot be converted to the type of lt_range_name'

  • SAP Managed Tags:

subhajit
Active Participant
0 Kudos
2,850

Apologize for the delay.

Its good to be silly while learning. Both should be of type /iwbep/t_cod_select_options as that's the table type for the nested select options table.

But I differ with Andre as my answer being the wrong answer as your question was related to it_filter_select_options.

So my answer was not wrong rather it is not recommended.

In this context, I would like to echo what Andre mentioned. You should use parameter IO_TECH_REQUEST_CONTEXT to retrieve filter parameters going forward.

All the best 🙂

  • SAP Managed Tags:

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
2,850

You should not use IT_FILTER_SELECT_OPTIONS since these parameters have been deprecated since a long time. They only still exist due to compatibility requirements of the method interface.

Instead you should use

io_tech_request_context->get_filter( )->get_filter_select_options( )

to get the filter parameters in the format of select options.

See also my following blog.

How to Develop Query Options for an OData Service Using Code-Based Implementation | SAP Blogs

Kind regards,

Andre

ceterum censeo RAP esse utendam
  • SAP Managed Tags:

0 Kudos
2,850

Thankyou for the help 🙂

  • SAP Managed Tags:

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos
2,850

Sorry but the answer you have marked as correct is not correct.

You shouldn't use it_select_options

ceterum censeo RAP esse utendam
  • SAP Managed Tags:

0 Kudos
2,850

Okay, but I am asked to make use of it_filter_select_options.

I am going through tour blog and I am absolutely loving it.

  • SAP Managed Tags: