Sometimes we need to modify the subtotals on the ALV, specially when we have to give the average of the percentages or something like that. To change the subtotal we need to follow certain steps:
1. we need to get the ALV object form the ALV function module. We can use the FM GET_GLOBALS_FROM_SLVC_FULLSCR to get the Global data of the ALV. From this FM we will get the ALV object.
2. After getting the ALV object, we need to get the subtotal using the method GET_SUBTOTALS of the ALV object. We will get the first level subtotal using the parameter EP_COLLECT01.
3. Now, we need to modify the subtotal. Here we need to take help of Field-symbols since the EP_COLLECT01 is reference to data.
4. We need to refresh the Table display. For this purpose we can use the method REFRESH_TABLE_DISPLAY.
Here is the code snippet which performs all the steps mentioned above:Code Snippet to change the Subtotal |
|
To be able to use the FM GET_GLOBALS_FROM_SLVC_FULLSCR, we need to find a spot in our program which is being called after the ALV's main FM e.g. REUSE_ALV_GRID_DISPLAY. For this purpose, I have implemented the TOP_OF_PAGE event because it will always be called after the FM. In the subroutine for the TOP_OF_PAGE, I used the code snippet to change the Subtotal.
You can download the entire source code of my test program from here --> http://smartform.googlecode.com/files/ZALV_SUBTOT_CHANGE.txt .
This website contains fundamental language elements of ABAP Objects and the usage of the respective ABAP Workbench tools. The tutorial is designed for developers who have had little or no experience with ABAP and ABAP Objects until now.
- ELEMENTARY DATA TYPES - Initial Values, Syntax & Properties.
- FIELD SYMBOLS - Introduction, Syntax & Examples.
- PARAMETERS - Introduction, Syntax & Examples.
- SELECT-OPTIONS - Introduction, Syntax & Examples.
- SELECTION-SCREEN - Introduction, Syntax & Examples.
- SSCRFIELDS - The Screen Fields Table.
EVENTS
- ABAP EVENTS During Runtime Of A Report Program.
- INITIALIZATION Event - Introduction With A Sample Code.
- AT SELECTION-SCREEN Event - Introduction With A Sample Code.
- AT SELECTION-SCREEN OUTPUT Event - Introduction With A Sample Code.