2013 Mar 27 1:06 PM
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
2013 Mar 28 8:59 PM
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
2013 Mar 27 1:49 PM
Hi,
When you add sort and totals.
You get "drill down total level".
regards.
2013 Mar 27 2:00 PM
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.
2013 Mar 27 3:33 PM
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.
2013 Mar 27 4:26 PM
Hello Thomas,
Are you referring to the icon (Collapse Selection) shown below?
2013 Mar 28 8:37 AM
yes please. This looks like a classic alv (fm reuse....).
I need the same in with OO method ...set for first display...
2013 Mar 28 9:01 AM
Hi,
Have you tried passing values to it_sort of set_table_for_first_display?
Regards,
Sonal
2013 Apr 04 1:10 PM
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) :
2013 Mar 28 12:38 PM
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
2013 Apr 04 1:35 PM
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
2013 Mar 28 8:59 PM
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
2013 Apr 04 1:40 PM
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.
2013 Apr 04 1:41 PM
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
2013 Dec 19 9:26 AM
Hi Thomas ,
Did you get a solution to this ? I am also stuck in the same problem.
2013 Dec 20 5:34 AM
Hi Mr.
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
2013 Dec 20 8:59 AM
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.
2014 Aug 29 4:15 PM
2014 Sep 16 11:38 AM