‎2009 Jan 12 5:54 AM
Hi Experts,
I have Table Name on the selection screen. Inside program I would like to create the Internal table based on the users input example if user gives MARA then internally Internal should be declared of MARA type.
How can we achieve this ? Please reply.
‎2009 Jan 12 6:45 AM
Hello
I advise against using method cl_alv_table_create=>create_dynamic_table. Instead I recommend to use either RTTI or data objects (if available in your SAP release) to create these runtime objects.
DATA: ldo_data TYPE REF TO data,
ld_tabnam TYPE tabname.
FIELD-SYMBOLS:
<lt_itab> TYPE TABLE.
ld_tabnam = 'MARA'.
CREATE DATA ldo_data TYPE STANDARD TABLE OF ( ld_tabnam ).
ASSIGN ldo_data->* TO <lt_itab>.
SELECT * FROM (ld_tabnam) INTO TABLE <lt_itab>.
Regards
Uwe
‎2009 Jan 12 5:58 AM
Hi,
I hope the below link will help you.
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
Thanks & Regards,
Khushboo.
‎2009 Jan 12 6:03 AM
Here are several examples how you can process the dynamic table afterwords.
now you have a line of the internal table
FIELD-SYMBOLS: <fs_dyn_table> LIKE LINE OF dyn_table.
this can be used for any field
FIELD-SYMBOLS: <fs_component> TYPE ANY.
example read
READ TABLE dyn_table ASSIGNING <fs_dyn_table>
INDEX 1.
example loop
LOOP AT dyn_table ASSIGNING <fs_dyn_table>.
place your coding here
ENDLOOP.
once you have a line you can display its elements
DO.
ASSIGN COMPONENT sy-index OF
STRUCTURE <fs_dyn_table> TO <fs_component>.
IF sy-subrc 0. EXIT. ENDIF.
WRITE / <fs_component>.
ENDDO.
if you want to display by name
ASSIGN COMPONENT 'COMPONENT_NAME' OF STRUCTURE <fs_dyn_table>
TO <fs_component>.
IF sy-subrc EQ 0.
WRITE: / 'Specific component ' , <fs_component>.
ENDIF.
‎2009 Jan 12 6:45 AM
Hello
I advise against using method cl_alv_table_create=>create_dynamic_table. Instead I recommend to use either RTTI or data objects (if available in your SAP release) to create these runtime objects.
DATA: ldo_data TYPE REF TO data,
ld_tabnam TYPE tabname.
FIELD-SYMBOLS:
<lt_itab> TYPE TABLE.
ld_tabnam = 'MARA'.
CREATE DATA ldo_data TYPE STANDARD TABLE OF ( ld_tabnam ).
ASSIGN ldo_data->* TO <lt_itab>.
SELECT * FROM (ld_tabnam) INTO TABLE <lt_itab>.
Regards
Uwe
‎2009 Jan 12 6:52 AM
Hi Soniya,
There are many threads regarding dynamic internal table, please search SCN before you post a question.
for dynamic internal table refer to the link below:
http://www.sap-img.com/ab030.htm
With luck,
Pritam.