Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Intearactive alv using oops

Hi,

I have done an alv grid program using oops (like creating a container,grid into it ,calling a method etc).

Now can any one of you help me in creating the interactive for it to call MM03 screen,as i am new to this concept.

Regards,

Silpa.M

Former Member
Former Member replied

Hi Silpa,

In Interactive ALV, we have to explicitly handel the events. So we have to create a local class and in that we have to handel each event seperately. so i have created a local class EVENT_HANDEL and handeled the event DOUBLE_CLICK.

Container Object creation should be done in the PBO Of the screen, Now i have done the changes in the below code just check it.

Hope it will solve your problem.

Regards

Kumar M


DATA : GT_VBAK       TYPE TABLE OF VBAK,
       WA_VBAK       TYPE VBAK.

DATA : GT_FCAT       TYPE TABLE OF LVC_S_FCAT WITH HEADER LINE.
DATA : MY_CONTAINER  TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
DATA : GRID          TYPE REF TO CL_GUI_ALV_GRID.

*****************************************************************************************
* FOR HANDELING EVENTS WE HAVE TO RAISE THE EVENTS WITH LOCAL CLASS AND SET HANDELERS
*****************************************************************************************
CLASS EVENT_HANDEL DEFINITION.
  PUBLIC SECTION.
    METHODS : DB_CLICK FOR EVENT DOUBLE_CLICK  OF CL_GUI_ALV_GRID
                           IMPORTING E_ROW
                                     E_COLUMN.
ENDCLASS.                    "EVENT_HANDEL DEFINITION

*----------------------------------------------------------------------*
*       CLASS EVENT_HANDEL IMPLEMENTATION
*----------------------------------------------------------------------*
*
*----------------------------------------------------------------------*
CLASS EVENT_HANDEL IMPLEMENTATION.
  METHOD DB_CLICK.
    READ TABLE GT_VBAK INTO WA_VBAK INDEX E_ROW-INDEX.
    IF SY-SUBRC EQ 0.
      SET PARAMETER ID 'AUN' FIELD WA_VBAK-VBELN.
      CALL TRANSACTION 'VA03' AND SKIP FIRST SCREEN.
    ENDIF.
  ENDMETHOD.                    "DB_CLICK
ENDCLASS.                    "EVENT_HANDEL IMPLEMENTATION
DATA : EVENTS        TYPE REF TO EVENT_HANDEL.

START-OF-SELECTION.



  CALL SCREEN 200.

*&---------------------------------------------------------------------*
*&      Form  F_GET_DATA
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
*  -->  p1        text
*  <--  p2        text
*----------------------------------------------------------------------*
FORM F_GET_DATA .

  SELECT * FROM VBAK INTO TABLE GT_VBAK
           UP TO 30 ROWS.

  CREATE OBJECT EVENTS.
  IF GRID IS INITIAL.
    CREATE OBJECT MY_CONTAINER
        EXPORTING
          CONTAINER_NAME              = 'CC1'
         EXCEPTIONS
          CNTL_ERROR                  = 1
          CNTL_SYSTEM_ERROR           = 2
          CREATE_ERROR                = 3
          LIFETIME_ERROR              = 4
          LIFETIME_DYNPRO_DYNPRO_LINK = 5
          OTHERS                      = 6.

    CREATE OBJECT GRID
      EXPORTING
        I_PARENT          =  MY_CONTAINER
       EXCEPTIONS
         ERROR_CNTL_CREATE = 1
         ERROR_CNTL_INIT   = 2
         ERROR_CNTL_LINK   = 3
         ERROR_DP_CREATE   = 4
         OTHERS            = 5.
    SET HANDLER : EVENTS->DB_CLICK   FOR GRID.
    CALL METHOD GRID->SET_TABLE_FOR_FIRST_DISPLAY
      EXPORTING
        I_STRUCTURE_NAME              = 'VBAK'
      CHANGING
        IT_OUTTAB                     = GT_VBAK
      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.
  ENDIF.
ENDFORM.                    " F_GET_DATA
*&---------------------------------------------------------------------*
*&      Module  STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE STATUS_0200 OUTPUT.
  SET PF-STATUS 'ZINTERACTIVE'.
  PERFORM F_GET_DATA.
ENDMODULE.                 " STATUS_0200  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0200  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0200 INPUT.

  CASE SY-UCOMM.
    WHEN 'BACK'.
      SET SCREEN 0.
      LEAVE SCREEN.
    WHEN 'CANCEL'.
      LEAVE PROGRAM.
  ENDCASE.

ENDMODULE.                 " USER_COMMAND_0200  INPUT

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question