‎2006 Feb 24 3:52 PM
How to create dynamic internal tables as that of existing internal table.
‎2006 Feb 24 3:55 PM
Hi Vinod,
Please check this enclosed example.
<a href="http://www.sap-img.com/ab030.htm">create a Dynamic Internal Table</a>
Regards,
Lanka
‎2006 Feb 24 4:20 PM
I had one internal table with some fields.
At runtime, i want to create replicate of that internal table. any idea?
‎2006 Feb 24 4:23 PM
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