Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Multiple ALV grids on a single screen in SAP ABAP
It is not possible to resize or place the grid at a particular position using function modules as ALVs are always displayed in fullscreen when using function modules. This limitation makes it challenging when you need to display multiple ALV grids or have more control over the grid positioning.
One method to overcome this limitation is to create a screen using custom container and then use the class CL_GUI_ALV_GRID to attach the ALV grids to this container at desired positions.
Implementation Steps
To create multiple ALV grids on a single screen, follow these key steps ?
Step 1: Create a screen (dynpro) with custom container controls
Step 2: Define internal tables for your data
Step 3: Create container objects using CL_GUI_CUSTOM_CONTAINER
Step 4: Create ALV grid objects using CL_GUI_ALV_GRID
Step 5: Link the ALV grids to their respective containers
Example Code Structure
Here's a basic example showing how to implement multiple ALV grids ?
" Data declarations
DATA: lo_container1 TYPE REF TO cl_gui_custom_container,
lo_container2 TYPE REF TO cl_gui_custom_container,
lo_alv_grid1 TYPE REF TO cl_gui_alv_grid,
lo_alv_grid2 TYPE REF TO cl_gui_alv_grid,
lt_data1 TYPE TABLE OF sflight,
lt_data2 TYPE TABLE OF spfli.
" Create containers
CREATE OBJECT lo_container1
EXPORTING
container_name = 'CONTAINER1'.
CREATE OBJECT lo_container2
EXPORTING
container_name = 'CONTAINER2'.
" Create ALV grids
CREATE OBJECT lo_alv_grid1
EXPORTING
i_parent = lo_container1.
CREATE OBJECT lo_alv_grid2
EXPORTING
i_parent = lo_container2.
" Display data in grids
CALL METHOD lo_alv_grid1->set_table_for_first_display
CHANGING
it_outtab = lt_data1.
CALL METHOD lo_alv_grid2->set_table_for_first_display
CHANGING
it_outtab = lt_data2.
Screen Design Considerations
When designing the screen, ensure that each custom container has a unique name and proper sizing. The containers should be positioned appropriately to accommodate both ALV grids without overlap.
This approach provides full control over ALV positioning and allows for sophisticated screen layouts with multiple data displays.
Conclusion
Using custom containers with CL_GUI_ALV_GRID class enables precise control over ALV grid positioning and allows multiple grids on a single screen, overcoming the fullscreen limitation of function modules.
