Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata



Applies to:

This article applies to SAP version ECC 6.0. This article applies to SAP ECC6.0, SAP Netweaver 2007 and above. For more information, visit the Web Dynpro ABAP homepage

Summary

This document explains about the concept of aggregations in Web Dynpro ABAP and usage of aggregations in WDA.

Author(s):  

Author(s):    Renuka Srinivasan

Company:    Applexus Technologies Pvt Ltd

Created on:  12 January 2012

 

1.    Aggregation:

       Aggregation is a calculation of set of values in a table. We can make calculations using the values of numeric columns (i.e. we will calculations in field with a numeric data type). By default all the values of a column are used for this. The result of the calculation is then displayed in a separate result row. We can also generate aggregation conditions.
          For e.g.:  If we consider the SAP List Viewer we can apply the above concept and along with if we need intermediate results of a particular column along with overall result of the calculation, the rows that contain the sub values of an intermediate result need to be next to each other, so we will sort the ALV. i.e. In ALV  if we sort the columns we can get intermediate results of that column.

2.    Possible Settings for Aggregations                 

  • Creating, getting and deleting an aggregation rule
  • Making settings for aggregation
  • Generating intermediate results
  • Hiding and showing interface elements for calculations or intermediate results                                                       

2.1 Creating, Getting and Deleting an Aggregation Rule    

      We are able to create maximum of one aggregation rule for a field. Aggregation is a property of a field; use the methods of the interface class IF_SALV_WD_AGGR implementing class CL_SALV_WD_FIELD.
               Following methods are available for this purpose:

Function

Method

Get aggregation rule

GET_AGGR_RULE

Create aggregation rule

CREATE_AGGR_RULE

Delete aggregation rule

DELETE_AGGR_RULE

                      
  

 

 

The aggregation rule of a field is represented by an object of the class CL_SALV_WD_AGGR_RULE.
Note: If we assign a new data table with a new structure to ALV output, all aggregation rules for all fields are deleted automatically.

2.2 Settings for Aggregation

                   Following are the settings for Calculation of field values:

  • Set aggregation type
  • Set the position of the result row
  • Forbid aggregation for a field

            2.2.1Setting the Aggregation Type

                   The following Aggregation (Calculation) types are available:

  • Total
    Adds together all values of the field
  • Minimum
    Determines the smallest value of the field
  • Maximum
    Determines the largest value of the field
  • Average
    Determines geometric average of all values of field
    To define the calculation type, can use methods of the class ‘CL_SALV_WD_AGGR_RULE’.

              2.2.1.1Methods for Changing Aggregation Type

                  

Function

Method

Set calculation type

SET_AGGREGATION_TYPE

Get calculation type

GET_AGGREGATION_TYPE

                   
  In addition to the calculation types listed above, you can also determine the total number of data   records. The result is displayed in the result row in the first available column. Because this setting affects the entire ALV output, we can use methods of the interface class IF_SALV_WD_FIELD_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE).

           2.2.1.2Methods for Displaying the Data Records of a Result


Function

Method

Display the number of data records

SET_COUNT_RECORDS_ENABLED

Check whether the number of data records is
displayed

IS_COUNT_RECORDS_ENABLED

                       

 


               


          2.2.2Setting the Position of Result Row

              We are able to define whether we need to display the result row for the calculations in an
ALV output above or below the rows that are included in the calculation. You use the methods of the
Interface class IF_SALV_WD_FIELD_SETTINGS for this (implementing class CL_SALV_WD_CONFIG_TABLE).


       2.2.2.1 Methods Relating to the Position of the Result Row                      

Function

Method

Place result row before data records

SET_AGGR_BEFORE_ITEMS

Check whether the result row is placed before the data records

IS_AGGR_BEFORE_ITEMS






    2.2.3Forbidding Aggregation for a Field

              By default, all fields with a numeric data type can be aggregated. We can forbid the aggregation for a field, if required. This has the following effects:

  • The column in question is no longer available on the Calculation tab of the Settings
    Dialog box_._
  • If we defined an aggregation rule for this field in our application, the calculation is
    Not carried out.
    To forbid the aggregation of a field, use the methods of the interface class IF_SALV_WD_AGGR (implementing class CL_SALV_WD_FIELD).       

       2.2.3.1 Methods for Forbidding Aggregation                   

                   

Function

Method

Forbid aggregation

SET_AGGREGATION_ALLOWED

Check whether aggregation is
allowed

IS_AGGREGATION_ALLOWED

                       

 


               


  2.3 Intermediate Results

By default, all values in a field are used in the calculation during aggregation. However, we are also able to generate intermediate results. For generating those need to 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 result row.
  • To specify which data records are contained in an intermediate result, group the data records. 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.
       We 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
  • 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.

           2.3.1Generate 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). 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.

           2.3.1.1Methods for Generating Intermediate Results

                          

