‎2007 Nov 26 6:40 AM
hi experts..
is it possible to declare a Internal table/variable with dynamic name?
do 10 times.
concatenate 'table' sy-tabix into lv_name.
data (lv_name) type i.
enddo.
thanks,
‎2007 Nov 26 6:47 AM
‎2007 Nov 26 6:50 AM
Hi,
yes you can but dont use bracket
do 10 times.
data lv_name type i.
concatenate 'table' sy-tabix into lv_name.
enddo.
Regards,
PRashant
‎2007 Nov 26 9:21 AM
‎2007 Nov 27 5:32 AM
try this.
do 10 times.
data lv_name(8) type c.
concatenate 'table' sy-tabix into lv_name.
enddo.
‎2007 Nov 27 7:43 AM
You can obviously do it through dynamic program generation. And depending on your version, you might have to. You can't however, do it directly.
This sample program, which works in 700 (and make work in earlier versions), creates a ten-times table.
TYPES: my_table_type TYPE STANDARD TABLE OF i WITH NON-UNIQUE KEY table_line.
DATA: t_ref TYPE STANDARD TABLE OF REF TO data WITH NON-UNIQUE KEY table_line,
p_data TYPE REF TO data,
v_count TYPE i,
v_mult TYPE i,
v_product TYPE i.
FIELD-SYMBOLS: <mytab> TYPE my_table_type,
<ref> TYPE REF TO data,
<val> TYPE i.
DO 10 TIMES.
CREATE DATA p_data TYPE my_table_type.
INSERT p_data INTO TABLE t_ref.
ASSIGN p_data->* TO <mytab>.
ADD 1 TO v_count.
v_mult = 0.
DO 10 TIMES.
ADD 1 TO v_mult.
v_product = v_mult * v_count.
INSERT v_product INTO TABLE <mytab>.
ENDDO.
ENDDO.
v_count = 0.
LOOP AT t_ref ASSIGNING <ref>.
ADD 1 TO v_count.
WRITE: / 'Table', v_count.
ULINE.
ASSIGN <ref>->* TO <mytab>.
LOOP AT <mytab> ASSIGNING <val>.
WRITE <val>.
ENDLOOP.
ULINE.
ENDLOOP.What you are doing is creating references to tables, and storing those in an internal table. When you need to handle the tables, you then dereference them into a field symbol, and use them as normal.
If the type of the tables varies, you can use the same principle, but it is more complex, and requires RTTS.
matt
‎2007 Nov 28 2:07 AM
hi...
thank u for ur reply..
my requirement is to save the data in dynamic variale/table...
i already generated the table structure and assign the data to temp structure..
i want to create a variable with dynamic name and assign the data to the dynamic variable created inside the loop statement...
loop at gt_pricing.
concatenate 'A' 906' into lv_tablename.
data lv_tablename(8) type c.
*---my requirement is to assign the data from temp structure to lv_tablename(A906)
endloop.