Application Development 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: 

ALV Group by

Former Member
0 Kudos
279

In my ALV report, I would like to group by Sales Order. How to accomplish this. Thank you

      WHEN 'VBELN_VA'.
        wa_fieldcatalog-seltext_l = 'Order No.'.
        wa_fieldcatalog-reptext_ddic = 'Order No.'.
        wa_fieldcatalog-emphasize = 'X'.
        wa_fieldcatalog-key = 'X'.
        MOVE: wa_fieldcatalog-seltext_l TO wa_fieldcatalog-seltext_m,
              wa_fieldcatalog-seltext_l TO wa_fieldcatalog-seltext_s.
        ADD 1 TO wa_fieldcatalog-col_pos.

1 ACCEPTED SOLUTION

Former Member
0 Kudos
127

I have the following code so far. It gives me error gd_sort is a table without header line and therefore has no component called Fieldname. I cannot add headerline to gd_sort as that will make the program to dump because of mismatch in data type. Any ideas?

      gd_sort      TYPE slis_t_sortinfo_alv,

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = repid
      i_callback_user_command = 'USER_COMMAND'
      is_layout               = gd_layout
      it_fieldcat             = fieldcatalog
      it_sort                 = gd_sort
      it_events               = gt_events
      is_print                = gd_prntparams
      i_save                  = 'X'
    TABLES
      t_outtab                = i_zopen_alv
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.

FORM build_sort.
  gd_sort-fieldname = 'VBELN_VA'.
  APPEND gd_sort.
ENDFORM.                    "build_sort

6 REPLIES 6

dhorions
Contributor
0 Kudos
127

You can find how to do that in .<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">this document</a>

alejandro_bindi
Active Contributor
0 Kudos
127

Use the sorting table, like in this code:


FORM f_grouping
     CHANGING lpi_sort TYPE slis_t_sortinfo_alv.

  DATA: lwa_sort LIKE LINE OF lpi_sort.

* Sorting and subtotaling by PO
  lwa_sort-fieldname = 'EBELN'.
  lwa_sort-up        = k_true. " 'X'
  lwa_sort-subtot    = k_true. " 'X'
  APPEND lwa_sort TO lpi_sort.

ENDFORM.                    " f_grouping

Then you must send the sorting table to the ALV function module.

If you're using OO ALV, it provides similar functionality.

Regards

Please reward points if helpful.

Message was edited by:

Alejandro Bindi

Former Member
0 Kudos
127

I am using REUSE_ALV

0 Kudos
127

Ok, on the REUSE_ALV_GRID_DISPLAY f.m., it's the it_sort parameter.

Regards

Former Member
0 Kudos
128

I have the following code so far. It gives me error gd_sort is a table without header line and therefore has no component called Fieldname. I cannot add headerline to gd_sort as that will make the program to dump because of mismatch in data type. Any ideas?

      gd_sort      TYPE slis_t_sortinfo_alv,

  CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      i_callback_program      = repid
      i_callback_user_command = 'USER_COMMAND'
      is_layout               = gd_layout
      it_fieldcat             = fieldcatalog
      it_sort                 = gd_sort
      it_events               = gt_events
      is_print                = gd_prntparams
      i_save                  = 'X'
    TABLES
      t_outtab                = i_zopen_alv
    EXCEPTIONS
      program_error           = 1
      OTHERS                  = 2.

FORM build_sort.
  gd_sort-fieldname = 'VBELN_VA'.
  APPEND gd_sort.
ENDFORM.                    "build_sort

0 Kudos
127

Check this modification of your code:


FORM build_sort.

  DATA: lwa_sort TYPE slis_sortinfo_alv.

  lwa_sort-fieldname = 'VBELN_VA'.
  APPEND lwa_sort TO gd_sort.
ENDFORM.                    "build_sort

Regards

Please reward points if helpful.