Function

Method

Generate intermediate results

SET_GROUP_AGGREGATION

Check whether intermediate results are displayed

GET_GROUP_AGGREGATION










          2.3.2Display Intermediate Results

              After Completing all the settings, to generate intermediate results we have to switch on the
Display of those intermediate results. We can use the methods of the interface class
IF_SALV_WD_FIELD_SETTINGS (implementing class CL_SALV_WD_CONFIG_TABLE).
       

Function

Method

Display intermediate results

SET_GROUP_AGGR_DISPLAYED

Check whether intermediate results are displayed

GET_GROUP_AGGR_DISPLAYED










        2.3.3Setting Levels for Drilling Down Intermediate Results

If we need to defined intermediate results for several alphanumeric fields, there are multiple levels of subtotals: The intermediate results are subdivided hierarchically and are marked with different number of points according to their level. The user can use these points to show and hide the entries for the individual intermediate results. We can use our application to show or hide the entries of one or more complete subtotal levels.
 We can also aggregate intermediate results. Can hide all data records and any existing lower subtotal levels. Only the results rows of the highest subtotal level and the results row with the overall result remains visible.
We can use the methods of the interface class IF_SALV_WD_FIELD_SETTINGS for this (implementing class CL_SALV_WD_CONFIG_TABLE).

        2.3.3.1Methods for Steps for Expanding Subtotals

  

Function

Method

Set highest subtotal level to be displayed

SET_EXPAND_LEVEL

Get current subtotal level being displayed

GET_EXPAND_LEVEL

Aggregate intermediate result

SET_GROUP_AGGR_COLLAPSED

Check whether intermediate results are aggregated

GET_GROUP_AGGR_COLLAPSED










     2.3.4Forbid the Generation of Intermediate Results

          By default, intermediate results are automatically displayed in the ALV output as soon as a
Calculation is performed in at least one field: all sorted fields with alphanumeric data types are
Interpreted as a possible criterion for intermediate results and are thus given intermediate results.
We can forbid the generation of intermediate results for individual fields. This has the following effects:

  • If we generate intermediate results for this field in our application, these settings have no effect in the ALV output.
                To forbid the generation of intermediate results for a field, use the methods of the interface
                Class IF_SALV_WD_SORT (implementing class CL_SALV_WD_FIELD).

     2.3.4.1Forbid the Generation of Intermediate Results              

Function

Method

Forbid the generation of intermediate results

SET_GROUP_AGGREGATION_ALLOWED

Check whether generating intermediate
results is permitted

IS_GROUP_AGGREGATION_ALLOWED

 

 

 

 

 

1.    Simple Layout Model for Aggregation Functionality

           View Element


           

Children
0…n

 

UI Element Container

          Layout Data

                                                                                                         

0…1

 

                                                                                                                            

              Layout

         UI Element

Container
 0…1

1

Generalization
 0…1

Aggregation






 




                                        Fig:    Layout Arrangement of UI Element in UI Element Container
The layout specifies the arrangement of the UI elements in their UI Element Container. An object of the type layout can be added to each container. To each child object contained in this container, an appropriate object of the type layout data can be added. This Layout Data object specifies the layout properties of the corresponding child – for example, the position in a coordinate system defined by the layout.

2.     Various Types/ Usage/Functions of Aggregations

Ø  Microsoft Excel

