Skip to Content
avatar image
Former Member

ALV report Subtotal custom text in OO ALV

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.

alv-text.png (5.5 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Aug 11, 2017 at 06:56 AM

    You have the event SUBTOTAL_TEXT of CL_GUI_ALV_GRID (cf subtotal_text)

    Add comment
    10|10000 characters needed characters exceeded

    • 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.

      8tgyg.png (65.8 kB)