Technical Articles
ABAP Lesser Known Heroes Series – Group Column : Part 1
Blog Series :
- ABAP Lesser Known Heroes Series – Group Column : Part 1
- ABAP Lesser Known Heroes Series – Value Operator : Part 2 | SAP Blogs
- 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,
- I am no expert , but still based on my experience and intuitions .
- Discussing with the fellow colleagues .
- How often a topic is discussed /explained in scn.sap, if not discussed sufficiently , a yes to my post series.
- 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.
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.
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.
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:
It can be declared in ABAP like this:
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.
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.
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.