Skip to Content
Technical Articles
Author's profile photo Philip Davy

ABAP Lesser Known Heroes Series – Group Column : Part 1

Blog Series :

  1. ABAP Lesser Known Heroes Series – Group Column : Part 1
  2. ABAP Lesser Known Heroes Series – Value Operator : Part 2 | SAP Blogs
  3. ABAP Lesser Known Heroes Series – TYPE RANGE OF : Part 3 | SAP Blogs

The objective of this series is to introduce to the features( new or old ) which are lesser known but helpful . Then the obvious question comes, how could one define the lesser known or used topics . One topic known to someone does not necessarily have to be known for others and vice versa. Everyone has varied years of experience, different kind of exposures and skills.  So my strategy is as below,

  1. I am no expert , but still based on my experience and intuitions .
  2. Discussing with the fellow colleagues .
  3. How often a topic is discussed /explained in scn.sap,   if not discussed sufficiently , a yes to my post series.
  4. Availability of posts related to a topic , if not available with sufficient information , a yes to my post series .

 

Please pardon me  if you already know some of these topics.

Group Column in SE11 

An average ABAP developer will spend a good amount of time in SE11. But chances are very high that they may have noticed ( or not ) but given little importance to this column.

 

Group%20Column%20in%20SE11

Figure 1: Group Column in SE11

So what is this column basically about ?  When we have a structure which has to be  included repeatedly in another structure , we could group the includes using meaningful names.

Include%20in%20Stucture

Figure 2: Include in Structure

For example , we have a product which costs different price through out the year based on season and if we need to develop a report based on this assumption

REPORT ZSAMPLE_INCL_GROUP.


CLASS demo DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS main.
ENDCLASS.

CLASS demo IMPLEMENTATION.
  METHOD main.
    DATA prod_det TYPE zprod_det_seas.
    prod_det-summer-price   = '15.45'.
    prod_det-summer-product = '63664636' .
    prod_det-spring-price   = '215.45'.
    prod_det-spring-product = '63664637'.
    prod_det-winter-price   = '120.45'.
    prod_det-winter-product = '63664638'.
    prod_det-autumn-price   = '151.45'.
    prod_det-autumn-product = '63664639'.
    cl_demo_output=>display( prod_det ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo=>main( ).

Figure 3 : Code Example with Group Column

More information about grouping in SAP Documentation 

https://help.sap.com/doc/abapdocu_750_index_htm/7.50/en-US/abenddic_include_structure.htm

Applicability

In the above example we have only two fields in the structure with 4 different groups. Think about a report where the months of few years happen to be as columns. Suppose 04/2020 – 04/2022, then there has to be 36 Columns.  In this case we just need to create an include with a group name for each year with the months .

 

Note: When you have more ideas regarding lesser known things but which are helpful in ABAP , you can shed me more light.

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Sandra Rossi
      Sandra Rossi

      Thank you! For those people who want to declare the same type in ABAP instead of DDIC, reusing your example, the DDIC type zprod_det_seas is looking like this:

      Component   Component Type   Group
      .INCLU-SU   ZPROD_DET        SUMMER
      .INCLU-WI   ZPROD_DET        WINTER
      .INCLU-SP   ZPROD_DET        SPRING
      .INCLU-AU   ZPROD_DET        AUTOMN

      It can be declared in ABAP like this:

      TYPES BEGIN OF zprod_det_seas.
               INCLUDE TYPE zprod_det AS summer RENAMING WITH SUFFIX su.
               INCLUDE TYPE zprod_det AS winter RENAMING WITH SUFFIX wi.
               INCLUDE TYPE zprod_det AS spring RENAMING WITH SUFFIX sp.
               INCLUDE TYPE zprod_det AS automn RENAMING WITH SUFFIX au.
      TYPES END OF zprod_det_seas.
      Author's profile photo Florian Royer
      Florian Royer

      Hello Philip,

      thank you for sharing - a very useful feature which I do not want to miss.

      Two of my most important use cases for this feature:

      clear ls_data-summer.

      Deep structures that include several other structures. When displaying an alv, you always want to hide GUIDs and other fields that are not necessary for the user. Include them in a structure, group name „Tech“ and delete them by reading the structure definition.

      I am very curious about your further contributions.

      Author's profile photo Jelena Perfiljeva
      Jelena Perfiljeva

      Personally, I'm not a huge fan of such grouping but nevertheless, it's refreshing to see an ABAP blog about something that is not 1001st rendition of "export to Excel". 🙂 Perfect strategy!

      Well done and I'm sure many will find this useful.

      Author's profile photo Rodrigo Ariel Giner de la Vega
      Rodrigo Ariel Giner de la Vega

      My 2 cents, you can also use Group feature for other statements like READ TABLE, if you have table with a big composite key fields you can just use group name to simplify the code.