Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ALV function modules

Former Member
0 Likes
486

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
356

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

1 REPLY 1
Read only

Former Member
0 Likes
357

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