2008 Aug 06 3:05 PM
Hi,
I am using CL_SALV_TABLE for displaying a ALV with the help of factory method.
Here I am using sort. If I put sort on integer field one exception is coming.
Subtotals cannot be calculated on aggregatable col.
Can anyone solve my problem....thanks in advance....
Amitava
Hi,
I am using CL_SALV_TABLE for displaying a ALV with the help of factory method.
Here I am using sort. If I put sort on integer field one exception is coming.
Subtotals cannot be calculated on aggregatable col.
Can anyone solve my problem....thanks in advance....
Amitava
2008 Aug 06 3:26 PM
I am getting the subtotals, First use summation button on any of the Qty or Currency fields. then sorr the Columns based on you want subtotals. Now click on subtotal button, choosing the column which you sorted.
REPORT zsalv_demo.
TABLES: sflight.
DATA:
t_sbook LIKE TABLE OF sbook,
salv TYPE REF TO cl_salv_table.
DATA:
functions TYPE REF TO cl_salv_functions_list.
SELECT-OPTIONS:
s_carid FOR sflight-carrid.
START-OF-SELECTION.
*-Get data
SELECT *
FROM sbook
INTO TABLE t_sbook
UP TO 10 ROWS
WHERE carrid IN s_carid.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = salv
CHANGING
t_table = t_sbook.
CALL METHOD salv->get_functions
RECEIVING
value = functions.
CALL METHOD functions->set_all.
CALL METHOD salv->display.
Regards
Vijay Babu Dudla
2008 Aug 06 3:41 PM
Hi
just append the following code with your code.... you will get the error
DATA: l_oref_sorts TYPE REF TO cl_salv_sorts,
l_except1 TYPE REF TO cx_salv_not_found, "Exception
l_except2 TYPE REF TO cx_salv_existing, "Exception
l_except3 TYPE REF TO cx_salv_data_error, "Exception
l_text1 TYPE string. "Exception msg
* get the SORTS object
l_oref_sorts = salv->get_sorts( ).
TRY.
CALL METHOD l_oref_sorts->add_sort
EXPORTING
columnname = 'SEATSOCC'
position = 1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_data_error INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
2008 Aug 06 3:55 PM
I got it .
The reason why you are getting that message is Subtotals cannot be performed on Number ,Qty or Currency fields.
SEATSOCC is of type INT. so that is the reason it is giving the message.I changed SEATSOCC to CARRID it is working fine for me.
REPORT zsalv_demo message-id zz.
TABLES: sflight.
DATA:
t_sflight LIKE TABLE OF sflight,
salv TYPE REF TO cl_salv_table.
DATA:
functions TYPE REF TO cl_salv_functions_list.
SELECT-OPTIONS:
s_carid FOR sflight-carrid.
START-OF-SELECTION.
*-Get data
SELECT *
FROM sflight
INTO TABLE t_sflight
UP TO 10 ROWS
WHERE carrid IN s_carid.
CALL METHOD cl_salv_table=>factory
EXPORTING
list_display = if_salv_c_bool_sap=>false
IMPORTING
r_salv_table = salv
CHANGING
t_table = t_sflight.
CALL METHOD salv->get_functions
RECEIVING
value = functions.
CALL METHOD functions->set_all.
CALL METHOD salv->display.
DATA: l_oref_sorts TYPE REF TO cl_salv_sorts,
l_except1 TYPE REF TO cx_salv_not_found, "Exception
l_except2 TYPE REF TO cx_salv_existing, "Exception
l_except3 TYPE REF TO cx_salv_data_error, "Exception
l_text1 TYPE string. "Exception msg
* get the SORTS object
l_oref_sorts = salv->get_sorts( ).
TRY.
CALL METHOD l_oref_sorts->add_sort
EXPORTING
columnname = 'CARRID' "SEATSOCC
position = 1.
CATCH cx_salv_not_found INTO l_except1.
l_text1 = l_except1->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_existing INTO l_except2.
l_text1 = l_except2->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
CATCH cx_salv_data_error INTO l_except3.
l_text1 = l_except3->get_text( ).
MESSAGE i000 WITH l_text1.
LEAVE LIST-PROCESSING.
ENDTRY.
2008 Aug 06 4:04 PM
I am doing SORT operation on the field CARRID and not doing subtotal.
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |