‎2008 Nov 04 7:28 AM
Hi,
What is the purpose of using special groups in ALV function modules i.e., using
it_sp_group type slis_t_sp_group_alv.
Is any prerequisite required for using this.
Thankful if explained with an example,
I tried to explore, but not so clear.
Rgds
khadeer.
‎2008 Nov 04 11:49 AM
Hi Khadeer,
Here is an example program that creates two special groups..
report zgroup.
type-pools: slis.
data: gs_fcat type slis_fieldcat_alv,
gs_grp type slis_sp_group_alv,
gt_fcat type slis_t_fieldcat_alv,
gt_grp type slis_t_sp_group_alv,
gt_t001 type table of t001.
start-of-selection.
select * into table gt_t001 from t001.
clear: gt_fcat, gt_grp.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'T001'
changing
ct_fieldcat = gt_fcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
* Group some columns together under a label of Group A
read table gt_fcat into gs_fcat with key fieldname = 'WAERS'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'A'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
read table gt_fcat into gs_fcat with key fieldname = 'SPRAS'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'A'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
gs_grp-sp_group = 'A'.
gs_grp-text = 'Group A'.
append gs_grp to gt_grp.
* Group some columns together under a label of Group B
read table gt_fcat into gs_fcat with key fieldname = 'STCEG'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'B'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
read table gt_fcat into gs_fcat with key fieldname = 'TXJCD'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'B'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
gs_grp-sp_group = 'B'.
gs_grp-text = 'Group B'.
append gs_grp to gt_grp.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = gt_fcat
it_special_groups = gt_grp
tables
t_outtab = gt_t001
exceptions
program_error = 1
others = 2.If you run the program and then select the Change Layout icon (CTRL + F8), and select say the sort order TAB. By default in the Hidden Column list you will see all the fields from T001, if you select the down arrow on the filter button you can change the displayed fields to those in your special group.
Regards,
Darren
‎2008 Nov 04 11:49 AM
Hi Khadeer,
Here is an example program that creates two special groups..
report zgroup.
type-pools: slis.
data: gs_fcat type slis_fieldcat_alv,
gs_grp type slis_sp_group_alv,
gt_fcat type slis_t_fieldcat_alv,
gt_grp type slis_t_sp_group_alv,
gt_t001 type table of t001.
start-of-selection.
select * into table gt_t001 from t001.
clear: gt_fcat, gt_grp.
call function 'REUSE_ALV_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'T001'
changing
ct_fieldcat = gt_fcat
exceptions
inconsistent_interface = 1
program_error = 2
others = 3.
* Group some columns together under a label of Group A
read table gt_fcat into gs_fcat with key fieldname = 'WAERS'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'A'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
read table gt_fcat into gs_fcat with key fieldname = 'SPRAS'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'A'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
gs_grp-sp_group = 'A'.
gs_grp-text = 'Group A'.
append gs_grp to gt_grp.
* Group some columns together under a label of Group B
read table gt_fcat into gs_fcat with key fieldname = 'STCEG'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'B'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
read table gt_fcat into gs_fcat with key fieldname = 'TXJCD'.
if ( sy-subrc = 0 ).
gs_fcat-sp_group = 'B'.
modify gt_fcat from gs_fcat index sy-tabix.
endif.
gs_grp-sp_group = 'B'.
gs_grp-text = 'Group B'.
append gs_grp to gt_grp.
call function 'REUSE_ALV_GRID_DISPLAY'
exporting
it_fieldcat = gt_fcat
it_special_groups = gt_grp
tables
t_outtab = gt_t001
exceptions
program_error = 1
others = 2.If you run the program and then select the Change Layout icon (CTRL + F8), and select say the sort order TAB. By default in the Hidden Column list you will see all the fields from T001, if you select the down arrow on the filter button you can change the displayed fields to those in your special group.
Regards,
Darren