on 02-01-2007 9:19 AM
Hi Experts,
I got following info from help file to generate Intermediate Results(subtotal).
Can somebody help me with sample code to achieve this?
Basically I want to subtotal 'Qty' column based on 'Product' field.
By default, all values in a field are used in the calculation during aggregation. However, you
are also able to generate intermediate results. You group the data records that contain the
values for an intermediate result and display each intermediate result in its own result row.
To generate intermediate results, you have to provide certain information:
● To specify in which field the values from which the intermediate results are calculated
are located, generate an aggregation condition for the desired field. The overall result is
displayed in the result row.
● To specify which data records are contained in an intermediate result, group the data
records: You sort the ALV output by the field that includes the criterion for the
intermediate result.
● To then generate the intermediate results, calculate the intermediate results using the
field with the criterion.
● To then display the intermediate results, switch on the display of intermediate results.
You are able to make the following settings for intermediate results:
● Generate intermediate results
● Display intermediate results
● Setting levels for drilling down intermediate results
● Set the position of the result rows (see Settings for Aggregation [page 196])
● Forbid the generation of intermediate results
Prerequisites
● You have generated an aggregation object for at least one aggregatable field.
● The field with the criterion for intermediate results is not an aggregatable field, and
therefore has an alphanumeric data type.
Generate Intermediate Results
To generate intermediate results in a field that already has an aggregation condition, generate
a sort condition for the field of a column (another column) (see Sorting [page 190]).
In this sort condition, define whether intermediate results are to be generated. To do this, use
the methods of the class CL_SALV_WD_SORT_RULE.
Methods for Generating Intermediate Results
Function Method
Generate intermediate results SET_GROUP_AGGREGATION
Check whether intermediate results are displayed GET_GROUP_AGGREGATION
Display Intermediate Results
Once you have made all settings, to generate intermediate results you have to switch on the
display of these intermediate results. You use the methods of the interface class
IF_SALV_WD_FIELD_SETTINGS for this (implementing class
CL_SALV_WD_CONFIG_TABLE).
Methods for Displaying Intermediate Results
Function Method
Display intermediate results SET_GROUP_AGGR_DISPLAYED
Check whether intermediate results are displayed GET_GROUP_AGGR_DISPLAYED
I have tried a bit but it is not working. here is my code:
get field and create aggregation rule of type total
lr_field = l_value->if_salv_wd_field_settings~get_field( 'Qty' ).
lr_field->if_salv_wd_aggr~create_aggr_rule( ).
lr_aggr_rule = lr_field->if_salv_wd_aggr~get_aggr_rule( ).
lr_aggr_rule->set_aggregation_type( if_salv_wd_c_aggregation=>aggrtype_total ).
l_field = l_value->if_salv_wd_field_settings~get_field( 'PRODUCT' ).
l_sortrule = l_field->IF_SALV_WD_SORT~create_sort_rule( ).
l_sortrule~SET_GROUP_AGGREGATION( 'Y').
l_value->if_salv_wd_field_settings~SET_GROUP_AGGR_DISPLAYED( 'Y' ).
Please help
Message was edited by:
gopalkrishna baliga
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
93 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.