‎2007 May 16 1:05 PM
Hi,
I want to declare a internal table with the dynamic type.
To be more clear if you enter the table name in the selection screen then that should be the type of the internal table.
Data : I_ITAB type < table name given in the selection screen>
Thanks
‎2007 May 16 1:12 PM
Hi,
I hope it will not work...Becoz it will be problematic when u work with this type..Internal tables itself will only work in the runtime only...
Reward if useful
‎2007 May 16 1:13 PM
‎2007 May 16 1:14 PM
Hi,
do like this.
in this example db_table is the table name u will enter from selection-screen
parameters:DB_TABLE(30).
DATA FCAT1 TYPE LVC_T_FCAT."fieldcat of type internal table
DATA:DYN_ITAB TYPE REF TO DATA,"holding the dynamic internal table
WA TYPE REF TO DATA."holding the wa for dynamic internal table
FIELD-SYMBOLS: <DISP_TABLE> TYPE TABLE,
<WA> TYPE ANY.
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'"creating fieldcat to create a dynamic internal table
EXPORTING
I_STRUCTURE_NAME = DB_TABLE
CHANGING
CT_FIELDCAT = FCAT1[].
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE"creating dynamic internal table using fieldcat
EXPORTING
IT_FIELDCATALOG = FCAT1[]
IMPORTING
EP_TABLE = DYN_ITAB.
ASSIGN DYN_ITAB->* TO <DISP_TABLE>."creating internal table by refering the dynamically generated internal table structure
CREATE DATA WA LIKE LINE OF <DISP_TABLE>."creating work area for the internal table
ASSIGN WA->* TO <WA>.
<DISP_TABLE> is ur internal table generated dynamically
<wa> is ur work area for this internal table.
rgds,
bharat.
rgds,
bharat.
‎2007 May 16 1:22 PM
first u need to goto table DD03L and get all the field labels into an internal table for the table specified on the selection screen.
now, u need to create a dynamic internal table using field symbols concept for the fields u have fetched.
then, u can use this dynamic internal table for ur purpose.