2024 Oct 16 5:44 AM
The aggregation was not working on my main program, so I decided to write another dummy program to see if it works there or not. Turns out, it doesn't. I have gone through every discussion and cannot seem to find the solution. The total doesn't appear at the end of the column which technically, it should.
Here is the code:
REPORT z_test_salv_aggregation.
TYPES: BEGIN OF ty_data,
menge TYPE i, " Using integer for quantity
END OF ty_data.
DATA: it_test TYPE TABLE OF ty_data,
wa_test TYPE ty_data,
lo_alv_table TYPE REF TO cl_salv_table,
lo_agg TYPE REF TO cl_salv_aggregations,
lo_functions TYPE REF TO cl_salv_functions_list.
* Sample data
wa_test-menge = 10. APPEND wa_test TO it_test.
wa_test-menge = 20. APPEND wa_test TO it_test.
wa_test-menge = 30. APPEND wa_test TO it_test.
* Create the ALV Table
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv_table
CHANGING
t_table = it_test
).
CATCH cx_salv_msg INTO DATA(lx_msg).
WRITE: / 'Error creating ALV table:', lx_msg->get_text( ).
RETURN.
ENDTRY.
* Get the Functions object and activate all functions
lo_functions = lo_alv_table->get_functions( ).
lo_functions->set_all( 'X' ).
lo_agg = lo_alv_table->get_aggregations( ).
TRY.
CALL METHOD lo_agg->add_aggregation
EXPORTING
columnname = 'MENGE'
aggregation = if_salv_c_aggregation=>total.
CATCH cx_salv_data_error cx_salv_not_found cx_salv_existing INTO DATA(lx_error).
ENDTRY.
* Display the ALV Table
lo_alv_table->display( ).
The aggregation was not working on my main program, so I decided to write another dummy program to see if it works there or not. Turns out, it doesn't. I have gone through every discussion and cannot seem to find the solution. The total doesn't appear at the end of the column which technically, it should.
Here is the code:
REPORT z_test_salv_aggregation.
TYPES: BEGIN OF ty_data,
menge TYPE i, " Using integer for quantity
END OF ty_data.
DATA: it_test TYPE TABLE OF ty_data,
wa_test TYPE ty_data,
lo_alv_table TYPE REF TO cl_salv_table,
lo_agg TYPE REF TO cl_salv_aggregations,
lo_functions TYPE REF TO cl_salv_functions_list.
* Sample data
wa_test-menge = 10. APPEND wa_test TO it_test.
wa_test-menge = 20. APPEND wa_test TO it_test.
wa_test-menge = 30. APPEND wa_test TO it_test.
* Create the ALV Table
TRY.
cl_salv_table=>factory(
IMPORTING
r_salv_table = lo_alv_table
CHANGING
t_table = it_test
).
CATCH cx_salv_msg INTO DATA(lx_msg).
WRITE: / 'Error creating ALV table:', lx_msg->get_text( ).
RETURN.
ENDTRY.
* Get the Functions object and activate all functions
lo_functions = lo_alv_table->get_functions( ).
lo_functions->set_all( 'X' ).
lo_agg = lo_alv_table->get_aggregations( ).
TRY.
CALL METHOD lo_agg->add_aggregation
EXPORTING
columnname = 'MENGE'
aggregation = if_salv_c_aggregation=>total.
CATCH cx_salv_data_error cx_salv_not_found cx_salv_existing INTO DATA(lx_error).
ENDTRY.
* Display the ALV Table
lo_alv_table->display( ).
2024 Oct 16 6:16 AM
2024 Oct 16 6:20 AM
Hey, thanks for your reply. As you can see in the image below, the sum is not shown. Could this be a version problem or something like that?
2024 Oct 16 6:21 AM - edited 2024 Oct 16 6:23 AM
Of course. Optionally use "ALV SOS" to identify the cause (search the Web).
2024 Oct 16 6:44 AM
yeah, I did the consistency check. It shows this
What does this mean?
2024 Oct 16 7:29 AM
2024 Oct 16 7:49 AM
You didn't indicate your ABAP version.
Try with type P instead of I.
2024 Oct 16 8:04 AM
I copied your code and it worked on my ECC and S/4HANA systems, can you check that you didn't define a default display variant and/or execute the ALV consistency check on your system?
2024 Oct 16 8:43 AM - edited 2024 Oct 16 9:13 AM
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |