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

Create internal table structure dynamically

Former Member
0 Likes
623

Hi ,

can any one help me out with creating an internal table structure dynamically.

my requirement is as follows:

i have a parameter to select a condition table(parameter: p_table like MV12A-KOTABNR)....my program should create an internal table structure dynamically for the selected table.

any help would be appreciated

thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
560

Please have a look at below weblog from Rich:

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Also you may have a look at below link.

http://www.sap-img.com/ab030.htm

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

3 REPLIES 3
Read only

Former Member
0 Likes
561

Please have a look at below weblog from Rich:

/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap

Also you may have a look at below link.

http://www.sap-img.com/ab030.htm

I hope it helps.

Best Regards,

Vibha

*Please mark all the helpful answers

Read only

Former Member
0 Likes
560
  FIELD-SYMBOLS: <fs_table> TYPE STANDARD TABLE.
  FIELD-SYMBOLS: <fs_line> TYPE ANY.

  CREATE DATA dref_table TYPE TABLE OF (p_table).
  CREATE DATA dref_table_line TYPE (p_table).

  ASSIGN dref_table->* TO <fs_table>.
  ASSIGN dref_table_line->* TO <fs_line>.

Now <fs_table> will have the same structure as the database table.

Read only

Former Member
0 Likes
560
try something like this

REPORT YCHATEST1.

PARAMETERS : P_TABLE LIKE DD02L-TABNAME.

DATA : IT_FIELDCAT TYPE LVC_T_FCAT,
       NEW_TABLE TYPE REF TO DATA.

FIELD-SYMBOLS : <FS> TYPE STANDARD TABLE.

ASSIGN (P_TABLE) TO <FS>.

CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
  EXPORTING
    I_STRUCTURE_NAME = <FS>
  CHANGING
    CT_FIELDCAT      = IT_FIELDCAT.

CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
  EXPORTING
    IT_FIELDCATALOG = IT_FIELDCAT
  IMPORTING
    EP_TABLE        = NEW_TABLE.