cancel
Showing results for 
Search instead for 
Did you mean: 

Using search for oData services generated using CDS views

11-21-2019 4:58 PM
3685 views 5 comments
0 Likes
SAP Managed Tags
Subscribe

Hi,

Trying to run a search on the odata service generated out of CDS view. But getting an error which says "Search not possible because the search scope is empty".

Attached screenshot of the same. Did not find any results on the internet for this error.

Could anyone point out how this is to be implmented?

Regards

Vaibhav Surana

0 Likes

Accepted Solutions (0)

Answers (4)

Answers (4)

rahullohia
Product and Topic Expert
Product and Topic Expert

Hi,

I faced the same issue recently and the way to solve is to redefine the method

IF_SADL_GW_QUERY_CONTROL~SET_QUERY_OPTIONS of your DPC_EXT class and then provide the scope parameters by specifying the 'Search' enabled fields from entity.

CASE iv_entity_set.

WHEN 'ApplicationSet'.
"Set basic search scope to include the following fields:
lt_search_scope = VALUE #( ( |{ 'DESCRIPTION' }| ) ( |{ 'APPLICATION' }| ) ).

io_query_options->set_text_search_scope( lt_search_scope ).

ENDCASE.

Thanks,

Rahul

Steve-Kangethe
Participant
0 Likes

In case someone is still struggling with this, you need to add the annotations that will allow some fields of the cds view to be searched as needed. For this error to go away, you need at least one field to be searchable.

Before the definition of the view, add this annotation:

@Search.searchable: true

Then before every field that you want to include within the scope of the search, add this annotation (example):

@Search.defaultSearchElement: true
--optional @Search.ranking: #HIGH 
FirstName,

Repeat for all fields as desired.

Hope this helps.

Former Member
0 Likes

Hi vaibhavsurana810,

Did you ever find a resolution for this? I'm having the same issue.

Isla

Former Member
0 Likes

Hi vaibhav,

Didn't find any attachment....

and with the entity set are you getting any data ? try to run with entity set if u get the data then there is a problem in the filters section otherwise there is a problem in generation of the service.
try registering again and see