For uploading files from / to Microsoft \Excel we can use aggregations.

  • ALV Functions
  • UI Element Container
     Here UI elements of a view are maintained in hierarchical structure. The hierarchy is based on aggregations like parent-child relationship between UI elements in the container.
  • Dynamic Programming
    For Dynamic Programming aggregations are provided in view designer.
  • View Designer
    Dynamic Programming of Aggregations:
    | View Designer Name | Runtime Name | Cardinality |

    Element

    CHILDREN

    0…n

    Category

    CATEGORY

    0…1

    Series

    SERIES_LIST

    1…n

    Value

    VALUES

    1…n

    Point

    POINT

    1…1

    Items

    ITEMS

    0…n

    Inhalt

    CONTENT

    0…1

    Header

    HEADER

    0…1

    Area

    AREAS

    0…n

    Title Content

    TITLE_CONTENT

    0…1

    MENU

    MENU

    0…1

    Menu Item

    ITEMS

    0…n

    Toolbar-Element

    TOOLBAR_ITEMS

    0..n

    Right-justified Toolbar Element

    TOOLBAR_RIGHT_ITEMS

    0..n

    Step

    STEPS

    0…n

    Button

    BUTTONS

    0…n

    Legend

    LEGEND

    0…1

    Selection

    MARKING

    0…1

    Phase

    PHASES

    0…n

    Element in Tab

    ENABLED

    0…1

    Header

    CONTENT

    1…1

    Toolbar

    VISIBLE

    0…1


















  • Business Graphics
    The UI element Business Graphics provides several chart types which can help the user of WD application to make decisions for corporate planning and find information in general.
    Chart designer can change UI element properties which also include aggregation functionality.

    Name

    Cardinality

    Type

    Category

    0…1

    Category

    Series

    1…n

    Abstract Series






    We can create this aggregation in the view designer in the UI tree from the context menu.

  • Point Aggregation
    Value (1…n) – Aggregation for a Numeric Value or Time Value, can create this aggregation in the view designer in the UI tree from context menu. (Insert value)
    | Name | Cardinality | Type |

    Point

    1…1

    Point







  • Series Aggregations
    Point (1…1) can create this aggregation in the view designer in the UI tree from context menu. (Insert point)
  • Contextual Panel

    Name

    Cardinality

    Type

    ITEMS

    0…n

    Contextual Panel Item





    Here following UI elements are used for various entries of aggregation:
     Free Contextual Area

    Name

    Cardinality

    Type

    Inhalt

    0…1

    UI Element

    Header

    0..1

    Expandable Title






                              View Switch
     Navigation List

    Name

    Cardinality

    Type

    ITEMS

    0…n

    Contextual Panel Item






  • Navigation List

    Name

    Cardinality

    Type

    HEADER

    0…1

    Expandable Title





  • Page Header / Page Header Area

    Name

    Cardinality

    Type

    Area

    0…n

    Page Header Area

    Title

    0…1

    UI Element

    Content

    0…1

    UI Element












  • Image
    | Name | Cardinality | Type |

    MENU

    0…1

    Menu





    Aggregation of a menu that is implemented using the UI element Menu.  As the Image is generally is not ready for data input, the arrow appears that displays the menu UI element only when the cursor is moved over the UI element.
                              Example of the display:
    We can create this aggregation for the Image in the View Designer in the UI tree from the context menu (entry Insert Menu).         
  • Link to Action/ Link to URL/ Data Binding
     Menu (0…1) - aggregation of a menu that is implemented using the UI element Menu.
  • Text View
        Menu (0…1) - Aggregation of a menu that is implemented using the UI element menu. As the Text View is generally is not ready for data input, the arrow appears that displays the menu UI element only when the cursor is moved over the UI element.
                                                
    Example of the display:
    You can create this aggregation for the Text View in the View Designer in the UI tree from the context menu (entry Insert Menu).
  • Menu                                

    Name

    Cardinality

    Type

    Menu Item

    0…n

    Menu Item





  • Toolbar

    Name

    Cardinality

    Type

    Toolbar Element

    0…n

    Toolbar Item

    Right Justified Toolbar Element

    0…n

    Toolbar Item







  • Toolbar Button Choice
         CHOICES (0…n) - Aggregation of a menu entry that is implemented using the UI element Menu Action Item. We can create this aggregation for the menu in the View Designer in the UI tree from the context menu (entry Insert Selection).
  • Breadcrumb
    A Breadcrumb displays the current page in the context of a navigation path. Bread Crumb Steps are bound to individual context attributes. In this way, the number of displayed steps is defined during runtime.
    | Name | Cardinality | Type |

    STEP

    0…n

    Bread Crumb Step






  • Button Row

    Name

    Cardinality

    Type

    Button

    0…n

    Button Row Item





  • Date Navigator
                                     

    Name

    Cardinality

    Type

    Legend

    0…1

    Date Navigator Legend

    Selection

    0…1

    Date Navigator Marking






  • Legend – (ITEMS(0…n))
  • Multi Pane – (Content (0…1) grid cell in the form of any element)
  • Phase Indicator – (Phase(0…n))
  • Progress Indicator – (Menu(0…1))
  • Roadmap – (Step(0…n))
  • Table(Table column, Table column Group, Table Standard Cell, Table Single Markable Cell)
    Discussed Initially.
  • Tabstrip 
    Tab (0...n) Aggregation for a Tab. We can create this aggregation in the View Designer in the UI tree from the context

    Name

    Cardinality

    Type

    Element in Tab

    ENABLED

    WDY_BOOLEAN

    Header

    HAS_CONTENT_PADDING

    WDY_BOOLEAN

    Toolbar

    VISIBLE

    WDY_BOOLEAN












  • Menu (entry Insert Tab).
  • Tab, Tree, Abstract Master Table Column, Abstract Popin, Abstract Table Column, Abstract Tree Node Type, Group , Tray..(MENU, ELEMENT, STEPS).