‎2009 Jul 20 11:14 AM
<l_table1> is defined as an sorted table and new_table from method create_dynamic_table is coming as standard table.
when we write a statement "ASSIGN new_table1->* TO <l_table1>." Its giving runtime error type conflict.
Could you please let me know how to create sorted internal table by using method create_dynamic_table.
Create a new Table
CALL METHOD cl_alv_table_create=>create_dynamic_table
EXPORTING
it_fieldcatalog = it_fieldcat1
IMPORTING
ep_table = new_table1.
Create a new Line with the same structure of the table.
ASSIGN new_table1->* TO <l_table1>.
‎2009 Jul 20 12:36 PM
Hello Veerendranath Pichikala,
you have to use method CREATE of class CL_ABAP_TABLEDESCR. Here you can define the type of the table via parameter P_TABLE_KIND (e.g.TABLEKIND_SORTED for sorted table).
As an example you can have a look at the following snippet from the article Advanced and Generic Programming in ABAP by Björn Mielenhausen and Gerd Kluger.
DATA: lineType TYPE REF TO cl_abap_structdescr,
tableType TYPE REF TO cl_abap_tabledescr,
key TYPE abap_keydescr_tab.
lineType ?= cl_abap_typedescr=>describe_by_name( 'SPFLI' ).
APPEND 'CARRID' TO key.
APPEND 'CONNID' TO key.
tableType = cl_abap_tabledescr=>create(
p_line_type = lineType
p_table_kind = cl_abap_tabledescr=>tablekind_sorted
p_unique = abap_true
p_key = key ).Best regards,
Alej
‎2009 Jul 20 12:36 PM
Hello Veerendranath Pichikala,
you have to use method CREATE of class CL_ABAP_TABLEDESCR. Here you can define the type of the table via parameter P_TABLE_KIND (e.g.TABLEKIND_SORTED for sorted table).
As an example you can have a look at the following snippet from the article Advanced and Generic Programming in ABAP by Björn Mielenhausen and Gerd Kluger.
DATA: lineType TYPE REF TO cl_abap_structdescr,
tableType TYPE REF TO cl_abap_tabledescr,
key TYPE abap_keydescr_tab.
lineType ?= cl_abap_typedescr=>describe_by_name( 'SPFLI' ).
APPEND 'CARRID' TO key.
APPEND 'CONNID' TO key.
tableType = cl_abap_tabledescr=>create(
p_line_type = lineType
p_table_kind = cl_abap_tabledescr=>tablekind_sorted
p_unique = abap_true
p_key = key ).Best regards,
Alej
‎2009 Aug 04 7:40 PM
Check the following (It's working and in 4.6 Version). The code is part of a Rich Heilman's Blog.
field-symbols: <dyn_table> type standard table,
<dyn_wa>,
<dyn_field>.
data: dy_table type ref to data,
dy_line type ref to data.
Create dynamic internal table and assign to FS
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = (fieldcatalog)
importing
ep_table = dy_table.
assign dy_table->* to <dyn_table>.
Create dynamic work area and assign to FS
create data dy_line like line of <dyn_table>.
assign dy_line->* to <dyn_wa>.
With regards
George