2012 May 25 2:10 PM
Is there any way to implement the special group functionality of the CL_GUI_ALV_GRID class in the ALV Object model (CL_SALV_TABLE class)? Any ideas would be appreciated.
2012 May 25 2:17 PM
2012 May 25 2:34 PM
I'm trying to duplicate the functionality of the CL_GUI_ALV_GRID class that is implemented through the importing parameter "IT_SPECIAL_GROUPS" in the method "SET_TABLE_FOR_FIRST_DISPLAY" along with the associated field catalog field "SP_GROUP".
I don't see a way to implement this same functionality through the CL_SALV_TABLE class (ALV Object Model).
2012 May 25 2:55 PM
Hi Jim,
I dont see any function in SALV.
But I am intrigued by CL_SALV_SORT -> SET_GROUP.
http://help.sap.com/saphelp_nw04/helpdata/en/10/e4eb40c4f8712ae10000000a155106/frameset.htm
Can you check it out? Not sure if this help!
I dont have access to system.
Thanks,
Shambu
2012 May 25 3:04 PM
Special groups is not about sorting data, its about organized grouping of the columns. I've already reviewed the standard documentation regarding all of the appropriate classes under the ALV object model. At this point, I'll assume that SAP has just not (yet) implemented this functionality. Thanks for trying.
2012 May 25 2:20 PM
2013 Feb 19 2:38 PM
Apparently in the OO version they call them now Specific Groups and there is an example program SALV_DEMO_TABLE_COLUMNS_GROUP (in Package SLIS in coutrary to other examples under SALV_OBJECTS_INT).
I think the program speaks for itself but indeed a bit more help might be given in SAP Help.
Dirk
2013 Feb 19 2:56 PM
Looks like the program SALV_DEMO_TABLE_COLUMNS_GROUP using the class CL_SALV_SPECIFIC_GROUPS is only available in newer SAP release. I can find the program in SAP ECC 6.0 EhP6, but couldn't find in ECC 6.0.
Regards,
Naimesh Patel
2013 Feb 19 3:07 PM
OK for those who don't have the Example program SALV_DEMO_TABLE_COLUMNS_GROUP here a bit how I implemented Specific Groups (and column colours):
*&---------------------------------------------------------------------*
*& Form ALV_COLUMN_SETTINGS
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_LO_ALV text
*----------------------------------------------------------------------*
FORM alv_column_settings
USING po_alv TYPE REF TO cl_salv_table.
DATA:
lr_columns TYPE REF TO cl_salv_columns_table,
lr_column TYPE REF TO cl_salv_column_table,
lt_columns_refs TYPE salv_t_column_ref,
l_color_lvl TYPE lvc_s_colo,
l_color_mbl TYPE lvc_s_colo,
l_color_mtb TYPE lvc_s_colo,
l_color_bhd TYPE lvc_s_colo,
l_color_bit TYPE lvc_s_colo,
l_color_mti TYPE lvc_s_colo,
lo_sp_groups TYPE REF TO cl_salv_specific_groups,
lo_functional_settings TYPE REF TO cl_salv_functional_settings.
CONSTANTS:
lc_sp_grp_lvl TYPE lvc_spgrp VALUE 'LVL',
lc_sp_grp_mbl TYPE lvc_spgrp VALUE 'MBL',
lc_sp_grp_mtb TYPE lvc_spgrp VALUE 'MTB',
lc_sp_grp_bhd TYPE lvc_spgrp VALUE 'BHD',
lc_sp_grp_bit TYPE lvc_spgrp VALUE 'BIT',
lc_sp_grp_mti TYPE lvc_spgrp VALUE 'MTI'.
FIELD-SYMBOLS:
<column_ref> TYPE salv_s_column_ref.
lr_columns = po_alv->get_columns( ).
lr_columns->set_optimize( abap_true ).
lt_columns_refs = lr_columns->get( ).
* Syntax of color value in col color
*{ COL_BACKGROUND } 0 GUI-specific
*{ 1 | COL_HEADING } 1 Gray-blue
*{ 2 | COL_NORMAL } 2 Light gray
*{ 3 | COL_TOTAL } 3 Yellow
*{ 4 | COL_KEY } 4 Blue-green
*{ 5 | COL_POSITIVE } 5 Green
*{ 6 | COL_NEGATIVE } 6 Red
*{ 7 | COL_GROUP } 7 Violet
l_color_lvl-col = col_key.
l_color_lvl-int = 0.
l_color_lvl-inv = 0.
l_color_mbl-col = col_normal.
l_color_mbl-int = 0.
l_color_mbl-inv = 0.
l_color_mtb-col = col_normal.
l_color_mtb-int = 1.
l_color_mtb-inv = 0.
l_color_bhd-col = col_heading.
l_color_bhd-int = 0.
l_color_bhd-inv = 0.
l_color_bit-col = col_total.
l_color_bit-int = 0.
l_color_bit-inv = 0.
l_color_mti-col = col_total.
l_color_mti-int = 1.
l_color_mti-inv = 0.
lo_functional_settings = po_alv->get_functional_settings( ).
lo_sp_groups = lo_functional_settings->get_specific_groups( ).
TRY.
lo_sp_groups->add_specific_group(
id = lc_sp_grp_lvl
text = 'Line Level Data' ).
lo_sp_groups->add_specific_group(
id = lc_sp_grp_mbl
text = 'Material-BOM Link Data' ).
lo_sp_groups->add_specific_group(
id = lc_sp_grp_mtb
text = 'Material-BOM Link Material Data' ).
lo_sp_groups->add_specific_group(
id = lc_sp_grp_bhd
text = 'BOM Header Data' ).
lo_sp_groups->add_specific_group(
id = lc_sp_grp_bit
text = 'BOM Item Data' ).
lo_sp_groups->add_specific_group(
id = lc_sp_grp_mti
text = 'BOM Item Material Data' ).
CATCH cx_salv_existing .
ENDTRY.
LOOP AT lt_columns_refs
ASSIGNING <column_ref>.
IF <column_ref>-columnname CP zmm_md_bom_data_provider=>gc_alv_pttrn_line_level.
lr_column ?= <column_ref>-r_column.
lr_column->set_color( value = l_color_lvl ).
lr_column->set_specific_group( id = lc_sp_grp_lvl ).
ENDIF.
IF <column_ref>-columnname CP zmm_md_bom_data_provider=>gc_alv_pttrn_matrial_bom_link.
lr_column ?= <column_ref>-r_column.
lr_column->set_color( value = l_color_mbl ).
lr_column->set_specific_group( id = lc_sp_grp_mbl ).
ENDIF.
IF <column_ref>-columnname CP zmm_md_bom_data_provider=>gc_alv_pttrn_mbl_material_data.
lr_column ?= <column_ref>-r_column.
lr_column->set_color( value = l_color_mtb ).
lr_column->set_specific_group( id = lc_sp_grp_mtb ).
ENDIF.
IF <column_ref>-columnname CP zmm_md_bom_data_provider=>gc_alv_pttrn_bom_header.
lr_column ?= <column_ref>-r_column.
lr_column->set_color( value = l_color_bhd ).
lr_column->set_specific_group( id = lc_sp_grp_bhd ).
ENDIF.
IF <column_ref>-columnname CP zmm_md_bom_data_provider=>gc_alv_pttrn_bom_item.
lr_column ?= <column_ref>-r_column.
lr_column->set_color( value = l_color_bit ).
lr_column->set_specific_group( id = lc_sp_grp_bit ).
ENDIF.
IF <column_ref>-columnname CP zmm_md_bom_data_provider=>gc_alv_pttrn_bit_material_data.
lr_column ?= <column_ref>-r_column.
lr_column->set_color( value = l_color_mti ).
lr_column->set_specific_group( id = lc_sp_grp_mti ).
ENDIF.
ENDLOOP.
ENDFORM. " ALV_COLUMN_SETTINGS
Hope this can be useful for some of the readers.
Dirk