You are on page 1of 12

19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

Community
Follow

 Do you have an S- or P- account? 


 Like
If so, you need SAP Universal ID. In a few months, SAP Universal
Get started with SAP Universal ID
ID will be the only option to login to SAP Community. Without it,
RSS
you will lose your content and badges. Ifyou Feed
have multiple
accounts, use the Consolidation Tool to merge your content.

Ask a Question Write a Blog Post Login

Former Member
May 24, 2012 | 6 minute read

Displaying ALV in Splitter Container with


heading using OOABAP
 4  11  56,146

Author: Avinash Palavai, SAP Technical Consultant, Atos India Pvt. Ltd.

Introduction:

      Splitter Container can be used to display data either from two or more tables or from a
single table based on particular conditions in ALV format using a single container at a time.

The classes that are used for achieving this are as follows,

1. CL_GUI_CUSTOM_CONTAINER .

2. CL_GUI_SPLITTER_CONTAINER .

3. CL_GUI_CONTAINER .

4. CL_GUI_ALV_GRID .

5. CL_DD_DOCUMENT.

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 1/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

Procedure:

1. First we have to design a modulepool screen (Screen No.100 ) with two custom controls,
each for ALV and Heading as below,

2. Name the first control as “HEADING”.

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 2/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

3. Name the second control as “MAIN_CONT”.

4. Save and activate the screen.

5. Do the below coding in the report program.

6. Here i took a case of displaying the material details of a particular material type ‘ZSEM’, in
the parent split alv list and                        the descriptions of those materials that are listed in
parent split alv in child split alv.

7. The heading being maintained for this ALV is ‘Material Master Report’.

************************************Coding****************************************
**

*REPORT  ZOOALV_WITH_SPLITTER.

DATA : O_CC TYPE REF TO CL_GUI_CUSTOM_CONTAINER .

DATA : O_SC TYPE REF TO CL_GUI_SPLITTER_CONTAINER .

DATA : O_PART1 TYPE REF TO  CL_GUI_CONTAINER .

DATA : O_PART2 TYPE REF TO  CL_GUI_CONTAINER .

DATA : ALV_GRID1 TYPE REF TO CL_GUI_ALV_GRID .

DATA : ALV_GRID2 TYPE REF TO CL_GUI_ALV_GRID .

DATA : I_MARA TYPE TABLE OF MARA .

DATA : I_MAKT TYPE TABLE OF MAKT .

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 3/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

DATA : DD TYPE REF TO CL_DD_DOCUMENT.

   START-OF-SELECTION .

   call SCREEN 100.

*&———————————————————————*

*&      Module  STATUS_0100  OUTPUT

*&———————————————————————*

*       text

*———————————————————————-*

MODULE STATUS_0100 OUTPUT.

*  SET PF-STATUS ‘xxxxxxxx’.

*  SET TITLEBAR ‘xxx’.

   PERFORM create_objects.

   PERFORM spli_main_cont .

   PERFORM DISP_HEADING.

   PERFORM disp_alv1 .

   PERFORM disp_alv2 .

ENDMODULE.                 ” STATUS_0100  OUTPUT

*&———————————————————————*

*&      Form  CREATE_OBJECTS

*&———————————————————————*

*       text

*———————————————————————-*

*  –>  p1        text

*  <–  p2        text

*———————————————————————-*

FORM CREATE_OBJECTS .

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 4/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

   CREATE OBJECT O_CC

     EXPORTING

       CONTAINER_NAME = ‘MAIN_CONT’.

  CREATE OBJECT DD

*  EXPORTING

*    STYLE  =

*    BACKGROUND_COLOR =

*    BDS_STYLESHEET =

*    NO_MARGINS =

. ENDFORM.                    ” CREATE_OBJECTS

*&———————————————————————*

*&      Form  SPLI_MAIN_CONT

*&———————————————————————*

*       text

*———————————————————————-*

*  –>  p1        text

*  <–  p2        text

*———————————————————————-*

FORM SPLI_MAIN_CONT .

   CREATE OBJECT O_SC

     EXPORTING

       PARENT  = O_CC

       ROWS    = 2

       COLUMNS = 1.

   CALL METHOD O_SC->GET_CONTAINER

     EXPORTING

       ROW       = 1

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 5/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

       COLUMN    = 1

     RECEIVING

       CONTAINER = O_PART1.

   CALL METHOD O_SC->GET_CONTAINER

     EXPORTING

       ROW       = 2

       COLUMN    = 1

     RECEIVING

       CONTAINER = O_PART2.

ENDFORM.                    ” SPLI_MAIN_CONT

*&———————————————————————*

*&      Form  DISP_ALV1

*&———————————————————————*

*       text

*———————————————————————-*

*  –>  p1        text

*  <–  p2        text

*———————————————————————-*

FORM DISP_ALV1 .

   CREATE OBJECT ALV_GRID1

     EXPORTING

       I_PARENT = O_PART1.

   SELECT * FROM MARA

      INTO TABLE I_MARA “UP TO 100 ROWS.

         WHERE MTART = ‘ZSEM’ .

     SORT I_MARA BY MATNR ASCENDING.

   CALL METHOD ALV_GRID1->SET_TABLE_FOR_FIRST_DISPLAY

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 6/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

     EXPORTING

       I_STRUCTURE_NAME = ‘MARA’

     CHANGING

       IT_OUTTAB        = I_MARA.

