2006 Jun 04 9:37 AM
Hi,
I need to display some information using ALV. But my table's columns are not static. Its column size can be change respect to station. Now, It it possible to add new columns to internal table and show with ALV?
Thanks.
2006 Jun 04 2:55 PM
Hi,
Take a look at these blogs which deal with dynamic internal tables ....
/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
You will have to create the entire internal table dynamically, once created you cannot add any more fields to the table.
Regards,
Ravi
Note :Please mark the helpful answers
2006 Jun 04 9:48 AM
Can'nt we try to fill field catalog based on the logic?
Regds
Manohar
2006 Jun 04 9:53 AM
Hi,
I mean that my internal table's column size can be 10 or 15 or 17 or another number respect to user's selection. So, I can not define internal table statically.
2006 Jun 04 9:55 AM
As manohar said modify the field catalog and dont forget to call
REFRESH_TABLE_DISPLAY method of cl_gui_alv_grid. (i assume you are using class based ALV)
Regards
Raja
2006 Jun 04 9:57 AM
in such a case you need to define the internal table dynamically
which can be done using
call method cl_alv_table_create=>create_dynamic_table
exporting
it_fieldcatalog = it_fieldcat
importing
ep_table = new_table.
search this forum for code sample on using this.
Regards
Raja
2006 Jun 04 9:58 AM
then you need to create dynamic internal table and respective field catalog.
Regds
Manohar
2006 Jun 04 10:52 AM
HI,
This is a Example progrma to create a Dinamic Internal table
*&---------------------------------------------------------------------*
*& Report ZDEEP_DYNAMIC_INTERNALTABLE *
*& *
*&---------------------------------------------------------------------*
*& *
*& *
*&---------------------------------------------------------------------*
report zdeep_dynamic_internaltable .
data: d_ref type ref to data,
d_ref2 type ref to data ,
i_alv_cat type table of lvc_s_fcat,
ls_alv_cat like line of i_alv_cat.
types tabname like dcobjdef-name .
parameter: p_tablen type tabname.
data: begin of itab occurs 0.
include structure dntab.
data: end of itab.
field-symbols : <f_fs> type table,
<f_fs1> type table,
<f_fs2> type any,
<f_fs3> type table,
<f_fs4> type any.
refresh itab.
call function 'NAMETAB_GET'
exporting
langu = sy-langu
tabname = p_tablen
tables
nametab = itab
exceptions
no_texts_found = 1.
loop at itab .
ls_alv_cat-fieldname = itab-fieldname.
ls_alv_cat-ref_table = p_tablen.
ls_alv_cat-ref_field = itab-fieldname.
append ls_alv_cat to i_alv_cat.
endloop.
* internal table build
call method cl_alv_table_create=>create_dynamic_table
exporting it_fieldcatalog = i_alv_cat
importing ep_table = d_ref .
assign d_ref->* to <f_fs>.
select * from (p_tablen) into corresponding fields of table <f_fs>.
loop at <f_fs> assigning <f_fs2>.
assign itab-fieldname to <f_fs4>.
loop at itab.
write: / <f_fs4>.
endloop.
endloop.
Hope this helps you
Thanks
Sudheer
2006 Jun 04 10:56 AM
2006 Jun 04 2:55 PM
Hi,
Take a look at these blogs which deal with dynamic internal tables ....
/people/ravikumar.allampallam/blog/2005/05/31/expand-the-list-of-columns-in-a-report-dynamically
/people/subramanian.venkateswaran2/blog/2004/11/19/dynamic-internal-table
/people/rich.heilman2/blog/2005/07/27/dynamic-internal-tables-and-structures--abap
You will have to create the entire internal table dynamically, once created you cannot add any more fields to the table.
Regards,
Ravi
Note :Please mark the helpful answers