Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

CL_GUI_ALV_GRID?

Former Member
0 Likes
2,761

What is CL_GUI_ALV_GRID? What is the need of this class?

3 REPLIES 3
Read only

Former Member
0 Likes
1,879

Check program BCALV_GRID_DEMO to see what you can do with it.

(in se83 -> ALV Grid Control)

it allows you to display list easily and with lots of functionality

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,879

Hello Ajay

Function module based ALV lists can be easily generated using:

- REUSE_ALV_LIST_DISPLAY

- REUSE_ALV_GRID_DISPLAY

- REUSE_ALV_GRID_DISPLAY_LVC

The last function module uses already many DDIC objects that are required for OO-based ALV lists, too.

Class <b>CL_GUI_ALV_GRID</b> is used for <b>OO-based</b> ALV lists which are much easier to develop and enhance then FM-based ALV lists.

I have posted several simplified OO-based ALV lists in the <i>ABAP Objects</i> forum (search for <b>ZUS_SDN</b>).

Finally, the most up-to-date version of OO-based ALV lists uses class <b>CL_SALV_TABLE</b> (SAP release >= 6.40). For more details please refer to:

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/eac1fa0b-0e01-0010-0990-8530de4908a6">ALV Object Model - Simple 2D Table - The Basics</a>

<a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cda3992d-0e01-0010-90b2-c4e1f899ac01">ALV Object Model - Simple 2D Table - Event Handling</a>

Regards

Uwe

Read only

Former Member
1,879

Hi, Ajay!

The class CL_GUI_ALV_GRID is the best way to crate an ALV. You do it by using ABAP Objects, which give you more efficiency and more simply management.

The best way to be involved with this class is with a simple example. You can find a lot in the literature, but I think the document will help you better is this: <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e8a1d690-0201-0010-b7ad-d9719a415907">An Easy Reference For ALV Grid Control</a>.

There you will find who to create an ALV, how to interact with the ALV handling events,... You have the chance to eliminate buttons you don't want to appear in the ALV and you also can create new ones.

If you want the code, 'BCALV_TEST_GRID_PERFORMANCE' report is a good first step, but I advise you to do it by yourself! You only need a container to the ALV in a dynpro ('CL_GUI_CUSTOM_CONTAINER' is the most used in these cases), and a table with data to pass to the method 'SET_TABLE_FOR_FIRST_DISPLAY'. You also have to pass the "LAYOUT" to give the ALV properies, and the "FIELDCATALOG" to give the different columns properties. Something like this:

data: begin of mt_outtab occurs 0.
      include structure sflight.
data: end of mt_outtab.

data: custom_container type ref to cl_gui_custom_container,
      grid1            type ref to cl_gui_alv_grid.

  if custom_container is initial.
    create object custom_container
        exporting
            container_name = 'CUSTOM_CONTAINER'.
  endif.

  if grid1 is initial.
    create object grid1
          exporting i_parent = custom_container.
  endif.

  perform set_layout.
  perform set_fieldcatalog.
  perform set_data.

  call method grid1->set_table_for_first_display
    exporting
      is_layout       = ms_layout
    changing
      it_fieldcatalog = sflight_fieldcata[]
      it_outtab       = mt_outtab[].

Only with this you will have an ALV with a lot of functionalities!

After doing that you can start trying to handle events.

DATA: event_receiver TYPE REF TO lcl_event_receiver.

*---------------------------------------------------------------------*
*       CLASS lcl_event_receiver DEFINITION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver DEFINITION.

  PUBLIC SECTION.
    METHODS: handle_input FOR EVENT double_click OF cl_gui_alv_grid
                                     IMPORTING e_row.

ENDCLASS.                    "lcl_event_receiver DEFINITION

*---------------------------------------------------------------------*
*       CLASS LCL_EVENT_RECEIVER IMPLEMENTATION
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
CLASS lcl_event_receiver IMPLEMENTATION.

  METHOD handle_input.

    CLEAR mt_outtab.
    READ TABLE mt_outtab INDEX e_row-index.
*   And now you have the selected row in the ALV...

  ENDMETHOD.                    "handle_info

ENDCLASS.                    "LCL_EVENT_RECEIVER IMPLEMENTATION

Don't forget to create the instance to the object that captures the events and to set which events will capture:

CREATE OBJECT event_receiver.

SET HANDLER event_receiver->handle_info FOR grid1.

Then you can start using other event 'CL_GUI_ALV_GRID' allows you (you can find these in Tcode 'SE24'), or eliminate buttons to add your own ones... It's really easy if you read the document "An Easy Reference For ALV Grid Control".

Hopping it will help you,

Sergio