ENDFORM .                                                   “DISP_ALV1

*&———————————————————————*

*&      Form  DISP_ALV2

*&———————————————————————*

*       text

*———————————————————————-*

*  –>  p1        text

*  <–  p2        text

*———————————————————————-*

FORM DISP_ALV2 .

   CREATE OBJECT ALV_GRID2

     EXPORTING

       I_PARENT = O_PART2.

   SELECT * FROM MAKT

      INTO TABLE I_MAKT

      FOR ALL ENTRIES IN I_MARA

       WHERE MATNR = I_MARA–MATNR.

     DELETE ADJACENT DUPLICATES FROM I_MAKT COMPARING MATNR.

   CALL METHOD ALV_GRID2->SET_TABLE_FOR_FIRST_DISPLAY

     EXPORTING

       I_STRUCTURE_NAME = ‘MAKT’

     CHANGING

       IT_OUTTAB        = I_MAKT.

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 7/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

ENDFORM.                                                    ” DISP_ALV2

*&———————————————————————*

*&      Form  DISP_HEADING

*&———————————————————————*

*       text

*———————————————————————-*

*  –>  p1        text

*  <–  p2        text

*———————————————————————-*

form DISP_HEADING .

      DATA : HEAD TYPE  SDYDO_ATTRIBUTE .

HEAD = CL_DD_DOCUMENT=>HEADING .

CALL METHOD DD->ADD_TEXT

   EXPORTING

     TEXT          = ‘MATERIAL MASTER REPORT’

     SAP_STYLE     = HEAD .

CALL METHOD DD->DISPLAY_DOCUMENT

    EXPORTING

      CONTAINER          = ‘HEADING’.

ENDFORM.                    ” DISP_HEADING

8. Save  and activate the entire program. Execute (F8),

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 8/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

9. The result clearly illustrates the purpose and advantage of displaying the ALV in Splitter
Container.

Alert Moderator

Assigned Tags

ABAP Development

abap

abap objects

alv

ooabap

ooalv

Similar Blog Posts 


Table Subforms header repeat for subsequent pages
By Sreeram Kumar Madisetty Jul 01, 2022

Refresh of CL_SALV_TREE
By Matthew Billingham Aug 06, 2021

ALV Grid With Multiple Header Lines

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 9/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

By Enno Wulff Sep 08, 2020

Related Questions 
Create Dynamic Container
By Furkan Kızılarslan Mar 29, 2022

Displying alv list in right format .


By Former Member Oct 03, 2011

HOW TO DISPLAY MULTIPLE ALV IN SINGLE SCREEN?


By sahas teja Dec 04, 2018

4 Comments

Comments are closed.

Former Member
May 24, 2012 at 9:39 pm

I got a syntax error for the line:

    heading = cl_dd_document=>heading .

Rob

Like 0 | Share

Former Member | Blog Post Author


May 24, 2012 at 10:09 pm

Hello Rob,

Updated the code.

DATA : HEAD TYPE  SDYDO_ATTRIBUTE .

HEAD = CL_DD_DOCUMENT=>HEADING .

Thanks ...

Like 0 | Share

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 10/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

Wolfgang Dörner
May 25, 2012 at 6:23 am

Hey!

You can show 2 ALVs on a dynpro much easier:

Create a dynpro (no custom control needed in the example below this is "2000").

Then you can add following code. Here new SALV-Model (cl_salv_table) is used. If you want you can add one more row to the
splitter-container and then put your header document in it.

"creating docking container as parent for splitter, setting up on empty dynpro


     create object lo_dck_cont
       exporting
         repid     = sy-repid
         dynnr     = '2000'
         side      = cl_gui_docking_container=>dock_at_top
         extension = 2000                                    "ratio = 95
         style     = cl_gui_control=>ws_child.

     "create splitter on docking


     create object lo_spl_ctrl
       exporting
         parent  = lo_dck_cont
         rows    = 2
         columns = 1.

*--create salv1---------------------------*
         cl_salv_table=>factory(
           exporting      

               r_container    = lo_spl_ctrl->get_container( row = 1 column = 1 )   


           importing
             r_salv_table   = lo_alv1

           changing
             t_table        = lt_data2
         ).

*--create salv2---------------------------*
         cl_salv_table=>factory(
           exporting

               r_container    = lo_spl_ctrl->get_container( row = 2 column = 1 )   


           importing
             r_salv_table   = lo_alv2
           changing
             t_table        = lt_data2
         ).

*--show---------------------------*

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 11/12
19/7/23, 9:08 Displaying ALV in Splitter Container with heading using OOABAP | SAP Blogs

lo_alv1->display( ).

lo_alv2->display( ).

Like 0 | Share

Vinod Kumar
May 26, 2012 at 5:31 am

All known OO (S)ALV scenarios are well explained in the blog Against All Odds - Programming of Communicating (S)ALV Grid
Controls written by Uwe Schieferstein way back in 2010.

Unfortunately the source code mentioned in the blog seems to be unformatted after migration to new SCN. (may be due to
different formatting options)

Regards, Vinod

Like 0 | Share

Find us on

Privacy Terms of Use

Legal Disclosure Copyright

Trademark Preferencias sobre cookies

Newsletter Support

https://blogs.sap.com/2012/05/24/displaying-alv-in-splitter-container-with-heading-using-ooabap/ 12/12

You might also like