Side by side ALV grid using OOPS

We can implement 2 ALV grids side by side using OOPS concepts. Here is the brief overview of OOPS ALV.

OOPS ALV as the name suggests is the object oriented implementation of ALV. It is more robust and has more features compared to traditional ALV. In OOPs ALV we first will create a container. Then we ‘dock’ ALV grids in these containers. By creating multiple containers in the screen ,  we can have multiple ALV grids.

Step by step of creating OOPS ALV :

Double click on the ‘8000’ to create the screen.

clip_image002

clip_image004

Uncomment STATUS_8000 and USER_COMMAND_8000.Double click on STATUS_8000 and select create modules in main program only.

Create a New PF STATUS for this

SET PF-STATUS 'ZAU_PF'.

SET TITLEBAR 'TEST PLAN'.

Double click on ZAU_PF and select the buttons you want and activate that PF status

clip_image006

Now lets create a docking container and embed one ALV grid in it.

Go back to the STATUS_8000 screen module and Create a docking container. Click pattern and select ABAP objects patterns

clip_image008

Select create object . Instance > Docking container name here its o_docking and class always cl_gui_docking_container

clip_image010

Change ratio according to requirement.

ratio                       = 45

Next create a GRID object.

Click pattern and select ABAP objects patterns

clip_image008[1]

Select create object . Instance > grid name here its o_grid and class always cl_gui_alv_grid

clip_image012

In  i_parent option write the parent docking name. In this case its o_docking.

Call function LVC_FIELDCATALOG_MERGE to auto fill field catalog Or build field catalog manually

CALL METHOD o_grid->set_table_for_first_display for alv output

Click ABAP Object Pattern radio button. Click Call Method radio button. Give Instance as o_grid(grid name) and Class/Interface as cl_gui_alv_grid and Method as set_table_for_first_display.

clip_image014

Repeat the same steps for Marc. Create a docking2 , grid2 object. generate field catalog for marc and call method grid2-> set_table_for_first_display for marc

Activate the file

Free all objects used when user presses back exit etc. Else it will go on creating ALV grids when screen gets changed.

Go to the USER_COMMAND_8000 and free all the objects used by calling method ‘free’ for grids and docking containers.

clip_image016

CALL METHOD o_grid->free

CALL METHOD o_docking->free

CALL METHOD o_grid2->free

CALL METHOD o_docking2->free

Do above free operations when user presses CANCEL , EXIT or BACK also.

Final result:

clip_image002[4]

Full code: