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

Dynamic internal table

Former Member
0 Likes
505

How to create dynamic internal tables as that of existing internal table.

3 REPLIES 3
Read only

Former Member
0 Likes
442

Hi Vinod,

Please check this enclosed example.

<a href="http://www.sap-img.com/ab030.htm">create a Dynamic Internal Table</a>

Regards,

Lanka

Read only

0 Likes
442

I had one internal table with some fields.

At runtime, i want to create replicate of that internal table. any idea?

Read only

0 Likes
442
u can create dynamic table like this by using the fieldcatalog of ur previous internal table


******DATA DECLARATION*****************************

FIELD-SYMBOLS : <it_final> TYPE STANDARD TABLE,
                <wa_final> TYPE ANY,
                <w_field> TYPE ANY.


********CREATE DYNAMIC TABLE************************

  CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
      it_fieldcatalog           = it_fieldcatalog
    IMPORTING
      ep_table                  = new_table
    EXCEPTIONS
      generate_subpool_dir_full = 1
      OTHERS                    = 2.
  IF sy-subrc <> 0.
*  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.

  ASSIGN new_table->* TO <it_final>.

*********CREATE WORK AREA****************************

CREATE DATA new_line LIKE LINE OF <it_final>.
  ASSIGN new_line->* TO <wa_final>.

*********INSERTTING WORK AREAR TO INTERNAL TABLE******

    INSERT <wa_final> INTO TABLE <it_final>.

*******POPULATING DATA*******************************  
  LOOP.
   
   ASSIGN COMPONENT 'FIELD1' OF STRUCTURE <wa_final> TO <w_field>.
   <w_field> = '12345'.

    ASSIGN COMPONENT 'FIELD2' OF STRUCTURE <wa_final> TO <w_field>.
   <w_field> = '21453DD'.

   FIELD1 AND FIELD2 ARE COMPONENTS OF FIELDCATALOG.
    
ENDLOOP.      

  ENDLOOP.

Message was edited by: Sekhar