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

Classes in ALV

Former Member
0 Likes
675

Hello Everyone ,

I am developing an oops alv , i need some help like in the output list if i select particular row and press a push button it has to do some operation.

Is there any Method which captures the selected row by the user.

Thanks,

Srinu.

Hello Everyone ,

I am developing an oops alv , i need some help like in the output list if i select particular row and press a push button it has to do some operation.

Is there any Method which captures the selected row by the user.

Thanks,

Srinu.

4 REPLIES 4
Read only

Former Member
0 Likes
650

Hi Vaasu,

check the code below.....

Use GET_SELECTED_ROWS method to get the selected row...

*----------------------------------------------------------------------*
*       CLASS lcl_event_handler DEFINITION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler DEFINITION.
  PUBLIC SECTION.
    DATA: wa_toolbar   TYPE stb_button,
          utilities    TYPE REF   TO cl_gui_frontend_services.
    METHODS : toolbar_handle FOR EVENT toolbar      OF cl_gui_alv_grid
                                    IMPORTING e_object
                                              e_interactive,
              ucomm_handle   FOR EVENT user_command OF cl_gui_alv_grid
                                    IMPORTING e_ucomm.
ENDCLASS.                    "lcl_event_handler DEFINITION

*----------------------------------------------------------------------*
*       CLASS lcl_event_handler IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS lcl_event_handler IMPLEMENTATION.
  METHOD toolbar_handle.
    MOVE   3 TO  wa_toolbar-butn_type.
    APPEND wa_toolbar   TO e_object->mt_toolbar.
    MOVE : 0            TO wa_toolbar-butn_type,
           '$PUSH'      TO wa_toolbar-function,
           '@0V@'       TO wa_toolbar-icon.
    APPEND wa_toolbar TO e_object->mt_toolbar.
  ENDMETHOD. "toolbar_handle

  METHOD ucomm_handle.
    CHECK e_ucomm EQ '$PUSH'.
    PERFORM on_push_button_click.
  ENDMETHOD. "ucomm_handle
ENDCLASS.                    "lcl_event_handler IMPLEMENTATION

DATA : container    TYPE REF   TO cl_gui_custom_container,
       grid         TYPE REF   TO cl_gui_alv_grid,
       event        TYPE REF   TO lcl_event_handler,
       it_display   TYPE TABLE OF mara,
       wa_display   TYPE mara.

START-OF-SELECTION.

  CALL SCREEN 100.

*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'BASIC'.
  PERFORM build_it_display.
  PERFORM create_objects.


ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.

  CASE sy-ucomm.
    WHEN 'BACK'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'EXIT'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'CANC'.
      SET SCREEN 0.
      LEAVE SCREEN.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*&      Form  build_it_display
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM build_it_display .
  SELECT * FROM mara UP TO 15 ROWS INTO TABLE it_display.
ENDFORM.                    " build_it_display
*&---------------------------------------------------------------------*
*&      Form  create_objects
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM create_objects .
  IF container IS INITIAL.
    CREATE OBJECT container
    EXPORTING
      container_name     = 'CUSTOM'.
    CREATE OBJECT event.
    CREATE OBJECT grid
      EXPORTING
        i_parent         = container.
    SET HANDLER event->toolbar_handle FOR grid.
    SET HANDLER event->ucomm_handle   FOR grid.
    CALL METHOD grid->set_table_for_first_display
      EXPORTING
        i_structure_name = 'MARA'
      CHANGING
        it_outtab        = it_display.
  ENDIF.
ENDFORM.                    " create_objects

*&--------------------------------------------------------------------*
*&      Form  on_push_button_click
*&--------------------------------------------------------------------*
*       text
*---------------------------------------------------------------------*
FORM on_push_button_click.
  BREAK-POINT.   " can be used to process the selected row
ENDFORM.                    "on_push_button_click

Cheers,

Jose.

Read only

Former Member
0 Likes
650

Hi Srinu,

This is the link where you can get the complete programe.

http://abapreports.blogspot.com/2008/06/oops-alv-sample-interactive-report.html

Please check this Method CALL METHOD W_GRID->GET_CURRENT_CELL

Cheers

Mohinder Singh Chauhan

Read only

Former Member
0 Likes
650

Hi Vaasu,

Refer to the following link for sample code.

http://saptechnical.com/Tutorials/ALV/Interactive/oops.htm

Jaya Vani

Read only

Former Member
0 Likes
650