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: 

Sub total in ALV

Former Member
0 Kudos
108

Hi all

i am developing a ALV FI Report(GRID DISPLAY),In this i am havin EKPO-NETWR

BSEG-DMBTR

RSEG-WRBTR

VBRP-NETWR

VBEP-BMENG.

In output i have to give total of above mentioned fields individually.

Can anyone let me know how to do this??

Thanks and Regards,

Arun Joseph

1 ACCEPTED SOLUTION

Former Member
0 Kudos
56

data: p_it_sortcat TYPE slis_t_sortinfo_alv.

CLEAR wa_sortcat.

wa_sortcat-fieldname = 'VBELN'.

wa_sortcat-up ='X'.

wa_sortcat-subtot = 'X'.

APPEND wa_sortcat TO p_it_sortcat.

populate the sort list and pass it to functionmodule to display the list.

'REUSE_ALV_GRID_DISPLAY'.

AWARD POINTS IF FIND USEFUL

4 REPLIES 4

Former Member
0 Kudos
57

data: p_it_sortcat TYPE slis_t_sortinfo_alv.

CLEAR wa_sortcat.

wa_sortcat-fieldname = 'VBELN'.

wa_sortcat-up ='X'.

wa_sortcat-subtot = 'X'.

APPEND wa_sortcat TO p_it_sortcat.

populate the sort list and pass it to functionmodule to display the list.

'REUSE_ALV_GRID_DISPLAY'.

AWARD POINTS IF FIND USEFUL

0 Kudos
56

Hi Usha

Could you please be more specific??

Thanks and Regards,

Arun Joseph

Former Member
0 Kudos
56

Hi try this code,

types :

begin of ty_vbak,

vkorg type vbak-vkorg, " Sales organization

kunnr type vbak-kunnr, " Sold-to party

vbeln type vbak-vbeln, " Sales document

netwr type vbak-netwr, " Net Value of the Sales Order

waerk type vbak-waerk, " Document currency

end of ty_vbak.

data:

vbak type vbak,

gt_vbak type table of ty_vbak.

select-options :

s_vkorg for vbak-vkorg, " Sales organization

s_kunnr for vbak-kunnr, " Sold-to party

s_vbeln for vbak-vbeln. " Sales document

selection-screen :

skip, begin of line,comment 5(27) v_1 for field p_max.

parameters p_max(2) type n default '20' obligatory.

selection-screen end of line.

initialization.

v_1 = 'Maximum of records to read'.

start-of-selection.

perform f_read_data.

perform f_display_data.

form f_read_data.

select vkorg kunnr vbeln netwr waerk

up to p_max rows

into table gt_vbak

from vbak

where kunnr in s_kunnr

and vbeln in s_vbeln

and vkorg in s_vkorg.

endform. " F_READ_DATA

form f_display_data.

type-pools: slis. " ALV Global types

define m_fieldcat.

add 1 to ls_fieldcat-col_pos.

ls_fieldcat-fieldname = &1.

ls_fieldcat-ref_tabname = 'VBAK'.

ls_fieldcat-do_sum = &2.

ls_fieldcat-cfieldname = &3.

append ls_fieldcat to lt_fieldcat.

end-of-definition.

define m_sort.

add 1 to ls_sort-spos.

ls_sort-fieldname = &1.

ls_sort-up = 'X'.

ls_sort-subtot = &2.

append ls_sort to lt_sort.

end-of-definition.

data:

ls_fieldcat type slis_fieldcat_alv,

lt_fieldcat type slis_t_fieldcat_alv,

lt_sort type slis_t_sortinfo_alv,

ls_sort type slis_sortinfo_alv,

ls_layout type slis_layout_alv.

m_fieldcat 'VKORG' '' ''.

m_fieldcat 'KUNNR' '' ''.

m_fieldcat 'VBELN' '' ''.

m_fieldcat 'NETWR' 'X' 'WAERK'(001).

m_fieldcat 'WAERK' '' ''.

m_sort 'VKORG' 'X'. " Sort by vkorg and subtotal

m_sort 'KUNNR' 'X'. " Sort by kunnr and subtotal

m_sort 'VBELN' ''. " Sort by vbeln

ls_layout-cell_merge = 'X'.

