01-07-2008 8:10 AM
Hi all,
How to convert Field symbol (which is an internal table) into an internal table.The Field symbol is being populated dynamically hence the structure is not fix.
01-07-2008 8:19 AM
Hello Daphne,
See this code, i'm not sure if its exactly what you want
DATA : LV_DBTAB1 LIKE DD02L-TABNAME.
DATA : DREF TYPE REF TO DATA.
FIELD-SYMBOLS: <ITAB> TYPE ANY TABLE, " used to store dynamic tables
<WA> TYPE ANY, " used to store record data
<WA1> TYPE ANY . " used to store field data
LV_DBTAB1 = 'MARA'.
data: it_mara like mara occurs 0 with header line.
CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN DREF->* TO <ITAB> .
selects all data
SELECT * FROM (LV_DBTAB1) INTO TABLE <ITAB> .
LOOP AT <ITAB> ASSIGNING <WA>.
APPEND <WA> TO IT_MARA.
ENDLOOP.
01-07-2008 8:26 AM
Hi all,
for my case i cannot hardcode any table name at all. it is dynamically selected by user. so everything is dynamically done. anyone know the way? thx
01-07-2008 8:30 AM
If everything needs to be done dynamically, then you will not need to put it into another internal table
since field symbols can point to internal tables, they can be used in a similar way to internal tables as follows
LOOP AT <ITAB> ASSIGNING <WA>.
processing
ENDLOOP.
01-07-2008 8:33 AM
but i need to export this field symbol which contain an internal table to another program. after trying to export it, i put the import statement into another program and i got this error message which say that field symbol is not assigned...
01-07-2008 8:40 AM
Interesting...
One work around I can think of is to export the table name (which the user entered as a parameter) as well
Then before importing the internal table into your second program, import that variable and assign your new field symbol to that type