06-06-2008 8:30 AM
Hi All,
One simple question maybe.
In my selection screen i am getting input as one of the standard table say 'SE11'.
Now in my code i want to make a standard table or internal type/like the input given table name, in this case "SE11".
Is this possible? If yes can you give a hint on the code.
Regds,
Shashank
06-06-2008 9:57 AM
Hi
Yes it is you need to use réferences and field symbols.
Here is a sample code that select all data of a given table and print it.
PARAMETERS: p_tab TYPE tabname16.
DATA: ls_tab TYPE REF TO data.
FIELD-SYMBOLS: <ft> TYPE ANY TABLE,
<fs> TYPE ANY.
TRY.
" Create the internal table
CREATE DATA ls_tab TYPE TABLE OF (p_tab).
" To access the reference data you need to assign it to a field symbol
ASSIGN ls_tab->* TO <ft>.
IF sy-subrc NE 0.
MESSAGE 'Error' TYPE 'E'.
ENDIF.
"
SELECT * FROM (p_tab) INTO TABLE <ft>.
LOOP AT <ft> ASSIGNING <fs>.
WRITE : / <fs>.
ENDLOOP.
CATCH cx_root.
MESSAGE 'Error' TYPE 'E'.
ENDTRY.
Hope it helps
Regards
06-06-2008 9:57 AM
Hi
Yes it is you need to use réferences and field symbols.
Here is a sample code that select all data of a given table and print it.
PARAMETERS: p_tab TYPE tabname16.
DATA: ls_tab TYPE REF TO data.
FIELD-SYMBOLS: <ft> TYPE ANY TABLE,
<fs> TYPE ANY.
TRY.
" Create the internal table
CREATE DATA ls_tab TYPE TABLE OF (p_tab).
" To access the reference data you need to assign it to a field symbol
ASSIGN ls_tab->* TO <ft>.
IF sy-subrc NE 0.
MESSAGE 'Error' TYPE 'E'.
ENDIF.
"
SELECT * FROM (p_tab) INTO TABLE <ft>.
LOOP AT <ft> ASSIGNING <fs>.
WRITE : / <fs>.
ENDLOOP.
CATCH cx_root.
MESSAGE 'Error' TYPE 'E'.
ENDTRY.
Hope it helps
Regards