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

comparing fields in dynamic way inside CDS views

ashish_bansal
Product and Topic Expert
Product and Topic Expert
0 Likes
2,213

Hi,

I am working on a prototype where i have to compare few fields of a DB table to see if there is any different value in any one of them. The fields to be compared comes from another table and could differ at times. How do i achieve this in CDS views ?

For e.g.

I get 2 fields named dispo and dispr from t130f DB table. After this i have to make a select on marc by comparing these 2 fields to see if the value differs. Something like this:

    SELECT A~*

     from MARC as A

     INNER JOIN MARC as B

         on A~matnr = B~matnr

     WHERE A~matnr = 'W10_000_0000000057'

       and ( A~dispo <> B~dispo

       OR  A~dispr <> B~dispr ).


The condition in brackets would be kind of dynamic. Thanks a lot in advance.


Regards,

Ashish

1 ACCEPTED SOLUTION
Read only

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
0 Likes
1,299

Hi Ashish,
ABAP CDS does not support dynamic SQL. You'd rather want to use dynamic Open SQL.

Another alternative are the programatical creation of CDS views or AMDPs - I mention it but I don't recommend it :-).


Cheers,
   Jasmin

Hi,

I am working on a prototype where i have to compare few fields of a DB table to see if there is any different value in any one of them. The fields to be compared comes from another table and could differ at times. How do i achieve this in CDS views ?

For e.g.

I get 2 fields named dispo and dispr from t130f DB table. After this i have to make a select on marc by comparing these 2 fields to see if the value differs. Something like this:

    SELECT A~*

     from MARC as A

     INNER JOIN MARC as B

         on A~matnr = B~matnr

     WHERE A~matnr = 'W10_000_0000000057'

       and ( A~dispo <> B~dispo

       OR  A~dispr <> B~dispr ).


The condition in brackets would be kind of dynamic. Thanks a lot in advance.


Regards,

Ashish

2 REPLIES 2
Read only

jasmin_gruschke
Product and Topic Expert
Product and Topic Expert
0 Likes
1,300

Hi Ashish,
ABAP CDS does not support dynamic SQL. You'd rather want to use dynamic Open SQL.

Another alternative are the programatical creation of CDS views or AMDPs - I mention it but I don't recommend it :-).


Cheers,
   Jasmin

Read only

0 Likes
1,299

Hi Jasmin,

Thats already very helpul. As i mentioned i am doing the prototyping and now when i know atleast this is not possible, it clarifies lot of things . Now i do not spent unnecessary time on this. Thanks again.

Regards,

Ashish