Application Development and Automation 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: 
Read only

CDS pass range parameters

JamesG
Participant
0 Likes
6,820

hi experts,

how to use CDS view pass range parameters,and let it was not obligatory input?

somebody can help me ?

Thanks

1 ACCEPTED SOLUTION
Read only

MateuszAdamus
Active Contributor
5,931

Hello qw1391202028

First thing that comes to my mind is a question - why would you want to do it?

You can use your range parameters simply in an Open SQL query selecting records from the CDS and it will have the same effect. So why complicate the CDS and put the parameters there?

SELECT some_field
  FROM my_cds
  WHERE some_other_field IN @my_range_parameter
  INTO TABLE @DATA(lt_results).

However, if you really want to do it, here is a blog on how it can be achieved with a table function: https://blogs.sap.com/2018/03/21/select-options-in-cds-using-table-function/

Kind regards,
Mateusz
2 REPLIES 2
Read only

MateuszAdamus
Active Contributor
5,932

Hello qw1391202028

First thing that comes to my mind is a question - why would you want to do it?

You can use your range parameters simply in an Open SQL query selecting records from the CDS and it will have the same effect. So why complicate the CDS and put the parameters there?

SELECT some_field
  FROM my_cds
  WHERE some_other_field IN @my_range_parameter
  INTO TABLE @DATA(lt_results).

However, if you really want to do it, here is a blog on how it can be achieved with a table function: https://blogs.sap.com/2018/03/21/select-options-in-cds-using-table-function/

Kind regards,
Mateusz
Read only

0 Likes
5,932

hi Mateusz,

Thanks for your replay.

i just think about it.haha

Kind regards.

wei.guo