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 column name

Former Member
0 Likes
528

hi experts,

DATA: temp(20) VALUE 'DATA',

i TYPE I VALUE 1,

J(2) type c.

LOOP AT l_t_tsi.

J = I.

CONCATENATE TEMP J INTO COLNAME.

itab-(COLNAME) = l_t_tsi-time_series_value.

i = i + 1.

ENDLOOP.

My internal table (itab) has fields data1(20), data2(20), data3(20)...

I want to generate the column names dynamically only.

The above code gives an error at this line -

itab-(COLNAME) = l_t_tsi-time_series_value.

Thanks in advance,

Bijal

4 REPLIES 4
Read only

Former Member
0 Likes
503

itab-(COLNAME) u cant use like this.

<b>itab-COLNAME</b>

Read only

athavanraja
Active Contributor
0 Likes
503

its not possible in this fashion. but if you tell us what you want do by doing this, may be we could come up with better option

Read only

Former Member
0 Likes
503

hi,

mentioning colname gives itab does not contain colname field.

thanks

Read only

Former Member
0 Likes
503

Hi,

If your aim is to refer to a internal table field dynamically you can do it.

Look at the code segment below -

DATA: temp(20) VALUE 'DATA',

i TYPE I VALUE 1,

J(2) type c.

FIELD-SYMBOLS: <ls_data>.

LOOP AT l_t_tsi.

J = I.

CONCATENATE TEMP J INTO COLNAME.

<b>ASSIGN COMPONENT colname OF itab TO <ls_data>.

<ls_data> = l_t_tsi-time_series_value.</b>

*itab-(COLNAME) = l_t_tsi-time_series_value.

i = i + 1.

ENDLOOP.

Regards,

Manish Joshi

    • If it solves your problem, close the thread.

    • Don't clutter-up forum by leaving open threads.