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

ABAP CDS View with dynamic table specification

former_member314455
Participant
0 Likes
3,664

Hello,

Just wondering if dynamic table specification is possible with CDS view?

My requirement is to represent the below in a CDS view-

parameters: p_region type char5.

SELECT table_name

      FROM Ztable_names

      INTO @data(lv_table)

      WHERE region = @p_region.

SELECT col1,

              col2

    FROM (lv_table)

    INTO TABLE @DATA(lv_result).


Thanks,

Ajith

1 ACCEPTED SOLUTION
Read only

pfefferf
Active Contributor
0 Likes
1,791

Hello Ajith,

within a CDS view declaration the names must be specified. No dynamic placeholders can be used.

Regards,

Florian

Hello,

Just wondering if dynamic table specification is possible with CDS view?

My requirement is to represent the below in a CDS view-

parameters: p_region type char5.

SELECT table_name

      FROM Ztable_names

      INTO @data(lv_table)

      WHERE region = @p_region.

SELECT col1,

              col2

    FROM (lv_table)

    INTO TABLE @DATA(lv_result).


Thanks,

Ajith

4 REPLIES 4
Read only

pfefferf
Active Contributor
0 Likes
1,792

Hello Ajith,

within a CDS view declaration the names must be specified. No dynamic placeholders can be used.

Regards,

Florian

Read only

0 Likes
1,791

Hi Florian,

Thanks for the clarification.

Is there any other way to achieve this (AMDP etc) ?

Thanks,

Ajith

Read only

pfefferf
Active Contributor
0 Likes
1,791

Hello Ajith,

within SQLScript you can use dynamic sql (e.g. EXEC command). But you should avoid this because of different reasons, for instance SQL injection vulnerability, decreased performance ...

Best Regards,

Florian

Read only

0 Likes
1,791

Thanks ! I think I'll create a RFC function module so that it can be called from external system.