cancel
Showing results for 
Search instead for 
Did you mean: 

Pass select option to CDS View only! No AMDP

0 Kudos
5,949

I know we can pass Select options from ABAP to CDS using table function and AMDP approach,

But as we know there are advantages of using core CDS and I was wondering that is there any approach where I can pass my select option to CDS view and consume it in CDS view only

Accepted Solutions (0)

Answers (3)

Answers (3)

MateuszAdamus
Active Contributor

Hello amit316chauhan

Condition generated from Select Options is passed to the DB server and handled on the DB side. Records are not filtered in the application server. Please read the SAP Help documentation when not sure.

I see no reason why the same thing shouldn't happen when querying data from a CDS view.

Kind regards,
Mateusz
0 Kudos

I Aggre that the condition passed is executed at DB layer

   SELECT *
       FROM z_cds_view
       INTO TABLE @DATA(lt_result)
       where field1 in s_field1. (Here Where Clause will be executed at DB level)

In Above code Complete z_cds_view will gets executed(lets say it retrieve 1Mil records) without filter first and then its result(1M records) will be filtered again (at DB level) by passing s_field1.

So the performance could have been improved if there would have been a way to pass select option directly at DB level, can you please comment on same?

Kind Regards

gasparerdelyi
Product and Topic Expert
Product and Topic Expert

The WHERE condition will be applied by DB the way the optimizer can deal with the situation.
It will not pass non-matching records to the application server.

If it will process many records or not depends on a number of factors:

  • If it is a calculated field
  • if the field is coming from a join or association then what are the ON conditions
just to name the trivial ones...
Why filter pushdown is not working is sometimes a not so easy question... but far more details are needed for analysis.
keremkoseoglu
Contributor

Here is an ugly but functional workaround. Assuming that you have a select option for BUKRS;

  • Generate a GUID
  • In your Z-program, SELECT bukrs FROM t001 WHERE bukrs IN s_bukrs INTO TABLE whatever
  • Insert those values in a temporary Z-table having two keys: GUID + BUKRS
  • Pass this GUID to your CDS View
  • In the CDS view, inner join your Z-table with GUID + BUKRS
0 Kudos

That is one hell of a walkaround 🙂

Have you seen this solution in a realtime application?

Also this solution will have its cons for performance :

1.Updating a table for guid

2. if table is Standard, then we have to add extra field

keremkoseoglu
Contributor

Not exactly that, but putting data into temporary tables and joining via GUID's is something doable. We did that occasionally (before the era of CDS Views) when we needed to use SELECT SUM and FOR ALL ENTRIES together.

1) You also need to cleanse the old entries from time to time.

2) The table would be a Z-table, not a standard table.

former_member1716
Active Contributor
0 Kudos

amit316chauhan,

If you are looking for an alternate approach for using select option inside CDS other than AMDP, well i don't think you have a better approach.

On the other hand when you query upon a CDS using select query you can very well use the Select options on them just like how you use up on a back end table.

Are you expecting something else other than this? if so please explain.

Regards!

0 Kudos
I understood the concept of applying select option in calling level at ABAP layer<br>
SELECT *
       FROM z_cds_view
       INTO TABLE @DATA(lt_result)
       where field1 in s_field1.

here complete z_cds_view will be executed without any where clause at DB level woudn't it affect the performance, rather than  paassing a filter directly to CDS?

former_member1716
Active Contributor

amit316chauhan,

In that case CDS with table functions is the only known method so far.

Regards!

0 Kudos

So basically AMDP is the only solution, so in the above-mentioned query, the complete table will be triggered right?

and that would be expensive on DB load? can you comment on performance perspective?

former_member1716
Active Contributor

amit316chauhan,

When you apply a select option in CDS you are only applying the filter on ABAP layer after projecting the data from database, similar to what we do with normal Database tables in ABAP.

But with CDS with table functions we are pushing down the filter to the DB Layer.

So Yes, CDS with table functions has better performance.

Regards!