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 report Subtotal custom text in OO ALV

Former Member
0 Kudos

Hi Friends,

I have done lot of search and tried with different options before posting this question.

I am using OO ALV with method - set_table_for_first_display

My scenario, report will use 2 levels for sorting process(field1 and field2) and 2 fields for Sub totals(field3 and field4). ( I need all the 4 fields in the output including the sorting fields). How to pass the subtotal custom text for these 2 sorting levels ?

I tried method subtotal_text but this requires in sorting no_out = 'X'.

My text will be same for all level1 and Level2 records, so I cant use them in sorting process if I create new Text fields.

Any hints .pls let me know ..

Thank You.

Ravi.

3 REPLIES 3

Sandra_Rossi
Active Contributor
0 Kudos

You have the event SUBTOTAL_TEXT of CL_GUI_ALV_GRID (cf subtotal_text)

0 Kudos

Hi Sandra,

Thanks for the reply. I tried this already. If I use this event what fields should I give in sort process?

As my data should be sorting based on first and second fields as per my logic. I can't use the 3rd field(Text field) for sort.

Please let me know on this.

Thanks.

0 Kudos

It's explained in the official documentation (URL above) how it works. The basics for using this feature is to hide the subtotal column.

You may test with program BCALV_GRID_TEST_EVENTS:

  • Sort by "plane type"
  • Set totals for "occupied" (number of seats)
  • Set subtotals for "plane type"
  • Hide column "plane type" -> the event SUBTOTAL_TEXT is triggered for every subtotal line of plane type, you may define any text you want, which is displayed from the first column (exception column excluded).

In the demo, SAP replace all subtotal lines with the same text "My Subtotals Text", but it should better be "My Subtotals for plane type 146-200" for the first subtotal line whose plane type value is 146-200, etc.

If you want the column not being hidden, you may cheat the program by simply creating an additional column with the same values.