headershadow

Displaying ALV in Splitter Container with heading using ABAP OO

Print Friendly

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.

Procedure:

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

  1. Name the first control as "HEADING".
  2. Name the second control as "MAIN_CONT".
  3. Save and activate the screen.
  4. Do the below coding in the report program.
  5. 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.
  6. 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 .
    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
    * p1 text
    * GET_CONTAINER
    EXPORTING
    ROW = 1
    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
    * SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    I_STRUCTURE_NAME = 'MARA'
    CHANGING
    IT_OUTTAB = I_MARA.
    ENDFORM . "DISP_ALV1

    *&---------------------------------------------------------------------*
    *& Form DISP_ALV2
    *&---------------------------------------------------------------------*
    * text
    *----------------------------------------------------------------------*
    * --> p1 text
    * SET_TABLE_FOR_FIRST_DISPLAY
    EXPORTING
    I_STRUCTURE_NAME = 'MAKT'
    CHANGING
    IT_OUTTAB = I_MAKT.

    ENDFORM. " DISP_ALV2

    *&---------------------------------------------------------------------*
    *& Form DISP_HEADING
    *&---------------------------------------------------------------------*
    * text
    *----------------------------------------------------------------------*
    * --> p1 text
    * HEADING .
    CALL METHOD DD->ADD_TEXT
    EXPORTING
    TEXT = 'MATERIAL MASTER REPORT'
    SAP_STYLE = HEAD .

    CALL METHOD DD->DISPLAY_DOCUMENT
    EXPORTING
    CONTAINER = 'HEADING'.
    ENDFORM. " DISP_LOGO

  7. Save and activate the entire program. Execute (F8),
  8. The result clearly illustrates the purpose and advantage of displaying the ALV in Splitter Container.

Avinash Palavai, SAP Technical Consultant, StraVis IT Solutions.
More about

6 thoughts on “Displaying ALV in Splitter Container with heading using ABAP OO


Comment author said

By MOHIT on 26 November 2013 at 11:49

Kindly review he code you hav given.. will it work in any case.. waiting for the updated one..

 

Comment author said

By Avinash Palavai on 27 November 2013 at 04:23

That is a working code, and will work....

 

Comment author said

By Rafa on 18 December 2013 at 20:18

No working code. Please update.

 

Comment author said

By Kartik on 29 December 2015 at 15:32

Not Working,just tried it

 

Comment author said

By Vetrivel on 7 April 2017 at 08:53

Not working please try it now.

 

Comment author said

By Sivananda on 8 April 2018 at 18:42

Hiii i want to split the 2nd row of that container again 2 parts ie 2 columns. Pls tell me how can I write.

 

Leave a Reply


*