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 ALV grid display

mahabaleshwar_patil
Participant
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.

But I developed the Z report but it’s not appearing

I have used the variant sort functionality.

I used the sum on ZWREBTR field

   wa_fcat-do_sum = 'X'.
MODIFY it_fcat FROM wa_fcat  TRANSPORTING do_sum
WHERE  fieldname  = 'ZWRBTR' AND
fieldname 
= 'WRBTR' .

  wa_sort-spos      = '1'.
wa_sort
-fieldname = 'ZAUGBL_GL'.
wa_sort
-tabname   = 'IT_Z070_CUR'.
wa_sort
-group     = 'UL'.
wa_sort
-up        = 'X'.
*  wa_sort-spos      = 'X'.
wa_sort
-subtot    = 'X'.

  APPEND wa_sort TO it_sort.
CLEAR:wa_sort.

Afeter that I am sung the grid display

t_slis_layout_alv-colwidth_optimize = 'X'.
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
i_callback_program      
= sy-repid
i_callback_pf_status_set
= 'SET_PF_STATUS'
i_callback_user_command 
= 'MODIFY_ALV'
is_layout               
= t_slis_layout_alv
it_fieldcat             
= it_fcat
it_sort                 
= it_sort
i_save                  
= 'A'
is_variant              
= rs_variant
TABLES
t_outtab                
= it_z070_cur
EXCEPTIONS
program_error           
= 1
OTHERS                   = 2.
IF sy-subrc <> 0.
MESSAGE text-032 TYPE 'E'.   "'Display Error'
ENDIF.

If I use the *  wa_sort-expa = 'X'. it will hide all line items and also t was not showing expand and collapse option

8 REPLIES 8

guilherme_frisoni
Contributor
0 Kudos

Hi,

there are only two parameters needed to achieve this:

do_sum = 'X' in fieldcat

and

subtot = 'X' in sort.

I just tried this options using BCALV_TEST_GRID test report and it works fine:

Check this report to compare to yours.

Regards,

Frisoni

0 Kudos

Hi i have did the same but still its Not working.

0 Kudos

In standard program BCALV_TEST_GRID, does it shows the expand icon?

0 Kudos

Hello,
it works fine and collapse option works fine. it does not work if there are some Editable fields in ALV how to make it Work.

Hi,

I was running some tests and debugs, and if your ALV have some edit field set on, your ALV have some other behaviors, and remove expand icons is one among then.

So, it is not possible to show this icon.

But, as Nikolay said above, you still can use menu Settings -> Define Totals Drilldown to expand and collaps lines.

Regards,

Frisoni

nikolayevstigneev
Contributor
0 Kudos

Hi! Just to suggest another point of view - you can create necessary layout manually and save it as a default one. It takes 1 minute of time and requires no coding.

0 Kudos

Hello,

it works fine and collapse option works fine. it does not work if there are some Editable fields in ALV how to make it Work.

0 Kudos

A-ah, once I had a problem like that - user complained that he couldn't expand subtotals in an editable ALV. But I didn't have enough time for investigations and just advised him to go to menu Settings -> Define Totals Drilldown and choose the level of expanding subtotals