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

dynamic select

Former Member
0 Likes
436

hi expert.

i have one big problem.

i want to get sum from table cosp by some strange statement.

when my perdio is 1 i want to get sum from wtg001

when period is 2 i want to get sum from wtg002

.....wtg012.

is it possible to have dynamic select  like this:

SELECT

SUM( distinct wtg0xy )   as ZWTG001_110010

cosp~kstar as kstar csku~ltext as ltext

INTO

   corresponding fields of tABLE IT_TMP?????

thanks for your advise

1 ACCEPTED SOLUTION
Read only

former_member188251
Active Participant
0 Likes
384

Hi Maryam,

Try like this:

concatenate 'wtg0' lv_period into lv_field.

select distinct  ( lv_field ) as ZWTG001_110010

cosp~kstar as kstar csku~ltext as ltext

INTO corresponding fields of itab.

Here, variable lv_period has the period '01' , '02' etc.

BR,

Shankar.

1 REPLY 1
Read only

former_member188251
Active Participant
0 Likes
385

Hi Maryam,

Try like this:

concatenate 'wtg0' lv_period into lv_field.

select distinct  ( lv_field ) as ZWTG001_110010

cosp~kstar as kstar csku~ltext as ltext

INTO corresponding fields of itab.

Here, variable lv_period has the period '01' , '02' etc.

BR,

Shankar.