09-17-2008 8:13 AM
Hi,everyone
I want to create a Dynamic table by the name which given from the seletion-screen in Unicode OS.
Can anyone give me some sample source ?
Thanks.
CHEN
09-17-2008 8:18 AM
Hi,
Please follow link
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/dynamic%2binternal%2btable
it should help to you
Regards
Jana
09-17-2008 8:18 AM
Hi,
Please follow link
https://www.sdn.sap.com/irj/sdn/wiki?path=/display/snippets/dynamic%2binternal%2btable
it should help to you
Regards
Jana
09-17-2008 8:19 AM
09-17-2008 8:19 AM
Also refer:
[http://sample-code-abap.blogspot.com/2008/07/dynamic-internal-table-and-processing.html]
09-17-2008 8:21 AM
hi,
check this link..
[https://www.sdn.sap.com/irj/sdn/weblogs?blog=/pub/wlg/2071] [original link is broken] [original link is broken] [original link is broken];
Regards,
Sathish Reddy.
09-17-2008 8:35 AM
hi Reddy
Thanks for your help.
I readed that blog and copy the code into my abap editor.
When I put the value 'T001',it worked well,
but when 'KNA1',I saw a short dump(System error).
In Unicode System, the method "cl_alv_table_create=>create_dynamic_table " is OK?
09-17-2008 8:41 AM
Hello Chen
You may have a look at thread
If you have RTTI available on your SAP system I would go for it.
Regards
Uwe
09-17-2008 8:47 AM
Hi,
Check this sample code,
DATA:
o_ref TYPE REF TO data.
FIELD-SYMBOLS:
<lt_table> TYPE STANDARD TABLE,
<fs> TYPE ANY,
<field> TYPE ANY,
<field1> TYPE ANY.
PARAMETERS:
p_tab TYPE tabname default 'MARA', " Table name (eg: MARA)
p_field(20) TYPE c default 'MATNR'. " Field name (eg: MATNR)
START-OF-SELECTION.
CREATE DATA o_ref TYPE TABLE OF (p_tab).
ASSIGN p_field TO <field1>.
ASSIGN o_ref->* TO <lt_table>.
SELECT *
INTO TABLE <lt_table>
FROM (p_tab).
LOOP AT <lt_table> ASSIGNING <fs>.
ASSIGN COMPONENT <field1> OF STRUCTURE <fs>
TO <field>.
IF sy-subrc = 0.
WRITE:/ <field>.
ENDIF.
ENDLOOP.
Regards
Adil
09-17-2008 8:56 AM
Chen,
Please run the code below, it will help you understand the concept of Dynamic Internal Table creation.
<content removed by moderator as it was just a copy/paste of someone else's work without giving credit. Any points have been unassigned.>
Cheers,
Murthy.
Edited by: Mike Pokraka on Sep 18, 2008 3:41 PM
09-17-2008 8:58 AM
Hi
Do like this.
REPORT z_test .
TYPE-POOLS: slis.
DATA: it_fieldcat TYPE lvc_t_fcat,
is_fieldcat LIKE LINE OF it_fieldcat.
DATA: new_table TYPE REF TO data.
DATA: new_line TYPE REF TO data.
FIELD-SYMBOLS: <l_table> TYPE ANY TABLE,
<l_line> TYPE ANY,
<l_field> TYPE ANY.
PARAMETERS: p_table TYPE dd02l-tabname.
* Build fieldcat
CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
EXPORTING
i_structure_name = p_table
CHANGING
ct_fieldcat = it_fieldcat[].
* Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat
IMPORTING
ep_table = new_table.
ASSIGN new_table->* TO <l_table>.
* Create Work Area
CREATE DATA new_line LIKE LINE OF <l_table>.
ASSIGN new_line->* TO <l_line>.
09-17-2008 9:00 AM