Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Reading different internal table dynamically

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.

Former Member
replied
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.
0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question