2010 Oct 11 4:24 PM
Hi All,
I have requirement in drill down report ,my requirement is
Text Qty1 Qty2 Total%
A 20 10 50%
A 102 21 21%
A 88 11 13%
A 21 10 49%
B 102 21 21%
B 88 11 13%
C 20 10 50%
D 102 21 21%
D 88 11 13%
If i do subtotal on Text it is giving Qty1 Qty2 of subtotals. My Question is i want subtotal % on Total% field
Please help me .
Thanks in Adv.
Kumar
2010 Oct 14 2:37 PM
A solution for classical oo alv
- add a numerical field for %, fill this for individual records
- put a handle for appl->handle_after_refresh
- in the associated method update the sub-total internal tables
Declaration at top of report should look like
* local class def
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
* ...
handle_after_refresh
FOR EVENT after_refresh
OF cl_gui_alv_grid
IMPORTING sender.
ENDCLASS.
* local class implementation
CLASS lcl_application IMPLEMENTATION.
* ...
METHOD handle_after_refresh.
PERFORM grid_after_refresh USING sender.
ENDMETHOD.
ENDCLASS.The calculation form should look like
FORM grid_after_refresh USING sender.
DATA: ref_total00 TYPE REF TO data,
ref_total01 TYPE REF TO data,
* ...
ref_total09 TYPE REF TO data,
lt_levels TYPE lvc_t_grpl.
FIELD-SYMBOLS <total> LIKE gt_alv.
CHECK sender = grid.
CALL METHOD grid->get_variant
IMPORTING
es_variant = gs_variant.
variant = gs_variant-variant.
CALL METHOD grid->get_filtered_entries
IMPORTING
et_filtered_entries = gt_filtered.
IF g_no_iter IS INITIAL. " global field -> only process once
CALL METHOD grid->get_subtotals
IMPORTING
ep_collect00 = ref_total00
* ...
ep_collect09 = ref_total09
et_grouplevels = lt_levels.
DO 10 TIMES.
CASE sy-index.
WHEN 01.
ASSIGN ref_total00->* TO <total>.
* ...
WHEN 10.
ASSIGN ref_total09->* TO <total>.
ENDCASE.
LOOP AT <total> ASSIGNING <fs>.Here perform calculations
ENDLOOP.
ENDDO.
g_no_iter = 'X'.
CALL METHOD grid->refresh_table_display
EXPORTING
i_soft_refresh = 'X'.
CLEAR g_no_iter.
ENDIF.
ENDFORM. " grid_after_refreshCreation of ALV
CREATE OBJECT grid
EXPORTING
i_parent = c_grid
i_lifetime = cntl_lifetime_dynpro.
* set handler
SET HANDLER appl->handle_after_refresh FOR grid.
* first display
CALL METHOD grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
it_toolbar_excluding = gt_toolbar_excluding
i_save = 'A'
i_default = 'X'
CHANGING
it_outtab = gt_alv
it_fieldcatalog = gt_fld.NB: every field used to compute new fields must be totalized.
Regards,
Raymond
Hi All,
I have requirement in drill down report ,my requirement is
Text Qty1 Qty2 Total%
A 20 10 50%
A 102 21 21%
A 88 11 13%
A 21 10 49%
B 102 21 21%
B 88 11 13%
C 20 10 50%
D 102 21 21%
D 88 11 13%
If i do subtotal on Text it is giving Qty1 Qty2 of subtotals. My Question is i want subtotal % on Total% field
Please help me .
Thanks in Adv.
Kumar
2010 Oct 11 4:32 PM
Hi,
I think if you create % field as int field it will work. use symbol '%' after the field value.
Thanks,
Anmol.
2010 Oct 12 9:24 AM
Hi Anmol,
i don't want subtotal on Total% field i want subtotals percentage
Text Qty1 Qty2 Total%
A 20 10 50%
A 102 21 21%
A 88 11 13%
A 21 10 49%
252 52 20 %( I need %of these 2 subtotals.)
B 102 21 21%
B 88 11 13%
C 20 10 50%
D 102 21 21%
D 88 11 13%
Please help me i need subtotals %, i am using standard method and i try to pass do_sum to field catlalog but still i am not getting..
Thanks
Kumar
2010 Oct 12 9:42 PM
Hi Kumar,
I think you wont get the percentage value using SUM or COLLECT statements,
you may be need to store the subtotal values in some variables and do manipulation.
May be you are using AT END-OF event so, in that event you have to manipulate the percentage value.
Thanks,
Anmol.
2010 Oct 12 10:31 PM
If the report is AVL you have to sort the table, if not you can tray with at end of or manually get the sum of % to write the subtotal when the field text change and clear the variable
2010 Oct 14 1:39 AM
Hi All,
I am not sure how I will get it, because it is a drill down report and when I press totals other 2 fields are giving total of the fields. But in percentage I don't want totals, I want to calculate (when I click subtotals or drill down I con clicking time) field1 / field2 = percentage
Can anybody help me on this.
Thanks,
KKP
2010 Oct 14 1:58 PM
You still haven't said whether this is a classical or an ALV report. If you expect help, you'll have to help us help you.
Rob
2010 Oct 14 2:02 PM
Hi,
But in percentage I don't want totals,
If you dont want total for percentage field automatically then define this field as char field.
And do the total manually
Thanks,
Anmol.
Edited by: anmol112 on Oct 14, 2010 3:03 PM
2010 Oct 11 9:25 PM
Why are you adding % at end of the field Total% ? without that it will be very easy to do the subtotal for Total% field .
2010 Oct 12 10:03 PM
2010 Oct 14 2:37 PM
A solution for classical oo alv
- add a numerical field for %, fill this for individual records
- put a handle for appl->handle_after_refresh
- in the associated method update the sub-total internal tables
Declaration at top of report should look like
* local class def
CLASS lcl_application DEFINITION.
PUBLIC SECTION.
METHODS:
* ...
handle_after_refresh
FOR EVENT after_refresh
OF cl_gui_alv_grid
IMPORTING sender.
ENDCLASS.
* local class implementation
CLASS lcl_application IMPLEMENTATION.
* ...
METHOD handle_after_refresh.
PERFORM grid_after_refresh USING sender.
ENDMETHOD.
ENDCLASS.The calculation form should look like
FORM grid_after_refresh USING sender.
DATA: ref_total00 TYPE REF TO data,
ref_total01 TYPE REF TO data,
* ...
ref_total09 TYPE REF TO data,
lt_levels TYPE lvc_t_grpl.
FIELD-SYMBOLS <total> LIKE gt_alv.
CHECK sender = grid.
CALL METHOD grid->get_variant
IMPORTING
es_variant = gs_variant.
variant = gs_variant-variant.
CALL METHOD grid->get_filtered_entries
IMPORTING
et_filtered_entries = gt_filtered.
IF g_no_iter IS INITIAL. " global field -> only process once
CALL METHOD grid->get_subtotals
IMPORTING
ep_collect00 = ref_total00
* ...
ep_collect09 = ref_total09
et_grouplevels = lt_levels.
DO 10 TIMES.
CASE sy-index.
WHEN 01.
ASSIGN ref_total00->* TO <total>.
* ...
WHEN 10.
ASSIGN ref_total09->* TO <total>.
ENDCASE.
LOOP AT <total> ASSIGNING <fs>.Here perform calculations
ENDLOOP.
ENDDO.
g_no_iter = 'X'.
CALL METHOD grid->refresh_table_display
EXPORTING
i_soft_refresh = 'X'.
CLEAR g_no_iter.
ENDIF.
ENDFORM. " grid_after_refreshCreation of ALV
CREATE OBJECT grid
EXPORTING
i_parent = c_grid
i_lifetime = cntl_lifetime_dynpro.
* set handler
SET HANDLER appl->handle_after_refresh FOR grid.
* first display
CALL METHOD grid->set_table_for_first_display
EXPORTING
is_layout = gs_layout
is_variant = gs_variant
it_toolbar_excluding = gt_toolbar_excluding
i_save = 'A'
i_default = 'X'
CHANGING
it_outtab = gt_alv
it_fieldcatalog = gt_fld.NB: every field used to compute new fields must be totalized.
Regards,
Raymond
2010 Oct 15 4:33 AM
Hi Raymond Giuseppi ,
Excellent explanation, thanks.
Thanks all to your valuable support.
Thread closed.