‎2006 Jun 27 12:46 PM
Hi Friends,
I have 10 fields in internal table , like
it_final-tsl01 , it_final-tsl02 ........ it_final-tsl10.
when i give 6 as input , it should add first 6 fields and store in a variable
‎2006 Jun 27 12:53 PM
Hi chandrasekhar,
1. just copy paste , and it will work as u require
2. we have to use field-symbols.
3.
report abc.
*----
data : begin of it_final occurs 0,
tls01 type i,
tls02 type i,
tls03 type i,
tls04 type i,
tls05 type i,
tls06 type i,
tls07 type i,
tls08 type i,
tls09 type i,
tls10 type i,
end of it_final.
*----
field-symbols : <FS>.
data : varname(15) type c.
data : num(2) type n.
data : tot type i.
*----
parameters : howmany type i default 6.
*----
start-of-selection.
*----
it_final-tls01 = 1.
it_final-tls02 = 2.
it_final-tls02 = 3.
append it_final.
loop at it_final.
do howmany times.
num = sy-index.
concatenate 'IT_FINAL-TLS' NUM INTO VARNAME.
assign (varname) to <FS>.
tot = tot + <FS>.
enddo.
write 😕 'Total : ' , tot.
endloop.
*----
regards,
amit m.
‎2006 Jun 27 12:49 PM
You can try doing this.
data : counter(2) type n.
data : varname (15) type c.
counter = '01'
do n times.
counter = counter + 1.
concatenate 'IT_FINAL-TSL' counter into varname.
total = total + (varname)
enddo.
regards,
Ravi
‎2006 Jun 27 12:54 PM
Hi Ravi,
thx for the reply ,i had tried the samething but its short dump at line total = total + (varname), dump says
unable to interrupt IT_FINAL-TSL01 as a number.
‎2006 Jun 27 12:59 PM
If that is giving a short dump,
assign (varname) to <fs_any>
total = total + <fs_any>
Regards,
Ravi
‎2006 Jun 27 12:53 PM
Hi chandrasekhar,
1. just copy paste , and it will work as u require
2. we have to use field-symbols.
3.
report abc.
*----
data : begin of it_final occurs 0,
tls01 type i,
tls02 type i,
tls03 type i,
tls04 type i,
tls05 type i,
tls06 type i,
tls07 type i,
tls08 type i,
tls09 type i,
tls10 type i,
end of it_final.
*----
field-symbols : <FS>.
data : varname(15) type c.
data : num(2) type n.
data : tot type i.
*----
parameters : howmany type i default 6.
*----
start-of-selection.
*----
it_final-tls01 = 1.
it_final-tls02 = 2.
it_final-tls02 = 3.
append it_final.
loop at it_final.
do howmany times.
num = sy-index.
concatenate 'IT_FINAL-TLS' NUM INTO VARNAME.
assign (varname) to <FS>.
tot = tot + <FS>.
enddo.
write 😕 'Total : ' , tot.
endloop.
*----
regards,
amit m.
‎2006 Jun 27 12:54 PM
Hi Chandrasekhar,
u can do it field symbols.ucan go thru example below..
For Dynamic population of fields
loop at tb_final.
clear l_ctr.
loop at tb_fieldcat into x_fieldcat .
l_ctr = l_ctr + 1.
perform pass_dynamic using x_fieldcat- fieldname l_ctr.
endif.
endloop.
append tb_final1.
endloop.
form pass_dynamic using p_field p_ctr.
field-symbols : <f1> type any,
<f2> type any.
data : l_text(100).
clear: l_text.
concatenate 'TB_FINAL1-tsl' p_ctr into l_text.
assign (l_text) to <f1>.
clear l_text.
To pass Data of tb_final to tb_final1.
if g_heading <> gc_x.
concatenate 'TB_FINAL-' p_field into l_text.
assign (l_text) to <f2>.
<f1> = <f2>.
endif.
endform.
Regards,
Kiran b
‎2006 Jun 27 12:56 PM
Hi,
check the code.
parameter : p_n(2) type i.
data : count(2) type i.
data : varname (15) type c.
do p_n times.
count = count + 1.
concatenate 'IT_FINAL-TSL' count into var.
sum = sum + var
enddo.