on 05-19-2009 3:29 PM
HI there,
I have created an alv grid with two columns...
One columns is PERNR and the other one is HOURS...
I have created a agregation for field HOURS likle this...
LR_FIELD = LR_FSET->GET_FIELD( 'CATSHOURS' ).
LR_FIELD->IF_SALV_WD_AGGR~CREATE_AGGR_RULE( AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL ).
LR_FIELD->IF_SALV_WD_AGGR~SET_AGGREGATION_ALLOWED( ABAP_TRUE ).
But i Need subtotal by PERNR....
I have tried SORT, tried AGREGATION NON...
But do not succeed !
Please thanks for the help !
Stephan
Hi,
U can use the following piece of code.
DATA: lr_field_settings TYPE REF TO IF_SALV_WD_FIELD_SETTINGS,
lr_field_curr TYPE REF TO CL_SALV_WD_FIELD,
lr_field_amnt TYPE REF TO CL_SALV_WD_FIELD.
DATA: lv_aggr_rule TYPE REF TO CL_SALV_WD_AGGR_RULE.
DATA: lr_sort_rule TYPE REF TO CL_SALV_WD_SORT_RULE.
* get ALV component
lr_salv_wd_table = wd_this->wd_cpifc_OVERVIEW_PAYMENT_ALV( ).
wd_this->alv_config_table = lr_salv_wd_table->get_model( ).
* display columns in correct order
lr_column_settings ?= wd_this->alv_config_table.
lt_column = lr_column_settings->get_columns( ).
loop at lt_column into ls_column.
CASE ls_column-id.
when 'DUE_CONAMNT'.
* aggregate field
CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
EXPORTING
FIELDNAME = 'DUE_CONAMNT'
RECEIVING
VALUE = lr_field_amnt.
* create aggregate rule as total
CALL METHOD LR_FIELD_AMNT->IF_SALV_WD_AGGR~CREATE_AGGR_RULE
EXPORTING
AGGREGATION_TYPE = IF_SALV_WD_C_AGGREGATION=>AGGRTYPE_TOTAL
RECEIVING
VALUE = lv_aggr_rule.
when 'CON_CURR'.
CALL METHOD LR_FUNCTION_SETTINGS->IF_SALV_WD_FIELD_SETTINGS~GET_FIELD
EXPORTING
FIELDNAME = 'CON_CURR'
RECEIVING
VALUE = lr_field_curr.
* sub totals based on contract currency.
CALL METHOD LR_FIELD_CURR->IF_SALV_WD_SORT~CREATE_SORT_RULE
EXPORTING
SORT_ORDER = IF_SALV_WD_C_SORT=>SORT_ORDER_ASCENDING
GROUP_AGGREGATION = ABAP_TRUE
RECEIVING
VALUE = lr_sort_rule.
ENDCASE.
ENDLOOP.
Here I'm doing subtotal based on currency field.
Hope this piece of code helps.
Regards
Manas Dua
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
If you want to sort then you can refer following code.
* Sort rows by seatsocc descending
DATA: lr_field TYPE REF TO cl_salv_wd_field.
lr_field =
l_value->if_salv_wd_field_settings~get_field( 'CATSHOURS' ).
lr_field->if_salv_wd_sort~create_sort_rule( sort_order =
if_salv_wd_c_sort=>sort_order_descending ).
I hope it helps.
regards,
rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
GROUP_AGGREGATION WHEN CREATING SORT IS PROVIDED WITH ABAP_TRUE
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
101 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.