PURPOSE -:
To get customer item selected subtotal.
DESCRIPTION -:
On clicking subtotal button in the toolbar, user should get subtotal of customer items which are selected. Then subtotal of not selected items and in the end all items total.
CODE -:
1. This checkbox is provided using the slis_layout_alv.
FORM f_build_layout CHANGING fp_wa_layout TYPE slis_layout_alv.
CONSTANTS: l_c_total TYPE char5 VALUE 'TOTAL'.
fp_wa_layout-colwidth_optimize = c_x .
fp_wa_layout-box_fieldname = c_box.
fp_wa_layout-zebra = c_x. " striped pattern
fp_wa_layout-totals_text = l_c_total.
ENDFORM. " f_build_layout
2. Now since this ‘BOX’ field is available hence, using the sort table, we can get the selected item total.
FORM f_sort_tab CHANGING fp_it_sort TYPE slis_t_sortinfo_alv.
* Local work area For Sort info.
DATA: l_wa_sort TYPE slis_sortinfo_alv.
CONSTANTS: l_c_1 TYPE char1 VALUE '1',
l_c_kunnr TYPE char5 VALUE 'KUNNR'.
CONSTANTS: l_c_box TYPE char3 VALUE 'BOX',
l_c_2 TYPE char1 VALUE '2'.
l_wa_sort-fieldname = l_c_kunnr.
l_wa_sort-spos = l_c_1.
l_wa_sort-up = c_x.
l_wa_sort-subtot = c_x.
l_wa_sort-comp = c_x.
APPEND l_wa_sort TO fp_it_sort.
CLEAR l_wa_sort.
l_wa_sort-fieldname = l_c_box.
l_wa_sort-spos = l_c_2.
l_wa_sort-down = c_x.
l_wa_sort-subtot = c_x.
l_wa_sort-comp = c_x.
APPEND l_wa_sort TO fp_it_sort.
CLEAR l_wa_sort.
ENDFORM. " f_sort_tab
Please note that subtotal will not work unless we check the ‘COMP’ field of sort table (l_wa_sort-comp = ‘X’.).
3. In user command, refresh the output.
WHEN l_c_subt. “Subtotal button FCODE.
rs_selfield-refresh = c_x.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment