2010 Apr 19 11:04 AM
Hi all,
I have created an internal table dynamically using the method
CALL METHOD CL_ALV_TABLE_CREATE=>CREATE_DYNAMIC_TABLE
EXPORTING
IT_FIELDCATALOG = IT_FIELDCAT2[]
IMPORTING
EP_TABLE = L_TABLE.
ASSIGN L_TABLE->* TO <IT_TABLE>.
CREATE DATA wa_table LIKE LINE OF <it_table>.
ASSIGN wa_table->* TO <wa_table1>.
when I tried to append data into the internal table <it_table>
as below
ex : <wa_table1>-prueflos = wa_item-prueflos.
it is giving the error as 'The data object <wa_table1> has no structure therefore no component called prueflos'.
can anybody tell me how to append data into a dynamically created internal table.
Thanks,
Sudheer
Hi,
Actually my data is in another internal table.
Based on some conditions I have to move the data into my dynamic internal table.
Can you tell me how to move the data from one internal table to dynamic internal table.
Thanks,
Sudheer
2010 Apr 19 11:12 AM
FAQ. You have to use [ASSIGN COMPONENT OF STRUCTURE|http://help.sap.com/abapdocu_70/en/ABAPASSIGN_MEM_AREA_DYNAMIC_DOBJ.htm#!ABAP_ALTERNATIVE_4@4@] to populate data to the dynamic internal table.
2010 Apr 19 11:15 AM
Hi Sudheer,
You need to use the ASSIGN COMPONENT command for this purpose. Check this code:
FIELD-SYMBOLS: <t_dyntable> TYPE STANDARD TABLE, u201C Dynamic internal table name
<fs_dyntable>, u201C Field symbol to create work area
<fs_fldval> type any. u201C Field symbol to assign values
* ***....
* ***....
* ***....
* ***....
* Assume your internal table has fields COL1, COL2, COL3 etc
DO p_cols TIMES.
index = sy-index.
MOVE sy-index TO wa_colno.
CONCATENATE 'COL'
wa_colno
INTO wa_flname.
* Set up fieldvalue
CONCATENATE 'VALUE' index INTO
fieldvalue.
CONDENSE fieldvalue NO-GAPS.
ASSIGN COMPONENT wa_flname
OF STRUCTURE <fs_dyntable> TO <fs_fldval>.
<fs_fldval> = fieldvalue.
ENDDO.
Hope this solves your problem!
Cheers,
Shailesh.
2010 Apr 19 11:27 AM
Hi,
Actually my data is in another internal table.
Based on some conditions I have to move the data into my dynamic internal table.
Can you tell me how to move the data from one internal table to dynamic internal table.
Thanks,
Sudheer
2010 Apr 19 11:36 AM
2010 Apr 19 12:06 PM
Please check this example.............
FIELD-SYMBOLS: <t> TYPE STANDARD TABLE,
<wa_t> TYPE ANY,
<field> TYPE ANY.
TYPES : BEGIN OF t_tab,
test1 TYPE c,
test2 TYPE c,
END OF t_tab.
DATA : table TYPE STANDARD TABLE OF t_tab,
wa_table TYPE t_tab,
table1 TYPE STANDARD TABLE OF t_tab,
wa_table1 TYPE t_tab.
ASSIGN ('WA_TABLE') TO <wa_t>.
ASSIGN ('TABLE') TO <t>.
wa_table1-test1 = '1'.
wa_table1-test2 = '2'.
APPEND wa_table1 TO table1.
LOOP AT table1 INTO wa_table1.
ASSIGN COMPONENT 'TEST1' OF STRUCTURE <wa_t> TO <field>. "Refer a particular field
<FIELD> = wa_table1-test1.
ASSIGN COMPONENT 'TEST2' OF STRUCTURE <wa_t> TO <field>. "Refer a particular field
<FIELD> = wa_table1-test2.
APPEND <wa_t> TO <t>.
ENDLOOP.
| User | Count |
|---|---|
| 6 | |
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |