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: 

Multiple subtotals UOM wise

Former Member
0 Kudos

Presently creating a reports for display of Billing details. The reports display the output in ALV grid.

User wants to see the sub total UOM wise. At present the subtotal is appearing after evry UOM while the user wants the display of all the quantities and UOM collectively at the bottom or top like standard transaction VF05.

How to display that. Kindly help.

thanks

anya

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi richard,

i have defined like this

clear l_fieldcat.

l_fieldcat-fieldname = 'FKIMG'.

l_fieldcat-outputlen = 13.

l_fieldcat-datatype = 'QUAN'.

l_fieldcat-do_sum = 'X'.

l_fieldcat-seltext_l = 'Total Qty'.

append l_fieldcat to p_fieldtab.

clear l_fieldcat.

l_fieldcat-fieldname = 'MEINS'.

l_fieldcat-datatype = 'UNIT'.

l_fieldcat-do_sum = 'X'.

l_fieldcat-seltext_l = 'UOM'.

append l_fieldcat to p_fieldtab.

and no sorting criteria. But still only subtotal of quantity is appearing. Kindly reply

7 REPLIES 7

Former Member
0 Kudos

hi,

use this code for example.

ls_sort-fieldname = 'BUKRS'.

ls_sort-spos = '1'.

ls_sort-up = 'X'.

ls_sort-subtot = 'X'.

APPEND ls_sort TO lt_sort.

and pass this lt_sort to reuse_alv_grid_display.

regards,

Santosh

Former Member
0 Kudos

hi,

Try like this.

DATA: gt_subtot TYPE slis_t_sortinfo_alv,

subtot LIKE LINE OF gt_subtot.

subtot-spos = 1.

subtot-fieldname = 'NAME1'.

subtot-tabname = 'ITAB_HEAD'.

subtot-up = 'X'.

subtot-group = 'X'.

subtot-subtot = 'X'.

subtot-expa = 'X'.

APPEND subtot TO gt_subtot.

subtot-spos = 2.

subtot-fieldname = 'WGBEZ'.

subtot-tabname = 'ITAB_HEAD'.

subtot-up = 'X'.

subtot-group = 'X'.

subtot-subtot = 'X'.

subtot-expa = 'X'.

APPEND subtot TO gt_subtot.

CALL FUNCTION 'REUSE_ALV_HIERSEQ_LIST_DISPLAY'

EXPORTING

i_callback_program = 'ZRAW_COST'

it_fieldcat = fcat

<b> it_sort = gt_subtot</b>

it_events = eve

i_tabname_header = 'ITAB_HEAD'

i_tabname_item = 'ITAB_ITM'

is_keyinfo = alv_keyinfo

TABLES

t_outtab_header = itab_head

t_outtab_item = itab_itm

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. "dis_data

U can use REUSE_ALV_GRID_DISPLAY instead of REUSE_ALV_HIERSEQ_LIST_DISPLAY

reward if useful.

raymond_giuseppi
Active Contributor
0 Kudos

What you want is the standard behavior of ALV modules, if your data are defined as quantities (type QUAN) or currency amounts (CURR) and the associated field unit of measure (UNIT) or currency key (CUKY) must be assigned and filled.

Don't put a sub-total and a sort criteria on unit, only sulmm the column, each UOM will be summed separately, and displayed collectively at the total and sub-total levels.

Regards

Former Member
0 Kudos

Hi richard,

i have defined like this

clear l_fieldcat.

l_fieldcat-fieldname = 'FKIMG'.

l_fieldcat-outputlen = 13.

l_fieldcat-datatype = 'QUAN'.

l_fieldcat-do_sum = 'X'.

l_fieldcat-seltext_l = 'Total Qty'.

append l_fieldcat to p_fieldtab.

clear l_fieldcat.

l_fieldcat-fieldname = 'MEINS'.

l_fieldcat-datatype = 'UNIT'.

l_fieldcat-do_sum = 'X'.

l_fieldcat-seltext_l = 'UOM'.

append l_fieldcat to p_fieldtab.

and no sorting criteria. But still only subtotal of quantity is appearing. Kindly reply

0 Kudos

hi,

but how can u make total of unit field?

0 Kudos

Just add the unit/cucy fieldname to this sample

Unit of Measure for quantity fields QUAN

l_fieldcat-qfieldname  = 'fieldname of unit of measure'.

or

Currency Key for currency amount fields CURR

l_fieldcat-cfieldname = 'fieldname of currency key' 

in anya code :

clear l_fieldcat.
l_fieldcat-fieldname = 'FKIMG'.
l_fieldcat-qfieldname  = 'MEINS'.
l_fieldcat-outputlen = 13.
l_fieldcat-datatype = 'QUAN'.
l_fieldcat-do_sum = 'X'.
l_fieldcat-seltext_l = 'Total Qty'.
append l_fieldcat to p_fieldtab.

So at each total level you will get as many total lines than there are unit or currency.

Regards

Former Member
0 Kudos

Thanks a lot raymond,

Your reply was simple, concise.

have rewarded points to u.

thanks once again.

anya