Application Development and Automation 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: 
Read only

Doubts in Declaration

Former Member
0 Likes
550

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

4 REPLIES 4
Read only

Former Member
0 Likes
525

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

Read only

Former Member
0 Likes
525

Hi,

Please go through the following linkks for Dynamic Declaration of Internal Tables.

Regards,

Ranjit Thakur.

<b>Please Mark The Helpful Answer.</b>

Read only

Former Member
0 Likes
525

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.

Read only

Former Member
0 Likes
525

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.