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: 

expand and collapse total lines in ABAP oo ALV

TMNielsen
Contributor
0 Kudos

Hi

In classic alv I remember an option to expand total lines (show detail lines) and collapse total lines (hide detail lines) by clicking an icon that looked like a printer icon:

Now I discovered that this option is not available in OO alv - not out of the box anyway. I have searched for options in the field catalog, the layout structure, the styles option, but so far I only found something that seems to be the opposite of what i want.

The is_layout-no_totexp seems to be a flag to set if I want to prevent that total lines is expandable, but I has no influence if I set this flag or not.

How can I have this functionality in OO ALV?

Best regards

1 ACCEPTED SOLUTION

Former Member
0 Kudos

A predefined sort order can be added to the OO ALV (CL_SALV_TABLE) prior to display by doing the following:

Use the factory method to create the grid and then use method GET_SORTS.

     Ex: lr_sorts = gr_table->get_sorts( ).


From here you can define the columns that you want subtotaled.

    Ex:  lr_sort->add_sort( columnname = 'GSBER'   subtotal = 'X' sequence = '01' ).

Sorry I don't have a small test program at this time but the information above should be enough to get you going.

If you have more questions check out some of SAP's Demo programs like SALV_DEMO_TABLE_EVENTS.

Also (Shift + Right Double Click) in a grey area of a grid will bring up the Consistency Check of ALV Grid which can be very handy. 

Good Luck,

AK

17 REPLIES 17

rosenberg_eitan
Active Contributor
0 Kudos

Hi,

When you add sort and totals.

You get "drill down total level".

regards.

0 Kudos

Hi Eitan

Thanks for your reply.

I think this function is quit useless compared to the old one, so I leave the question open - hoping to get a better solution.

0 Kudos

Hi Thomas,

I might be more helpful if you will tell me in more details what

do you mean by "classic ALV" what was the class or function module

used to achive that.

Regards.

Former Member
0 Kudos

Hello Thomas,

Are you referring to the icon (Collapse Selection) shown below?

0 Kudos

yes please. This looks like a classic alv (fm reuse....).

I need the same in with OO method ...set for first display...

0 Kudos

Hi,

Have you tried passing values to it_sort of set_table_for_first_display?

Regards,

Sonal

0 Kudos

Hi Sonal

Thanks for your reply.

I don't want to program the sort sequence - it should be an option to the users to define their own sort criteria and save them with their own alv layout

- but anyway I have tried to pass values to the IT_SORT table without result. As you can see there are no option to collapse section (see collapse section image in above post from Aron Kitts) :

former_member196593
Participant
0 Kudos

Hi Mr. Thomas   refer this  code.

IF gs_sub_fcat-fieldname = 'PRCTR'.

  REFRESH : gt_sort.

    wa_sort-fieldname = 'PRCTR'.

    wa_sort-up = 'X'.

    wa_sort-subtot = 'X'.

   wa_sort-tabname = 'gt_ordsub1'.

    wa_sort-expa = 'X'.---------------------------------> This is  importand  for  Expand

   APPEND wa_sort TO gt_sort.

  CLEAR : wa_sort.

then pass the gt_sort to FM

Regards
TK.Srithar

0 Kudos

Hi Srithar

The IT_SORT parameter of cl_gui_alv_grid->set_table_for_first_display does not have tabname field, so it seems your code is not for the method I use and I can also see you write "pass the gt_sort> to FM"

But the IT_SORT in my scenario also has a EXPA field and if I set this flag, the output is presented in a collapsed way (totals only), but still no easy way to expand the lines (except for the option already mentioned by Eitan Rosenberg).

.

I suppose I could program my own double-click function - if the user double click the quantity column, I could make the program read current sort table by method get_sort_criteria, toggle the EXPA flag and re-set the sort table by method set_sort_criteria. Hmmmm

Former Member
0 Kudos

A predefined sort order can be added to the OO ALV (CL_SALV_TABLE) prior to display by doing the following:

Use the factory method to create the grid and then use method GET_SORTS.

     Ex: lr_sorts = gr_table->get_sorts( ).


From here you can define the columns that you want subtotaled.

    Ex:  lr_sort->add_sort( columnname = 'GSBER'   subtotal = 'X' sequence = '01' ).

Sorry I don't have a small test program at this time but the information above should be enough to get you going.

If you have more questions check out some of SAP's Demo programs like SALV_DEMO_TABLE_EVENTS.

Also (Shift + Right Double Click) in a grey area of a grid will bring up the Consistency Check of ALV Grid which can be very handy. 

Good Luck,

AK

0 Kudos

Hi Aron

fist of all thanks for the hint about Shift + Right Double Click - lot of interesting info to get there.

I'm using cl_gui_alv_grid and I don't want to change to CL_SALV_TABLE.

Also I don't want to make predefined sort criteria. The users should be able to choose their own sort criteria and their own sub totals.

TMNielsen
Contributor
0 Kudos

Hi All

Thanks for all the replies. I didn't get the perfect solution, but I got a lot of useful ideas.

So thanks again. I will close the thread here.

Best regards

0 Kudos

Hi Thomas ,

Did you get a solution to this ? I am also stuck in the same problem.

0 Kudos

Hi Mr.

   Sourav Chatterjee Aluminum

 

   refer this  code.

IF gs_sub_fcat-fieldname = 'PRCTR'.

  REFRESH : gt_sort.

    wa_sort-fieldname = 'PRCTR'.

    wa_sort-up = 'X'.

    wa_sort-subtot = 'X'.

   wa_sort-tabname = 'gt_ordsub1'.

    wa_sort-expa = 'X'.---------------------------------> This is  importand  for  Expand

   APPEND wa_sort TO gt_sort.

  CLEAR : wa_sort.

then pass the gt_sort to FM

Regards
TK.Srithar

0 Kudos

Hi Sridhar,

Thanks for the info. In the code snippet , the entire output is getting merged row-wise . My requirement was to make a collapsible subtotals with a button as in the screen-shot by Aaron Kitts. The user wants to see this report as a Summary of respective columns.I want the exact same scenario as shown in the screen shot. If you have any valuable info on how to do it please let me know.

0 Kudos

may be your grid is editable?

0 Kudos

This message was moderated.