2007 Jul 11 7:38 AM
Hi,
how many Columns does ALV Grid support? Or is there no limit?
//Rainer
2007 Jul 11 7:47 AM
2007 Jul 11 7:43 AM
2007 Jul 11 7:44 AM
2007 Jul 11 7:44 AM
It can support 99 columns and you can surpress fields.
Regards,
Sairam
2007 Jul 11 7:47 AM
2007 Jul 11 8:12 AM
Hello Rainer
With the following sample report I had no problem to create and display an ALV list having 6.900 columns.
*&---------------------------------------------------------------------*
*& Report ZUS_SDN_RTTI_CREATE_ITAB_1
*&
*&---------------------------------------------------------------------*
*& NOTE: check limitation of columns for ALV list
*&
*&---------------------------------------------------------------------*
REPORT zus_sdn_rtti_create_itab_1.
TYPE-POOLS: abap.
DATA:
gd_tabnam TYPE string,
gd_tabfield TYPE string,
gd_fldname TYPE fieldname,
go_table TYPE REF TO cl_salv_table,
go_sdescr TYPE REF TO cl_abap_structdescr,
go_sdescr_new TYPE REF TO cl_abap_structdescr,
go_tdescr TYPE REF TO cl_abap_tabledescr,
go_typedescr TYPE REF TO cl_abap_typedescr,
gdo_handle TYPE REF TO data,
gs_component TYPE abap_compdescr,
gt_components TYPE abap_compdescr_tab,
*
gs_comp TYPE abap_componentdescr,
gt_comp TYPE abap_component_tab.
*
FIELD-SYMBOLS:
<gt_p0002x> TYPE STANDARD TABLE.
PARAMETER:
p_tabnam TYPE tabname DEFAULT 'P0002',
p_repeat TYPE i DEFAULT '1'.
START-OF-SELECTION.
" Describe structure
go_sdescr ?= cl_abap_structdescr=>describe_by_name( p_tabnam ).
gt_components = go_sdescr->components.
REFRESH: gt_comp.
DO p_repeat TIMES.
LOOP AT gt_components INTO gs_component.
" Build fieldname
CONCATENATE p_tabnam gs_component-name INTO gd_tabfield
SEPARATED BY '-'.
CLEAR: gs_comp.
gs_comp-type ?= cl_abap_datadescr=>describe_by_name( gd_tabfield ).
gs_comp-name = gs_component-name.
APPEND gs_comp TO gt_comp.
ENDLOOP.
ENDDO.
" Renaming of columns
LOOP AT gt_comp INTO gs_comp.
WRITE syst-tabix TO gd_fldname NO-ZERO.
REPLACE ALL OCCURRENCES OF '.' IN gd_fldname WITH ' '.
CONDENSE gd_fldname NO-GAPS.
CONCATENATE 'COLUMN_' gd_fldname INTO gd_fldname.
CONDENSE gd_fldname NO-GAPS.
gs_comp-name = gd_fldname.
MODIFY gt_comp FROM gs_comp INDEX syst-tabix.
ENDLOOP.
DESCRIBE TABLE gt_comp.
MESSAGE s398(00) WITH 'No. of columns =' syst-tfill space space.
" Display component list
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_table
CHANGING
t_table = gt_comp.
go_table->display( ).
CATCH cx_salv_msg .
ENDTRY.
go_sdescr_new = cl_abap_structdescr=>create( gt_comp ).
go_tdescr = cl_abap_tabledescr=>create( go_sdescr_new ).
" Create data refence followed by table creation
CREATE DATA gdo_handle TYPE HANDLE go_tdescr.
ASSIGN gdo_handle->* TO <gt_p0002x>.
DO 10 TIMES.
APPEND INITIAL LINE TO <gt_p0002x>.
ENDDO.
TRY.
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = go_table
CHANGING
t_table = <gt_p0002x>.
go_table->display( ).
CATCH cx_salv_msg .
ENDTRY.
END-OF-SELECTION.
Regards
Uwe