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

What is this feature of ALV called? The ability to display a heading to every group after sorting

JoshGn_zzz
Explorer
0 Kudos
203

Hi,

We have a requirement to Sort a report by Purchase Order and Purchase Requisition, and label each group with the corresponding PO& PR Number. (Please see screenshot below from ME2L)

My problem is, i am unable to recall the ABAP/ALV terminology to do this. 

Can anyone point me in the right direction, so i can use it for searching further. 

I tried 'Sort' & 'Aggregation'. But this does not seem to be it.

We are looking for the below effect which can be seen in ME2L. Where there report is sorted by Vendor/Supplying plant & Purchasing document. But whenever a new Vendor starts in the report, the large yellow line appears with a label identifying the Vendor/Supplying plant with the number and name. Whenever a new Purchasing document starts in the report, a large yellow line appears with a label identifying the Purchasing document.

I analysed the background code. I noticed they are just passing in the 'SORT' table with the two fields. I am unable to identify anything which says, "Group together like this, and start each group with a heading like this.."

How do they do this.png

 

Regards,

Joshua.

 

 

3 REPLIES 3
Read only

Sandra_Rossi
Active Contributor
0 Kudos
164

If you use CL_GUI_ALV_GRID (?)

  • Sorting: method SET_SORT_CRITERIA
  • Custom subtotal text: either the method GET_SUBTOTALS or the event SUBTOTAL_TEXT.
Read only

0 Kudos
162

Thank you for the reply, Sandra.

Yes I am using CL_GUI_ALV_GRID.

Let me try as you suggested. Earlier, I tried with just SORT table it did not have the desired effect. 

Please note that the screenshot is not actually labelling the subtotals. Instead, it is labelling the start of every new Vendor/Purchase document.

Also, for further reference, any suggestion on how i go about searching for this? I am just unsure what this is called. I searched with heading, grouping, header, row group, aggregation, labelling, group heading.

Read only

60

Thank you @Sandra_Rossi .

This has worked. I also searched and managed to find out this thread where you have explained how to get it working completely in front end. And this helped too. -> https://community.sap.com/t5/application-development-and-automation-discussions/alv-report-subtotal-...

Logging a few of my learnings here, for my own future reference or for others

  1. The feature is called 'Subtotal Text'/'ALV Subtotal Text' 
  2. There MUST be something (a numeric field?) on the ALV we are totaling and something to subtotal/group it under 
    1. In my case, i added a dummy field with 0 value
      1. set NO_ZERO in field catalog to 'X'
      2. set DO_SUM in field catalog to 'X'
    2. I ensured the Subtotal happens at PO Level
      1. I pass in IT_SORT when calling SET_TABLE_FOR_FIRST_DISPLAY
      2. In IT_SORT i have maintained the PO field is added, with SUBTOT = 'X'
      3. In the fieldcatalog for the PO field i ensured NO_OUT = 'X'
  3. I followed BCALV_TEST_GRID_EVENTS to subscribe to the SUBTOTAL_TEXT event
  4. MOST IMPORTANT
    1. I ensured the DUMMY field is at the END, as per field catalog positioning
    2. I originally had this as the first field. And this COMPLETELY PREVENTED the event from triggering (and even the default subtotal text was suppressed). I believe it is because the position of the subtotal value conflicted with the position of the text

EDIT: Not sure how to mark this as answered/Solved. So, if anyone can help, please help.