Application Development 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: 

How to convert field symbol to an internal table?

Former Member
0 Kudos

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.

5 REPLIES 5

former_member189059
Active Contributor
0 Kudos

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.

0 Kudos

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

0 Kudos

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.

Former Member
0 Kudos

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...

0 Kudos

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