Application Development and Automation 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: 
Read only

ALV Grid + Total

Former Member
0 Likes
582

Hi all!

May be anybody know, how to create ALV Grid like this

dog 10

cat 20

monkey 30

TOTAL 60

I.e. I want to add text 'TOTALS' at last line (with sum).

If I use function reuse_alv_LIST_display - all work and the text "TOTAL" displays.

If we use reuse_alv_GRID_display it doesn't work.

> this is out text string 'totals'

>gd_layout type slis_layout_alv,

>gd_layout-totals_text = 'Totals'(201).

Thanks.

Hi all!

May be anybody know, how to create ALV Grid like this

dog 10

cat 20

monkey 30

TOTAL 60

I.e. I want to add text 'TOTALS' at last line (with sum).

If I use function reuse_alv_LIST_display - all work and the text "TOTAL" displays.

If we use reuse_alv_GRID_display it doesn't work.

> this is out text string 'totals'

>gd_layout type slis_layout_alv,

>gd_layout-totals_text = 'Totals'(201).

Thanks.

4 REPLIES 4
Read only

Former Member
0 Likes
545

Hi

try this

gd_layout-DO_SUM = 'X'.

Best regards,

Thangesh

Read only

Former Member
0 Likes
545

Hi Leonid,

check the code:

tables: vbak.

type-pools : slis.

data: begin of it_vbak occurs 0,

icon type icon-id,

vbeln like vbak-vbeln,

audat like vbak-audat,

vbtyp like vbak-vbtyp,

auart like vbak-auart,

augru like vbak-augru,

netwr like vbak-netwr,

waerk like vbak-waerk,

end of it_vbak.

data: g_repid like sy-repid,

wa_sort type slis_sortinfo_alv,

it_sort type slis_t_sortinfo_alv,

wa_layout type slis_layout_alv,

it_fieldtab type slis_t_fieldcat_alv,

wa_fieldcat type slis_fieldcat_alv.

selection-screen begin of block b1 with frame.

select-options:s_vbeln for vbak-vbeln,

s_vbtyp for vbak-vbtyp default 'C'.

selection-screen end of block b1 .

selection-screen begin of block b2 with frame.

parameters: list radiobutton group rad1,

grid radiobutton group rad1.

selection-screen end of block b2.

initialization.

g_repid = sy-repid.

start-of-selection.

select vbeln

audat

vbtyp

auart

augru

netwr

waerk into corresponding fields of table it_vbak

from vbak where audat > '01/01/2004' and

netwr > 0 and

vbeln in s_vbeln and

vbtyp in s_vbtyp.

loop at it_vbak.

if it_vbak-netwr < 10000.

it_vbak-icon = '@08@'.

elseif it_vbak-netwr > 10000 and it_vbak-netwr < 100000.

it_vbak-icon = '@09@'.

elseif it_vbak-netwr > 100000.

it_vbak-icon = '@0A@'.

endif.

modify it_vbak index sy-tabix.

endloop.

end-of-selection.

perform sort_list.

perform modify_fieldcat.

perform layout_list.

&----


*& Form sort_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form sort_list .

clear wa_sort.

wa_sort-fieldname = 'AUART'.

wa_sort-spos = '1'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

clear wa_sort.

wa_sort-fieldname = 'VBTYP'.

wa_sort-spos = '2'.

wa_sort-up = 'X'.

append wa_sort to it_sort.

clear wa_sort.

wa_sort-fieldname = 'WAERK'.

wa_sort-spos = '3'.

wa_sort-up = 'X'.

wa_sort-subtot = 'X'.

append wa_sort to it_sort.

endform. " sort_list

&----


*& Form layout_list

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form layout_list .

clear wa_layout.

if list = 'X'.

wa_layout-zebra = 'X'.

wa_layout-window_titlebar = 'LIST DISPLAY'.

wa_layout-subtotals_text = 'SUBTOTAL'.

wa_layout-totals_text = 'TOTAL'.

call function 'REUSE_ALV_LIST_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER =

  • I_BUFFER_ACTIVE = ' '

i_callback_program = g_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_STRUCTURE_NAME =

is_layout = wa_layout

it_fieldcat = it_fieldtab[]

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = it_sort[]

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_vbak

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

