2008 Feb 29 1:49 PM
Hi all,
I have an internal table i_out, defined as:
DATA:
BEGIN OF i_out OCCURS 0,
pernr LIKE catsdb-pernr,
catshours LIKE catsdb-catshours,
END OF i_out.I display this internal table in an ALV grid. After I run the report, I try do add subtotal to the field catshours (sorted on pernr ), but then I get the following message:
Subtotals cannot be calculated over totalizable fields.
Does anyone know why this happens?
All helpful answers will be rewarded!
Regards,
MV
2008 Feb 29 2:16 PM
hi check this ex program,
&----
*& Report ZALVTESTFORSUBTOTAL
*&
&----
*&
*&
&----
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
&----
*& Form getD_data
&----
text
----
--> p1 text
<-- p2 text
----
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
&----
*& Form disp_alv
&----
text
----
--> p1 text
<-- p2 text
----
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv
<REMOVED BY MODERATOR>
venkat.
Edited by: Alvaro Tejada Galindo on Feb 29, 2008 4:13 PM
Hi all,
I have an internal table i_out, defined as:
DATA:
BEGIN OF i_out OCCURS 0,
pernr LIKE catsdb-pernr,
catshours LIKE catsdb-catshours,
END OF i_out.I display this internal table in an ALV grid. After I run the report, I try do add subtotal to the field catshours (sorted on pernr ), but then I get the following message:
Subtotals cannot be calculated over totalizable fields.
Does anyone know why this happens?
All helpful answers will be rewarded!
Regards,
MV
2008 Feb 29 1:58 PM
Hi,
Could be because the format of the field that you are tring to calculate is character or string (not numbers) try to convert them to a number ( quantity,amount) first and then try.
Regards,
Himanshu
2008 Feb 29 2:00 PM
Hi,
For testing purpose I could do it in SE11 itself (sorting and subtotaling), I think it should possible.
Could you please provide me the code for sort and sutotaling.
Thanks,
Sriram POnna.
2008 Feb 29 2:14 PM
Hi,
Here is the complete definition of the internal table:
DATA: BEGIN OF i_out OCCURS 0,
pernr LIKE catsdb-pernr,
ename LIKE p0001-ename,
kostl LIKE p0001-kostl,
verak LIKE csks-verak,
workdate LIKE catsdb-workdate,
catshours LIKE catsdb-catshours,
END OF i_out.And here is the code for sorting:
FORM set_alv_sorting .
* sort by personnel number
CLEAR ln_sort.
ln_sort-fieldname = 'PERNR'.
ln_sort-spos = '1'.
ln_sort-up = 'X'.
APPEND ln_sort TO i_sort.
* sort by employee name
CLEAR ln_sort.
ln_sort-fieldname = 'ENAME'.
ln_sort-spos = '2'.
ln_sort-up = 'X'.
APPEND ln_sort TO i_sort.
* sort by cost centre
CLEAR ln_sort.
ln_sort-fieldname = 'KOSTL'.
ln_sort-spos = '3'.
ln_sort-up = 'X'.
APPEND ln_sort TO i_sort.
* sort by person responsible
CLEAR ln_sort.
ln_sort-fieldname = 'VERAK'.
ln_sort-spos = '4'.
ln_sort-up = 'X'.
APPEND ln_sort TO i_sort.
* sort by work date
CLEAR ln_sort.
ln_sort-fieldname = 'WORKDATE'.
ln_sort-spos = '5'.
ln_sort-up = 'X'.
APPEND ln_sort TO i_sort.
ENDFORM. " SET_ALV_SORTINGI have not added any code for sub totals, I have only tried to use the sub total-button in the list display. I get the error message even if I don't sort the output in advance.
Do you have any ideas?
<REMOVED BY MODERATOR>
Regards,
MV
Edited by: Alvaro Tejada Galindo on Feb 29, 2008 4:13 PM
2008 Feb 29 2:19 PM
Hi,
Change your code as below :
FORM set_alv_sorting .
* sort by personnel number
CLEAR ln_sort.
ln_sort-fieldname = 'PERNR'.
ln_sort-spos = '1'.
ln_sort-up = 'X'.
ln_sort-subtot = 'X'. "Code chnaged here
APPEND ln_sort TO i_sort.
"Don't chnage the rest of the code.
While building fieldcatalog, for CATSHOUR you have to use gt_fieldcat-do_sum = 'X'.
Thanks,
Sriram Ponna.
2008 Feb 29 2:16 PM
hi check this ex program,
&----
*& Report ZALVTESTFORSUBTOTAL
*&
&----
*&
*&
&----
REPORT ZALVTESTFORSUBTOTAL.
tables:pa0008.
type-pools:slis.
types:begin of ty_pa0008,
pernr like pa0008-pernr,
begda like pa0008-begda,
endda like pa0008-endda,
ansal like pa0008-ansal,
lga01 like pa0008-lga01,
bet01 like pa0008-bet01,
end of ty_pa0008.
data:it_pa0008 type standard table of ty_pa0008 with header line.
data:it_fieldcat type SLIS_T_FIELDCAT_ALV,
wa_fieldcat type slis_fieldcat_alv,
it_layout type slis_layout_alv,
WA_events TYPE slis_alv_event,
it_events TYPE slis_t_event.
select-options:s_pernr for pa0008-pernr.
start-of-selection.
perform getD_data.
perform disp_alv.
&----
*& Form getD_data
&----
text
----
--> p1 text
<-- p2 text
----
form getD_data .
select pernr
begda
endda
ansal
lga01
bet01
from pa0008
into table it_pa0008
where pernr in s_pernr.
sort it_pa0008 by pernr begda descending.
endform. " getD_data
&----
*& Form disp_alv
&----
text
----
--> p1 text
<-- p2 text
----
form disp_alv .
wa_fieldcat-fieldname = 'PERNR'.
wa_FIELDCAT-REPTEXT_DDIC = 'Personnel no'.
*WA_FIELDCAT-no_subtotals = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BEGDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'Start date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ENDDA'.
wa_FIELDCAT-REPTEXT_DDIC = 'End date'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'ANSAL'.
wa_FIELDCAT-REPTEXT_DDIC = 'Annula salary'.
wa_fieldcat-do_sum = 'X'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'LGA01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Wage Type'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
wa_fieldcat-fieldname = 'BET01'.
wa_FIELDCAT-REPTEXT_DDIC = 'Amount for wagetype'.
append wa_fieldcat to it_fieldcat.
clear wa_fieldcat.
DATA: sort TYPE slis_sortinfo_alv,
it_sort TYPE slis_t_sortinfo_alv.
sort-fieldname = 'PERNR'.
sort-subtot = 'X'.
SORT-UP = 'X'.
APPEND sort TO it_sort.
*sort-fieldname = 'BEGDA'.
*SORT-NO_SUBTOTS = 'X'.
*APPEND sort TO it_sort.
IT_layout-totals_text = 'total text'.
IT_layout-subtotals_text = 'Subtotal text'.
*WA_EVENTS-NAME = 'SUBTOTAL TEXT'.
*WA_EVENTS-FORM = 'SUBTOTAL TEXT'.
*APPEND WA_EVENTS TO IT_EVENTS.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = sy-repid
IS_LAYOUT = it_LAYOUT
IT_FIELDCAT = IT_FIELDCAT
it_sort = it_sort
it_events = it_events
TABLES
t_outtab = it_pa0008 .
endform. " disp_alv
<REMOVED BY MODERATOR>
venkat.
Edited by: Alvaro Tejada Galindo on Feb 29, 2008 4:13 PM
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |