Skip to Content
author's profile photo Former Member
Former Member

Call a method within the event on_user_command from alv oo

Hi,

I have one class for manage all the actions of my report also i add the events methods for my alv, the on_user_command but my problem is when i call a event on the alv grid. i can catch the event but i can't call any method of my class.

Can anyone help me ?

Thank you in advance.

MIguel Silva

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 05:06 AM

    Hi,

    I am Posting The code Which I Got Correct Output Using Events.

    *& Report  ZALVGRID_PG PAVAN
    *&PAVAN
    *&---------------------------------------------------------------------*
    *&
    *&
    *&---------------------------------------------------------------------*
    
    REPORT  ZALVGRID_PG.
    TABLES: SSCRFIELDS.
    
    DATA: V_BELNR TYPE RBKP-BELNR.
    
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: IRNO FOR V_BELNR.
    PARAMETERS: P_GJAHR TYPE RBKP-GJAHR.
    SELECTION-SCREEN END OF BLOCK B1.
    
    DATA: WA TYPE ZALVGRID_DISPLAY,
          ITAB TYPE STANDARD TABLE OF ZALVGRID_DISPLAY.
    
    DATA: IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    
    DATA: GRID TYPE REF TO CL_GUI_ALV_GRID.
    
    DATA: L_IDENTITY TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
    
    DATA: L_TREE TYPE REF TO CL_GUI_ALV_TREE_SIMPLE.
    
    TYPE-POOLS: SLIS,SDYDO.
    
    DATA: L_LOGO TYPE SDYDO_VALUE,
          L_LIST TYPE SLIS_T_LISTHEADER.
    
    END-OF-SELECTION.
    
    
    CLASS CL_LC DEFINITION.
      PUBLIC SECTION.
        METHODS: DC FOR EVENT DOUBLE_CLICK OF CL_GUI_ALV_GRID IMPORTING E_ROW E_COLUMN.
    ENDCLASS.
    
    CLASS CL_LC IMPLEMENTATION.
      METHOD DC.
        DATA: WA1 TYPE ZALVGRID_DISPLAY.
        READ TABLE ITAB INTO WA1 INDEX E_ROW-INDEX.
        BREAK-POINT.
        SET PARAMETER ID 'BLN' FIELD WA1-BELNR.
        CALL TRANSACTION 'FB02'.
      ENDMETHOD.                    "DC
    ENDCLASS.
    
    
    
    DATA: OBJ_CL TYPE REF TO CL_LC.
    
    START-OF-SELECTION.
      PERFORM SELECT_DATA.
      IF SY-SUBRC = 0.
        CALL SCREEN 100.
    
      ELSE.
        MESSAGE E000(0) WITH 'DATA NOT FOUND'.
      ENDIF.
    
    
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'AB'.
    *  SET TITLEBAR 'xxx'.
    
      IF IDENTITY IS INITIAL.
        CREATE OBJECT IDENTITY
        EXPORTING
          CONTAINER_NAME = 'ALVCONTROL'.
        CREATE OBJECT GRID
        EXPORTING
          I_PARENT = IDENTITY.
    
        CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
    *        I_BUFFER_ACTIVE               =
    *        I_BYPASSING_BUFFER            =
    *        I_CONSISTENCY_CHECK           =
             I_STRUCTURE_NAME              = 'ZALVGRID_DISPLAY'
    *
    *        IS_VARIANT                    =
    *        I_SAVE                        =
    *        I_DEFAULT                     = 'X'
    *        IS_LAYOUT                     =
    *        IS_PRINT                      =
    *        IT_SPECIAL_GROUPS             =
    *        IT_TOOLBAR_EXCLUDING          =
    *        IT_HYPERLINK                  =
    *        IT_ALV_GRAPHICS               =
    *        IT_EXCEPT_QINFO               =
    *        IR_SALV_ADAPTER               =
          CHANGING
            IT_OUTTAB                     = ITAB.
    *        IT_FIELDCATALOG               =
    *        IT_SORT                       =
    *        IT_FILTER                     =
    *      EXCEPTIONS
    *        INVALID_PARAMETER_COMBINATION = 1
    *        PROGRAM_ERROR                 = 2
    *        TOO_MANY_LINES                = 3
    *        others                        = 4
                .
        IF SY-SUBRC <> 0.
    *     MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *                WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
        ENDIF.
        CREATE OBJECT OBJ_CL.
        SET HANDLER OBJ_CL->DC FOR GRID.
        ENDIF.
    
        IF L_IDENTITY IS INITIAL.
          CREATE OBJECT L_IDENTITY
          EXPORTING
            CONTAINER_NAME = 'LOGO'
            .
          CREATE OBJECT L_TREE
          EXPORTING
            I_PARENT = L_IDENTITY.
    
          PERFORM LOGOSUB USING L_LOGO.
          CALL METHOD L_TREE->CREATE_REPORT_HEADER
            EXPORTING
              IT_LIST_COMMENTARY    = L_LIST
              I_LOGO                = L_LOGO.
    
    *          I_BACKGROUND_ID       =
    *          I_SET_SPLITTER_HEIGHT =
    *          I_MODEL_MODE          =
          ENDIF    .
    
    
    
    ENDMODULE.                 " STATUS_0100  OUTPUT
    
    
    FORM LOGOSUB  USING    P_L_LOGO.
      P_L_LOGO = 'ERPLOGO'.
    
    ENDFORM.                    " LOGOSUB
    
    FORM SELECT_DATA .
    
      SELECT RBKP~BELNR
             RBKP~BLDAT
             RSEG~BUZEI
             RSEG~MATNR
             INTO TABLE ITAB
             FROM RBKP INNER JOIN RSEG
        ON RBKP~BELNR = RSEG~BELNR
        WHERE RBKP~BELNR IN IRNO
        AND RBKP~GJAHR = P_GJAHR.
    
    ENDFORM.                    " SELECT_DATA
    
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'EXIT'.
          LEAVE PROGRAM.
        WHEN 'CANCEL'.
           EXIT.
           ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    

    This Will Be the Perfect Example It will Cover All the Events like Double Click And Alv Usage Also.

    WarmRegards,

    PavanKumar.G

    Edited by: Neil Gardiner on Dec 13, 2011 4:08 PM

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 28, 2011 at 01:14 PM

    Please post the coding of your event handler...

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 13, 2011 at 11:04 AM

    Thank you for all replies,

    The problem is already solved.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.