elseif grid = 'X'.

wa_layout-zebra = 'X'.

wa_layout-window_titlebar = 'GRID DISPLAY'.

wa_layout-subtotals_text = 'SUBTOTAL'.

wa_layout-totals_text = 'TOTAL'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

i_callback_program = g_repid

  • I_CALLBACK_PF_STATUS_SET = ' '

  • I_CALLBACK_USER_COMMAND = ' '

  • I_CALLBACK_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_TOP_OF_PAGE = ' '

  • I_CALLBACK_HTML_END_OF_LIST = ' '

  • I_STRUCTURE_NAME =

  • I_BACKGROUND_ID = ' '

  • I_GRID_TITLE =

  • I_GRID_SETTINGS =

is_layout = wa_layout

it_fieldcat = it_fieldtab

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

it_sort = it_sort

  • IT_FILTER =

  • IS_SEL_HIDE =

  • I_DEFAULT = 'X'

  • I_SAVE = ' '

  • IS_VARIANT =

  • IT_EVENTS =

  • IT_EVENT_EXIT =

  • IS_PRINT =

  • IS_REPREP_ID =

  • I_SCREEN_START_COLUMN = 0

  • I_SCREEN_START_LINE = 0

  • I_SCREEN_END_COLUMN = 0

  • I_SCREEN_END_LINE = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • I_HTML_HEIGHT_TOP =

  • I_HTML_HEIGHT_END =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

tables

t_outtab = it_vbak

  • EXCEPTIONS

  • PROGRAM_ERROR = 1

  • OTHERS = 2

.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

endif.

endform. " layout_list

&----


*& Form modify_fieldcat

&----


  • text

----


  • --> p1 text

  • <-- p2 text

----


form modify_fieldcat .

clear wa_fieldcat.

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'ICON'.

wa_fieldcat-seltext_l = 'LIGHTS'.

wa_fieldcat-icon = 'X'.

  • WA_FIELDCAT-ddictxt = 'l'.

wa_fieldcat-col_pos = 1.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'VBELN'.

wa_fieldcat-seltext_l = 'SALES DOCUMENT'.

  • WA_FIELDCAT-ddictxt = 'l'.

wa_fieldcat-col_pos = 2.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

  • when 'maktx'.

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'AUDAT'.

wa_fieldcat-seltext_l = 'DATE'.

  • WA_FIELDCAT-ddictxt = 'l'.

wa_fieldcat-col_pos = 3.

wa_fieldcat-outputlen = 15.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'VBTYP'.

wa_fieldcat-seltext_l = 'SALES CATEGORY'.

wa_fieldcat-col_pos = 4.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'AUART'.

wa_fieldcat-seltext_l = 'SALES DOCUMENT TYPE'.

wa_fieldcat-col_pos = 5.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'AUGRU'.

wa_fieldcat-seltext_l = 'ORDER REASON'.

  • WA_FIELDCAT-ddictxt = 'l'.

wa_fieldcat-col_pos = 6.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'NETWR'.

wa_fieldcat-seltext_l = 'QUANTITY'.

wa_fieldcat-do_sum = 'X'.

  • WA_FIELDCAT-ddictxt = 'l'.

wa_fieldcat-col_pos = 7.

wa_fieldcat-outputlen = 25.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

wa_fieldcat-tabname = 'IT_VBAK'.

wa_fieldcat-fieldname = 'WAERK'.

wa_fieldcat-seltext_l = 'CURRENCY'.

  • WA_FIELDCAT-ddictxt = 'l'.

wa_fieldcat-col_pos = 8.

wa_fieldcat-outputlen = 10.

append wa_fieldcat to it_fieldtab.

clear wa_fieldcat .

endform. " modify_fieldcat

regards,

keerthi.

Read only

Former Member
0 Likes
545

It doesn't work.

In case reuse_alv_LIST_display all works

BUT

in case reuse_alv_GRID_display it doesn't work.

I want to add string 'totals' exactly in ALV Grid.

Read only

Former Member
0 Likes
545

Hello,

If you use the method set_table_for_first_display from class CL_GUI_ALV_GRID, and specify the parameter is_variant. Once your grid is displayed click on the subtotal/sum button to display your totals - Just as you would in excel using formulas.

Regards

Christine.