call function 'REUSE_ALV_GRID_DISPLAY'

exporting

is_layout = ls_layout

it_fieldcat = lt_fieldcat

it_sort = lt_sort

tables

t_outtab = gt_vbak.

endform. " F_DISPLAY_DATA[/code]

Regards,

kavitha

Former Member
0 Kudos
56

hi,

try this example.

tables: vbak,

vbap.

types: begin of ty_vbak,

vbeln type vbeln_va,

erdat type erdat,

ernam type ernam ,

end of ty_vbak.

types: begin of ty_vbap,

vbeln type vbeln_va,

posnr type posnr_va,

matnr(2) type c, "MATNR,

matkl type matkl,

netwr type netwr_ap,

slno type i,

end of ty_vbap.

data: t_vbak type table of ty_vbak,

t_vbap type table of ty_vbap,

w_vbak type ty_vbak,

w_vbap type ty_vbap.

data: t_fieldcat type slis_t_fieldcat_alv,

w_fieldcat type slis_fieldcat_alv,

i_sort type slis_t_sortinfo_alv ,

w_sort type slis_sortinfo_alv.

selection-screen: begin of block b1 with frame title text-001.

select-options: s_vbeln for vbak-vbeln.

selection-screen: end of block b1.

perform populate_data.

perform fieldcat.

perform sort.

perform display.

form populate_data .

select vbeln

from vbak into table t_vbak

where vbeln in s_vbeln.

if sy-subrc = 0.

select vbeln

posnr

matnr

matkl

netwr

from vbap into table t_vbap for all entries in t_vbak

where vbeln = t_vbak-vbeln.

endif.

endform.

form fieldcat .

w_fieldcat-col_pos = 1.

w_fieldcat-fieldname = 'VBELN'.

w_fieldcat-tabname = 'T_VBAP'.

w_fieldcat-seltext_m = 'SALES DOCU'.

w_fieldcat-outputlen = 20.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-col_pos = 2.

w_fieldcat-fieldname = 'POSNR'.

w_fieldcat-tabname = 'T_VBAP'.

w_fieldcat-seltext_m = 'I'.

w_fieldcat-outputlen = 20.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-col_pos = 3.

w_fieldcat-fieldname = 'MATNR'.

w_fieldcat-tabname = 'T_VBAP'.

w_fieldcat-outputlen = 20.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-col_pos = 4.

w_fieldcat-fieldname = 'MATKL'.

w_fieldcat-tabname = 'T_VBAP'.

w_fieldcat-seltext_m = 'MATERIAL DESC'.

w_fieldcat-outputlen = 20.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

w_fieldcat-col_pos = 5.

w_fieldcat-fieldname = 'NETWR'.

w_fieldcat-tabname = 'T_VBAP'.

w_fieldcat-do_sum = 'X'.

w_fieldcat-outputlen = 20.

append w_fieldcat to t_fieldcat.

clear w_fieldcat.

FORM display .

CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

EXPORTING

  • I_INTERFACE_CHECK = ' '

  • I_BYPASSING_BUFFER = ' '

  • I_BUFFER_ACTIVE = ' '

I_CALLBACK_PROGRAM = sy-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 =

IT_FIELDCAT = t_fieldcat

  • IT_EXCLUDING =

  • IT_SPECIAL_GROUPS =

IT_SORT = i_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

  • I_HTML_HEIGHT_TOP = 0

  • I_HTML_HEIGHT_END = 0

  • IT_ALV_GRAPHICS =

  • IT_HYPERLINK =

  • IT_ADD_FIELDCAT =

  • IT_EXCEPT_QINFO =

  • IR_SALV_FULLSCREEN_ADAPTER =

  • IMPORTING

  • E_EXIT_CAUSED_BY_CALLER =

  • ES_EXIT_CAUSED_BY_USER =

TABLES

T_OUTTAB = t_vbap

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

ENDFORM.

FORM sort .

w_sort-fieldname = 'VBELN'.

w_sort-up = 'X'.

append w_sort to i_sort.

clear w_sort.

w_sort-fieldname = 'NETWR'.

w_sort-subtot = 'X'.

w_sort-comp = 'X'.

append w_sort to i_sort.

clear w_sort.

ENDFORM.

reward if useful,

thanks and regards