on 06-24-2009 3:11 PM
Hi Friends ,
I need to make all the arithmetic operation in ALV TABLE like sum , subtraction ,deletion etc..
How can i do this one ,
Can any one help to solve this problem
Thanks & Regards
Sankar.M
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please describe more what you need to do. If you want to perform arithmetic operations, you can always do this on the source data while still in an ABAP internal table before binding to the context. Otherswise the ALV had the built-in functions to allow columnar Total, Minimum, Maximum, and Mean Value calculation via the Calculation Tab in the Settings dialog. Use the following ALV settings to activate this option in the settings:
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
data l_salv_wd_table type ref to iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv( ).
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
l_table->if_salv_wd_std_functions~set_count_records_allowed( abap_true ).
l_table->if_salv_wd_std_functions~set_aggregation_allowed( abap_true ).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>
> Hi thomas ,
>
>
> I need to calculate the sum , and subtract the values and add two values like that .
>
> I don't know how can i perform these steps
>
> can you tell me the proper steps for this problem
>
>
> Thanks
>
> Sankar.M
As already described, you can add a columnar sum option via the code given and then activate the option per column in the layout settings dialog.
For other calculations, you should perform these in ABAP code on the internal table data before data binding to the context. Are you asking how you perform arithmetic operations in ABAP? Arthmetic operators are keywords in the language. For instance i fyou want to subtract two columns and store the values in a third for all records in an internal table, you would do something like this:
field-symbols: <Wa_itab> like line of itab.
loop at itab assigning <wa_itab>.
<wa_itab>-col3 = <wa_itab>-col1 - <wa_itab>-col2.
endloop.
Hi thomas
I used the following code what you given in the init method,
data: l_ref_cmp_usage type ref to if_wd_component_usage.
l_ref_cmp_usage = wd_this->wd_cpuse_alv( ).
if l_ref_cmp_usage->has_active_component( ) is initial.
l_ref_cmp_usage->create_component( ).
endif.
data l_salv_wd_table type ref to iwci_salv_wd_table.
l_salv_wd_table = wd_this->wd_cpifc_alv( ).
data l_table type ref to cl_salv_wd_config_table.
l_table = l_salv_wd_table->get_model( ).
l_table->if_salv_wd_std_functions~set_count_records_allowed( abap_true ).
l_table->if_salv_wd_std_functions~set_aggregation_allowed( abap_true ).
but it displays the error
mthod wd_cpuse_alv( ). is unknown or protected or private
what should i do ?
Thanks & Regards
Sankar.M
Hi lekha ,
I did this thing perfectly , but this case the calculation button is inside of the setting ,
that means after clicking the setting button only we get that total sum all the things .
can we get that calculation button directly instead of clicking the setting button to get calculation ?
Thanks
Sankar.M
Hi,
I did not get your doubt.
When you check the link i have provided, you can see the Total for those columns.
For ex: if you change some data and want the SUM for that column. Refer the above link.
But to get the total, you need to hit 'ENTER' key or any event so that SUMMATION is shown for that column.
Regards
Lekha
hi thanks for your reply,
i am not asking that one ,
when i run application , in that page there are two two buttons on ALV TABLE ,
1. filter
2. setting
after clicking the setting button then only i get that calculation button then i do all operation .
Instead of this one can i get that calculation button in the alv in front ? instead of clicking the setting button .....
now got it ?
Thanks
Sankar.M
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.