Displaying Two ALV Grid on Screen

Embed Size (px)

DESCRIPTION

alv grid

Citation preview

Displaying Two ALV Grid on ScreenIn this tutorial I will try to explain how to display multiple ALV Grid on a single screen. This is a very simple concept, to render or to draw a ALV grid on a screen you need a CONTAINER. Usually we create a CONTAINER with class CL_GUI_CUSTOM_CONTAINER and pass this CONTAINER object while creating ALV grid in parameter I_PARENT. Now to display multiple ALV grid you need multiple CONTAINER, here the class CL_GUI_EAST_SPLITTER_CONTAINER comes in the picture. This class divides a particular CONTAINER into two and give you two CONTAINER in return. How it divides depend on the parameter you pass while creating object. You can divide it horizontally by passing argument CL_GUI_EAST_SPLITTER_CONTAINER=>ORIENTATION_HORIZONTAL or vertically by passing argument CL_GUI_EAST_SPLITTER_CONTAINER=>orientation_VERTICAL. Since it will give you two CONTAINER you can further divide resulting CONATINER into two. So each time you create a object of CL_GUI_EAST_SPLITTER_CONTAINER you get one more CONTAINER. Finally you can use these CONATINER to create ALV Grids, or any GUI controls for example CL_GUI_ALV_TREE or CL_GUI_MOVIE (SAP Movie Control.. sounds interesting).

If you are confuse with above explanation then just forgot it and see the example. I have created a SCREEN 100 with custom container name 'CONTAINER'.

Below is the code for above screen shot.?

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108REPORT zreport.TABLES : scarr .DATA : it_scarr TYPE TABLE OF scarr .DATA : ob_custom TYPE REF TO cl_gui_custom_container ,ob_split1 TYPE REF TO cl_gui_easy_splitter_container ,ob_split2 TYPE REF TO cl_gui_easy_splitter_container ,ob_grid1 TYPE REF TO cl_gui_alv_grid ,ob_grid2 TYPE REF TO cl_gui_alv_grid ,ob_grid3 TYPE REF TO cl_gui_alv_grid .SELECT-OPTIONS : s_carrid FOR scarr-carrid .START-OF-SELECTION .SELECT *INTO TABLE it_scarrFROM scarrWHERE carrid IN s_carrid .CALL SCREEN 100 .*&---------------------------------------------------------------------**& Module status_0100 OUTPUT*&---------------------------------------------------------------------*MODULE status_0100 OUTPUT.SET TITLEBAR 'ZTITLE01' .SET PF-STATUS 'ZPF01' .* This will create a containerCREATE OBJECT ob_customEXPORTINGcontainer_name = 'CONTAINER'.* This spit the container OB_CUSTOM into twoCREATE OBJECT ob_split1EXPORTINGparent = ob_customorientation = cl_gui_easy_splitter_container=>orientation_vertical.* Now we have two container* OB_SPLIT1->TOP_LEFT_CONTAINER* OB_SPLIT1->BOTTOM_RIGHT_CONTAINER* Since these two are itself a container we can further devide them into two.* Let try to divide OB_SPLIT1->BOTTOM_RIGHT_CONTAINER into twoCREATE OBJECT ob_split2EXPORTINGparent = ob_split1->bottom_right_containerorientation = cl_gui_easy_splitter_container=>orientation_horizontal.* Now we have total 3 container available with us* OB_SPLIT1->TOP_LEFT_CONTAINER* OB_SPLIT2->TOP_LEFT_CONTAINER* OB_SPLIT2->BOTTOM_RIGHT_CONTAINER* Note that OB_SPLIT1->BOTTOM_RIGHT_CONTAINER is not available because we divided* that into two.* Now Put a grid in each containerCREATE OBJECT ob_grid1EXPORTINGi_parent = ob_split1->top_left_container.CREATE OBJECT ob_grid2EXPORTINGi_parent = ob_split2->top_left_container.CREATE OBJECT ob_grid3EXPORTINGi_parent = ob_split2->bottom_right_container.CALL METHOD ob_grid1->set_table_for_first_displayEXPORTINGi_structure_name = 'SCARR'CHANGINGit_outtab = it_scarr.CALL METHOD ob_grid2->set_table_for_first_displayEXPORTINGi_structure_name = 'SCARR'CHANGINGit_outtab = it_scarr.CALL METHOD ob_grid3->set_table_for_first_displayEXPORTINGi_structure_name = 'SCARR'CHANGINGit_outtab = it_scarr.ENDMODULE. " status_0100 OUTPUT*&---------------------------------------------------------------------**& Module user_command_0100 INPUT*&---------------------------------------------------------------------*MODULE user_command_0100 INPUT.IF sy-ucomm = 'BACK' OR sy-ucomm = 'EXIT' .FREE : ob_grid1 ,ob_grid2 ,ob_grid3 ,ob_split1 ,ob_split2 ,ob_custom .LEAVE TO SCREEN 0 .ENDIF.ENDMODULE. " user_command_0100 INPUT