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: 

Reading different internal table dynamically

Former Member
0 Kudos

Hi Gurus,

I have a requierement where I need to read differrent internal tables starting with GT_TXT_* and whcih tabel is going to be read will be decided at runtime only.

I tried the following code but it's giving syntax error. Any suggestions ?

DATA : l_tabname(14) TYPE c.

FIELD-SYMBOLS: <dyn_table> TYPE STANDARD TABLE any.

DATA dref TYPE REF TO ty_struc.

CONCATENATE 'GT_TXT_' belege-field INTO l_tabname.

ASSIGN (l_tabname) TO <dyn_table>.

READ TABLE <dyn_table> INTO struc_txt WITH KEY key = t_output-old_val.

IF sy-subrc = 0.

t_output-old_val = struc_txt-text.

ENDIF.

Regards,

Sandip.

1 ACCEPTED SOLUTION

Pawan_Kesari
Active Contributor
0 Kudos
TYPES : t_mara TYPE TABLE OF mara .

DATA : gt_txt_1 TYPE t_mara ,
       gt_txt_2 TYPE t_mara .
DATA : gs_txt TYPE mara .

DATA : l_tabname(14) TYPE c.
FIELD-SYMBOLS: <dyn_table> TYPE t_mara .

CONCATENATE 'GT_TXT_' '1' INTO l_tabname.
ASSIGN (l_tabname) TO <dyn_table>.

READ TABLE <dyn_table> INTO gs_txt WITH KEY matnr = 'abc' .
IF sy-subrc = 0.

ENDIF.
2 REPLIES 2

Pawan_Kesari
Active Contributor
0 Kudos
TYPES : t_mara TYPE TABLE OF mara .

DATA : gt_txt_1 TYPE t_mara ,
       gt_txt_2 TYPE t_mara .
DATA : gs_txt TYPE mara .

DATA : l_tabname(14) TYPE c.
FIELD-SYMBOLS: <dyn_table> TYPE t_mara .

CONCATENATE 'GT_TXT_' '1' INTO l_tabname.
ASSIGN (l_tabname) TO <dyn_table>.

READ TABLE <dyn_table> INTO gs_txt WITH KEY matnr = 'abc' .
IF sy-subrc = 0.

ENDIF.

Former Member
0 Kudos

Hi ,

You can check the my post in the thread in specified in the bellow link --

[https://forums.sdn.sap.com/click.jspa?searchID=-1&messageID=7545053]

You can check the link bellow --

[https://wiki.sdn.sap.com/wiki/display/Snippets/Howtocreateinternaltable+dynamically]

Regards

Pinaki