Disbable button on alv report using oops

Hi all,
I have a button to toll bar of alv grid using oops
based on that when the user clicks on that some action is performed and list is displayed again
now when the list is diaplyed i need the button that i added to be disabled so that the user cannot click it agin
i have everything i don't know how to disable the button.
USING THIS STATMENT  move 'X' to ls_toolbar-disabled WE CAN DISABLE BUT I DON'T WHERE TO PASS IT..
LOCAL CLASSES: Definition
*===============================================================
class lcl_event_receiver: local class to
                        define and handle own functions.
Definition:
~~~~~~~~~~~
class lcl_event_receiver definition.
  public section.
    methods:
    handle_toolbar
        for event toolbar of cl_gui_alv_grid
            importing e_object e_interactive,
    handle_user_command
        for event user_command of cl_gui_alv_grid
            importing e_ucomm.
  private section.
endclass.
lcl_event_receiver (Definition)
*===============================================================
LOCAL CLASSES: Implementation
*===============================================================
class lcl_event_receiver (Implementation)
class lcl_event_receiver implementation.
  method handle_toolbar.
append a separator to normal toolbar
    clear ls_toolbar.
    move 3 to ls_toolbar-butn_type.
    append ls_toolbar to e_object->mt_toolbar.
append an icon to show booking table
    clear ls_toolbar.
    move 'ADD' to ls_toolbar-function.
    move icon_employee to ls_toolbar-icon.
    move 'Show Bookings'(111) to ls_toolbar-quickinfo.
    move 'Add Material'(112) to ls_toolbar-text.
    move '' to ls_toolbar-disabled.
    append ls_toolbar to e_object->mt_toolbar.
  endmethod.
  method handle_user_command.
    case e_ucomm.
      when 'ADD'.
        call method g_grid->get_selected_rows
                 importing et_index_rows = lt_rows.
        call method cl_gui_cfw=>flush.
        if sy-subrc ne 0.
add your handling, for example
         call function 'POPUP_TO_INFORM'
              exporting
                   titel = g_repid
                   txt2  = sy-subrc
                   txt1  = 'Error in Flush'(500).
        else.
*tHIS IS THE PART IAM HAVING PROBLEM WITH
*class lcl_event_receiver implementation.
method handle_toolbar.
*clear : ls_toolbar.
loop at e_object->mt_toolbar into ls_toolbar WHERE FUNCTION = 'ADD'.
DELETE e_object->mt_toolbar FROM ls_toolbar.
move ' ' to ls_toolbar-disabled.
append ls_toolbar to e_object->mt_toolbar.
endloop.
*ENDMETHOD.
*ENDCLASS.
***tHIS IS THE PART
  call method g_grid->refresh_table_display.
        endif.
    endcase.
  endmethod.
Thanks in advance

Hi
hI ALL,
MY QUESTION IS WHEN method handle_toolbaR WOULD BE TRIGERRED
first time i have the button enabled and when i press the button its get disabled.This is what i need
But iam trying to understand how this is working
Let me know whether iam right or not
when this piece of code would be triggered
method handle_toolbar.
    clear ls_toolbar.
    move 3 to ls_toolbar-butn_type.
    append ls_toolbar to e_object->mt_toolbar.
    clear ls_toolbar.
    move 'ADD' to ls_toolbar-function.
    move icon_employee to ls_toolbar-icon.
    move 'Show Bookings'(111) to ls_toolbar-quickinfo.
    move 'Add Material'(112) to ls_toolbar-text.
    move ' ' to ls_toolbar-disabled.
    append ls_toolbar to e_object->mt_toolbar.
    IF FLAG = 'X'.
    LOOP AT e_object->mt_toolbar INTO ls_toolbar.
   if ls_toolbar-function = 'ADD'.
   ls_toolbar-disabled = 'X'.
   MODIFY e_object->mt_toolbar FROM ls_toolbar.
   endif.
   ENDLOOP.
    ENDIF.
1 ) would this be triggered
when i call this  call method g_grid->refresh_table_display.
2)or
call method g_grid->set_toolbar_interactive
This is my piece of code
class lcl_event_receiver definition.
  public section.
    methods:
    handle_toolbar
        for event toolbar of cl_gui_alv_grid
            importing e_object e_interactive,
    handle_user_command
        for event user_command of cl_gui_alv_grid
            importing e_ucomm.
  private section.
endclass.
class lcl_event_receiver implementation.
  method handle_toolbar.
    clear ls_toolbar.
    move 3 to ls_toolbar-butn_type.
    append ls_toolbar to e_object->mt_toolbar.
    clear ls_toolbar.
    move 'ADD' to ls_toolbar-function.
    move icon_employee to ls_toolbar-icon.
    move 'Show Bookings'(111) to ls_toolbar-quickinfo.
    move 'Add Material'(112) to ls_toolbar-text.
    move ' ' to ls_toolbar-disabled.
    append ls_toolbar to e_object->mt_toolbar.
    IF FLAG = 'X'.
    LOOP AT e_object->mt_toolbar INTO ls_toolbar.
   if ls_toolbar-function = 'ADD'.
   ls_toolbar-disabled = 'X'.
   MODIFY e_object->mt_toolbar FROM ls_toolbar.
   endif.
   ENDLOOP.
    ENDIF.
  endmethod.
  method handle_user_command.
    case e_ucomm.
      when 'ADD'.
        call method g_grid->get_selected_rows
                 importing et_index_rows = lt_rows.
        call method cl_gui_cfw=>flush.
        if sy-subrc ne 0.
        else.
    perform test.
  call method g_grid->refresh_table_display.
       endif.
    endcase.
  endmethod.                           "handle_user_command
odule status_0100 output.
SET PF-STATUS 'STATUS'.
  set pf-status 'MAIN100'.
  set titlebar 'HEADER_CHECK'.
if g_custom_container is initial.
    create object g_custom_container
             exporting container_name = g_container.
    create object g_grid
               exporting i_parent = g_custom_container.
call function 'LVC_FIELDCATALOG_MERGE'
exporting
i_structure_name = 'ZTEST'
changing
ct_fieldcat = fieldcat
exceptions
others = 3
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
g_layout-sel_mode = 'A'.              " TO GET SELECTION BOX
call method g_grid->set_table_for_first_display
exporting
   I_BYPASSING_BUFFER            =
   I_BUFFER_ACTIVE               =
   I_CONSISTENCY_CHECK           =
   I_STRUCTURE_NAME              =
   IS_VARIANT                    =
   I_SAVE                        =
   I_DEFAULT                     = 'X'
     is_layout                     = g_layout
   IS_PRINT                      =
   IT_SPECIAL_GROUPS             =
    it_toolbar_excluding          = pt_exclude
   IT_HYPERLINK                  =
   IT_ALV_GRAPHICS               =
  changing
    it_outtab                     =  i_zTEST
    it_fieldcatalog               = fieldcat
   IT_SORT                       =
   IT_FILTER                     =
  exceptions
    invalid_parameter_combination = 1
    program_error                 = 2
    too_many_lines                = 3
    others                        = 4
create object event_receiver.
    set handler event_receiver->handle_user_command for g_grid.
    set handler event_receiver->handle_toolbar for g_grid.
  call method g_grid->set_toolbar_interactive.
  endif.                               "IF grid1 IS INITIAL
  call method cl_gui_control=>set_focus exporting control = g_grid.
endmodule.                 " STATUS_0100  OUTPUT
Thanks
Suchitra

Similar Messages

  • Alv report using oops ABAP

    hi friendz,
    can any one of u give an example, how to build alv report using oops abap ?
    thanks in advance.
    points for sure
    regards,
    Vijaya

    Hi Vijaya,
    I hope the following code upto your requirement.
    *& Report  ZMAT_ALV_GRID                                               *
    REPORT  ZCL_CLASS1.
    TYPES: BEGIN OF T_MARA,
             MATNR TYPE MARA-MATNR,
             MAKTX TYPE MAKT-MAKTX,
             WERKS TYPE MARD-WERKS,
             LGORT TYPE MARD-LGORT,
             LABST TYPE MARD-LABST,
           END OF T_MARA.
    *DATA: IT_MARA TYPE STANDARD TABLE OF T_MARA.
    DATA: IT_MARA TYPE T_MARA OCCURS 0.
    DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          O_GRID TYPE REF TO CL_GUI_ALV_GRID.
    DATA: X_FLDCAT TYPE LVC_S_FCAT.
    DATA: IT_FLDCAT TYPE LVC_T_FCAT.
    DATA: I_LAYOUT TYPE LVC_S_LAYO.
    DATA: X_SORT TYPE LVC_S_SORT.
    DATA: I_SORT TYPE LVC_T_SORT.
    TABLES: MARA.
    SELECT-OPTIONS: S_MATNR FOR MARA-MATNR.
    PARAMETERS: P_CHK AS CHECKBOX.
    START-OF-SELECTION.
      PERFORM GET_DATA.
      PERFORM GENERATE_FLDCAT.
      PERFORM GENERATE_LAYOUT.
      PERFORM DO_SORT.
      SET SCREEN 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
       SET PF-STATUS 'MAIN'.
    SET TITLEBAR 'xxx'.
       PERFORM BUILD_ALV.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  BUILD_ALV
          text
    FORM BUILD_ALV .
    CREATE OBJECT O_CONT
       EXPORTING
          CONTAINER_NAME              = 'MAT_CONTAINER'
       EXCEPTIONS
         CNTL_ERROR                  = 1
         CNTL_SYSTEM_ERROR           = 2
         CREATE_ERROR                = 3
         LIFETIME_ERROR              = 4
         LIFETIME_DYNPRO_DYNPRO_LINK = 5
         others                      = 6.
         CREATE OBJECT O_GRID
           EXPORTING
              I_PARENT          = O_CONT
           EXCEPTIONS
             ERROR_CNTL_CREATE = 1
             ERROR_CNTL_INIT   = 2
             ERROR_CNTL_LINK   = 3
             ERROR_DP_CREATE   = 4
             others            = 5.
    CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
       EXPORTING
       I_BUFFER_ACTIVE               =
       I_BYPASSING_BUFFER            =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
       IS_VARIANT                    =
       I_SAVE                        =
       I_DEFAULT                     = ' '
         IS_LAYOUT                     = I_LAYOUT
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
       CHANGING
         IT_OUTTAB                     = IT_MARA
         IT_FIELDCATALOG               = IT_FLDCAT[]
         IT_SORT                       = I_SORT
       IT_FILTER                     =
      EXCEPTIONS
        INVALID_PARAMETER_COMBINATION = 1
        PROGRAM_ERROR                 = 2
        TOO_MANY_LINES                = 3
        others                        = 4.
    ENDFORM.                    " BUILD_ALV
    *&      Form  GET_DATA
          text
    FORM GET_DATA .
    SELECT A~MATNR
          B~MAKTX
          C~WERKS
          C~LGORT
          C~LABST
    INTO TABLE IT_MARA
    FROM MARA AS A
    INNER JOIN MAKT AS B
    ON BMATNR = AMATNR
    INNER JOIN MARD AS C
    ON CMATNR = AMATNR
    WHERE A~MATNR IN S_MATNR
    AND   B~SPRAS = SY-LANGU.
    ENDFORM.                    " GET_DATA
    *&      Form  GENERATE_FLDCAT
          text
    FORM GENERATE_FLDCAT .
    *CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
      EXPORTING
      I_BUFFER_ACTIVE              =
       I_STRUCTURE_NAME             = 'ZSMARA'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
      I_INTERNAL_TABNAME           = ' '
    CHANGING
       CT_FIELDCAT                  = IT_FLDCAT
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3.
    X_FLDCAT-COL_POS = 1.
    X_FLDCAT-FIELDNAME = 'MATNR'.
    X_FLDCAT-OUTPUTLEN = '18'.
    X_FLDCAT-REPTEXT = 'Material No'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 2.
    X_FLDCAT-FIELDNAME = 'MAKTX'.
    X_FLDCAT-OUTPUTLEN = '48'.
    X_FLDCAT-REPTEXT = 'Material Desc'.
    X_FLDCAT-TOOLTIP = 'Material Desc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 3.
    X_FLDCAT-FIELDNAME = 'WERKS'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'Plant'.
    X_FLDCAT-TOOLTIP = 'Plant'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 4.
    X_FLDCAT-FIELDNAME = 'LGORT'.
    X_FLDCAT-OUTPUTLEN = '5'.
    X_FLDCAT-REPTEXT = 'S.Loc'.
    X_FLDCAT-TOOLTIP = 'S.Loc'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    X_FLDCAT-COL_POS = 5.
    X_FLDCAT-FIELDNAME = 'LABST'.
    X_FLDCAT-OUTPUTLEN = '20'.
    X_FLDCAT-REPTEXT = 'Quantity'.
    X_FLDCAT-TOOLTIP = 'Quantity'.
    X_FLDCAT-DO_SUM = 'X'.
    APPEND X_FLDCAT TO IT_FLDCAT.
    ENDFORM.                    " GENERATE_FLDCAT
    *&      Form  GENERATE_LAYOUT
          text
    FORM GENERATE_LAYOUT .
      I_LAYOUT-ZEBRA = 'X'.
      I_LAYOUT-FRONTEND = 'X'.
      I_LAYOUT-GRID_TITLE = 'ALV GRID USING OOPS'.
      I_LAYOUT-NUMC_TOTAL = 'X'.
    ENDFORM.                    " GENERATE_LAYOUT
    *&      Form  DO_SORT
          text
    FORM DO_SORT .
    X_SORT-FIELDNAME = 'MATNR'.
    X_SORT-UP = 'X'.
    X_SORT-SUBTOT = 'X'.
    IF P_CHK = 'X'.
       X_SORT-EXPA = SPACE.
    ELSE.
       X_SORT-EXPA = 'X'.
    ENDIF.
    APPEND X_SORT TO I_SORT.
    ENDFORM.                    " DO_SORT
    inorder to execute this code perfectly, do the following things.
    1. Create a Graphical Screen 100.
    2. Place a Custom Control on that screen and give name as MAT_CONTAINER.
    3. activate the screen.
    and execute the program.
      if this suits requirement award points.
    satish

  • ALV report using OOPS concept.

    Hi,
    Please help me in writing ALV report using OOPS concept as i have never used this concept before.Please post a clear picture for this.
    Thanks in advance.

    Hi
    Refer this code:
    REPORT zcls_alv_oops MESSAGE-ID z1.
    TABLES : mara.
    Types Declaration..\
    TYPES :
    BEGIN OF t_mara,
    matnr TYPE matnr,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_mara,
    BEGIN OF t_marc,
    matnr TYPE matnr,
    werks TYPE werks_d,
    mtart TYPE mtart,
    maktx TYPE maktx,
    END OF t_marc.
    Internal Tables Declaration..\
    DATA :
    i_mara TYPE TABLE OF t_mara,
    i_marc TYPE TABLE OF t_marc,
    i_fcat1 TYPE lvc_t_fcat,
    i_fcat2 TYPE lvc_t_fcat.
    Constants Declaration..\
    CONSTANTS :
    c_cont1 TYPE scrfname VALUE 'CONT1',
    c_cont2 TYPE scrfname VALUE 'CONT2'.
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME.
    SELECT-OPTIONS:
    s_matnr FOR mara-matnr NO INTERVALS.
    SELECTION-SCREEN SKIP 1.
    PARAMETERS :
    p_hotspt RADIOBUTTON GROUP r1 DEFAULT 'X',
    p_bttn RADIOBUTTON GROUP r1.
    SELECTION-SCREEN END OF BLOCK b1.
    \* Class forward referncing.
    CLASS lcl_rcvr_class DEFINITION DEFERRED.
    \* Pointers Declaration..
    DATA :
    lp_rcvr TYPE REF TO lcl_rcvr_class,
    lp_cont1 TYPE REF TO cl_gui_custom_container,
    lp_cont2 TYPE REF TO cl_gui_custom_container,
    lp_grid1 TYPE REF TO cl_gui_alv_grid,
    lp_grid2 TYPE REF TO cl_gui_alv_grid.
    \* Local Class Definiton.
    CLASS lcl_rcvr_class DEFINITION.
    PUBLIC SECTION.
    METHODS :
    hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
    IMPORTING e_row_id e_column_id es_row_no,
    handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
    IMPORTING e_row e_column.
    ENDCLASS.
    \* Local Class Implementation.
    CLASS lcl_rcvr_class IMPLEMENTATION.
    METHOD hotspot_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row_id-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    METHOD handle_double_click.
    DATA :
    wa_mara TYPE t_mara,
    wa_marc TYPE t_marc.
    DATA :
    l_index TYPE sy-tabix.
    READ TABLE i_mara INTO wa_mara INDEX e_row-index.
    IF sy-subrc EQ 0.
    REFRESH i_marc.
    SELECT matnr
    werks
    INTO TABLE i_marc
    FROM marc
    WHERE matnr EQ wa_mara-matnr.
    IF sy-subrc EQ 0.
    LOOP AT i_marc INTO wa_marc.
    l_index = sy-tabix.
    wa_marc-mtart = wa_mara-mtart.
    wa_marc-maktx = wa_mara-maktx.
    MODIFY i_marc FROM wa_marc INDEX l_index
    TRANSPORTING mtart maktx.
    ENDLOOP.
    CALL SCREEN 200.
    ELSE.
    MESSAGE e121 WITH text-005 wa_mara-matnr.
    ENDIF.
    ENDIF.
    ENDMETHOD.
    ENDCLASS.
    \* Start of Selection
    START-OF-SELECTION.
    \* Extract the Material Master data for the Input Material.
    SELECT a~matnr
    a~mtart
    b~maktx
    INTO TABLE i_mara
    FROM mara AS a
    INNER JOIN makt AS b
    ON a~matnr EQ b~matnr
    WHERE a~matnr IN s_matnr
    AND b~spras EQ sy-langu.
    END-OF-SELECTION.
    IF NOT i_mara\[\] IS INITIAL.
    \* Call Screen to display the Material Master data.
    CALL SCREEN 100.
    ELSE.
    MESSAGE s121 WITH text-006.
    ENDIF.
    \*& Module DISP_GRID OUTPUT
    \* text
    MODULE disp_grid OUTPUT.
    \* Build the Field catelog for Material Master data.
    PERFORM build_fcat.
    \* Display the Material Master data using ALV.
    PERFORM disp_alv.
    ENDMODULE. " DISP_GRID OUTPUT
    \*& Module USER_COMMAND_0100 INPUT
    \* text
    MODULE user_command_0100 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    \*& Form build_fcat
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARA'.
    IF p_hotspt EQ 'X'.
    ws_fcat-hotspot = 'X'.
    ENDIF.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARA'.
    APPEND ws_fcat TO i_fcat1.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat
    \*& Form disp_alv
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv.
    IF lp_cont1 IS INITIAL.
    \* Create the Container Object of Material Master.
    CREATE OBJECT lp_cont1
    EXPORTING
    container_name = c_cont1
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6 .
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Master.
    CREATE OBJECT lp_grid1
    EXPORTING
    i_parent = lp_cont1
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Master data by calling method.
    CALL METHOD lp_grid1->set_table_for_first_display
    CHANGING
    it_outtab = i_mara
    it_fieldcatalog = i_fcat1
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Set Handler for the Hot Spot Event.
    CREATE OBJECT lp_rcvr.
    IF p_hotspt EQ 'X'.
    SET HANDLER lp_rcvr->hotspot_click FOR lp_grid1.
    ELSE.
    SET HANDLER lp_rcvr->handle_double_click FOR lp_grid1.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDIF.
    ENDFORM. " disp_alv
    \*& Module STATUS_0100 OUTPUT
    \* text
    MODULE status_0100 OUTPUT.
    SET PF-STATUS 'MAIN_STAT'.
    SET TITLEBAR 'T_100'.
    ENDMODULE. " STATUS_0100 OUTPUT
    \*& Module STATUS_0200 OUTPUT
    \* text
    MODULE status_0200 OUTPUT.
    SET PF-STATUS 'PLANT_STAT'.
    SET TITLEBAR 'T_200'.
    ENDMODULE. " STATUS_0200 OUTPUT
    \*& Module DISP_GRID_plant OUTPUT
    \* text
    MODULE disp_grid_plant OUTPUT.
    \* Build the Field catelog for Material Plant data.
    PERFORM build_fcat_plant.
    \* Display the Material Master Plant data using ALV.
    PERFORM disp_alv_plant.
    ENDMODULE. " DISP_GRID_plant OUTPUT
    \*& Module USER_COMMAND_0200 INPUT
    \* text
    MODULE user_command_0200 INPUT.
    \*when exit or cancel is clicked program has to come out
    CASE sy-ucomm.
    WHEN 'EXIT' OR 'CANC'.
    LEAVE PROGRAM.
    WHEN 'BACK'.
    LEAVE TO SCREEN 0.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0200 INPUT
    \*& Form build_fcat_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM build_fcat_plant.
    DATA : ws_fcat TYPE lvc_s_fcat.
    ws_fcat-fieldname = 'MATNR'.
    ws_fcat-scrtext_m = text-001.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'WERKS'.
    ws_fcat-scrtext_m = text-004.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MTART'.
    ws_fcat-scrtext_m = text-002.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ws_fcat-fieldname = 'MAKTX'.
    ws_fcat-scrtext_m = text-003.
    ws_fcat-tabname = 'I_MARC'.
    APPEND ws_fcat TO i_fcat2.
    CLEAR ws_fcat.
    ENDFORM. " build_fcat_plant
    \*& Form disp_alv_plant
    \* text
    \* \--> p1 text
    \* <-\- p2 text
    FORM disp_alv_plant.
    IF lp_cont2 IS INITIAL.
    \* Create the Container Object of Material Plant data.
    CREATE OBJECT lp_cont2
    EXPORTING
    container_name = c_cont2
    EXCEPTIONS
    cntl_error = 1
    cntl_system_error = 2
    create_error = 3
    lifetime_error = 4
    lifetime_dynpro_dynpro_link = 5
    others = 6.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Create the Object for Grid of Material Plant data.
    CREATE OBJECT lp_grid2
    EXPORTING
    i_parent = lp_cont2
    EXCEPTIONS
    error_cntl_create = 1
    error_cntl_init = 2
    error_cntl_link = 3
    error_dp_create = 4
    others = 5.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ELSE.
    \* Dipslay Material Plant data by calling method.
    CALL METHOD lp_grid2->set_table_for_first_display
    CHANGING
    it_outtab = i_marc
    it_fieldcatalog = i_fcat2
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    OTHERS = 4.
    IF sy-subrc NE 0.
    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
    ENDIF.
    ENDIF.
    ENDIF.
    ELSE.
    \* Call method 'REFRESH_TABLE_DISPLAY' to refresh the grid data.
    CALL METHOD lp_grid2->refresh_table_display.
    ENDIF.
    ENDFORM. " disp_alv_plant
    Thanks
    Vasudha

  • ALV reports using OOPS

    Hi frnds,
            I want to write an alv report program using oops concepts.CAn anybody send me a simple code to generate an alv reports?
    Thanks a lot in advance.

    Hi
    http://www.sapdev.co.uk/reporting/alv/alvobjgrid/alvobject_sort.htm
    *& Report  ZLCL_ALV_INVOICE                                            *
    REPORT  ZLCL_ALV_INVOICE                        .
    TABLES: VBRK.
    DATA: ITAB LIKE VBRP OCCURS 1 WITH HEADER LINE.
    DATA: O_CONT TYPE REF TO CL_GUI_CUSTOM_CONTAINER,
          O_GRID TYPE REF TO CL_GUI_ALV_GRID.
    START-OF-SELECTION.
      SET SCREEN 100.
    *&      Form  GET_DATA
          text
    FORM GET_DATA .
      SELECT *
        FROM VBRP
        INTO TABLE ITAB
        WHERE VBELN = VBRK-VBELN.
    ENDFORM.                    " GET_DATA
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MENU'.
      IF O_CONT IS INITIAL.
        CREATE OBJECT O_CONT
          EXPORTING
        CONTAINER_NAME              = 'INV_CONT' "Screen custom control name
          EXCEPTIONS
            CNTL_ERROR                  = 1
            CNTL_SYSTEM_ERROR           = 2
            CREATE_ERROR                = 3
            LIFETIME_ERROR              = 4
            LIFETIME_DYNPRO_DYNPRO_LINK = 5
            OTHERS                      = 6
        IF SY-SUBRC <> 0.
          MESSAGE I000(Z00) WITH 'Error in custom container'.
          EXIT.
        ENDIF.
        CREATE OBJECT O_GRID
          EXPORTING
            I_PARENT          = O_CONT "Custom container class object
          EXCEPTIONS
            ERROR_CNTL_CREATE = 1
            ERROR_CNTL_INIT   = 2
            ERROR_CNTL_LINK   = 3
            ERROR_DP_CREATE   = 4
            OTHERS            = 5.
        IF SY-SUBRC <> 0.
          MESSAGE I000(Z00) WITH 'Error in alv grid linking'.
          EXIT.
        ENDIF.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN 'BACK'.
          LEAVE PROGRAM.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Module  SHOW_ALV_GRID  INPUT
          text
    MODULE SHOW_ALV_GRID INPUT.
      PERFORM GET_DATA.
      CALL METHOD O_GRID->SET_TABLE_FOR_FIRST_DISPLAY
        EXPORTING
          I_STRUCTURE_NAME              = 'VBRP'
        CHANGING
          IT_OUTTAB                     = ITAB[]
        EXCEPTIONS
          INVALID_PARAMETER_COMBINATION = 1
          PROGRAM_ERROR                 = 2
          TOO_MANY_LINES                = 3
          OTHERS                        = 4.
      IF SY-SUBRC <> 0.
        MESSAGE I000(Z00) WITH 'Error in showing alv grid'.
        EXIT.
      ENDIF.
    ENDMODULE.                 " SHOW_ALV_GRID  INPUT
    you can understand very easily

  • ALV Report using OOPS - Back button(F3) flow not correct

    Hi,
    When i try to execute my report (F8) and it goes to output screen perfectly.
    Then if i hit back button(F3) it comes to selection screen that's also fine.
    after then if i hit back button(F3) then it goes to output screen again.
    actually it has to go to the SE38 - program screen
    My GUI logic:
    *&  Include           ZSD_GUILOGIC
    *&      Module  init_0100  OUTPUT
          text
    MODULE init_0100 OUTPUT.
      call method cl_gui_cfw=>dispatch.
    create the report object
        if my_report is initial.
          CREATE OBJECT MY_REPORT
            EXPORTING
              SO_VKORG = so_vkorg[]
              SO_VTWEG = so_vtweg[]
              SO_DATE  = so_date[].
        endif.
      IF my_CUSTOM_CONTAINER IS INITIAL.
        CREATE OBJECT my_CUSTOM_CONTAINER
          EXPORTING
            CONTAINER_NAME = _CONTAINER.
        CREATE OBJECT my_GRID1
          EXPORTING
            I_PARENT = my_CUSTOM_CONTAINER.
        int_tab = my_report->RETURN_RESULT( ).
        CALL METHOD my_GRID1->SET_TABLE_FOR_FIRST_DISPLAY
          EXPORTING
            is_variant       = my_layout
            i_save           = 'A'
            i_default        = 'X'
            I_STRUCTURE_NAME = structure
          CHANGING
            IT_OUTTAB        = int_tab[].
      else.
    container actually exists.
        int_tab = my_report->RETURN_RESULT( ).
        MY_grid1->refresh_table_display( ).
      endif.
    ENDMODULE.                 " init_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE USER_COMMAND_0100 INPUT.
      to react on oi_custom_events:
      CASE OK_CODE.
        WHEN 'EXIT'.
          PERFORM EXIT_PROGRAM.
        when 'BACK'.
          clear: my_report, my_CUSTOM_CONTAINER, my_grid1, int_tab.
         leave
          CALL SELECTION-SCREEN 1000.
        WHEN 'REFRESH'.
         int_tab = my_report->RETURN_RESULT( ).
        WHEN OTHERS.
       do nothing
      ENDCASE.
      CLEAR OK_CODE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  EXIT_PROGRAM
          text
    -->  p1        text
    <--  p2        text
    FORM EXIT_PROGRAM .
      LEAVE PROGRAM.
    ENDFORM.                    " EXIT_PROGRAM
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE STATUS_0100 OUTPUT.
      SET PF-STATUS 'MAIN0100'.
    SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT

    HI,
    Thanks for ur replies.
    I am calling selection screen 100 like this.
    REPORT  ZSD_.
    INCLUDE ZSD__TOP.
    INCLUDE ZSD_LCL000.
    INCLUDE ZSD_GUILOGIC.
    initialization.
      move 'IEQ000' to so_vrsio.
      append so_vrsio.
      move 'IEQ' to so_date.
      so_date-low  = sy-datum.
      so_date-high = sy-datum.
      append so_date.
    start-of-selection.
    set the layout
      perform prepare_layout changing my_layout.
    Thanks
    Praba
    set the structure
      structure = 'ZSD_LEVEL0'.
    call the processing screen 0100
    set screen '0100'.

  • Creating ALV reports using OOP concept

    After creating many reports i found out that 90% of the coding in a report is copy paste i.e. only 10% of coding effort is required which includes
        creating the custom data types and internal table variables  ...
        populating the data
        creating screen,GUI status and GUI title
    Just copy paste the below code and do as stated  :
    *ALV TEMPLATE
    *create screen no. 2000
    *change flow logic in screen if necessary
    *create GUI status and GUI title
    *change selection texts and text symbols*
    REPORT  Y_TEMPLATE_ALV.
    TABLES : ."use if range of values required on selection screen.
    DATA: zcl_alvgrid        TYPE REF TO cl_gui_alv_grid,
           zcl_ccontainer     TYPE REF TO cl_gui_docking_container,
           wa_layout    TYPE lvc_s_layo,
           it_fieldcat  TYPE STANDARD TABLE OF lvc_s_fcat,
           wa_fieldcat  TYPE lvc_s_fcat,
           z_document         TYPE REF TO cl_dd_document,
           o_docking TYPE REF TO cl_gui_docking_container,"Docking Container
           o_split TYPE REF TO cl_gui_easy_splitter_container, "Splitter
           o_top_container TYPE REF TO cl_gui_container,   "Top Container
           o_bottom_container TYPE REF TO cl_gui_container."Bottom Container
    TYPES : BEGIN OF TY_FINAL,
    "All columns which are to be displayed in the report should be included here
    END OF TY_FINAL.
    *Add additional Internal Tables's if data is to be extracted from multiple tables
    *Then loop at main table and Read the other tables
    DATA :IT_DATA TYPE STANDARD TABLE OF , "data extracted from tables can be stored in this internal table variable ..
           WA_DATA TYPE ,
           iT_alv      TYPE STANDARD TABLE OF TY_FINAL, " pass to  the method SET_TABLE_FOR_FIRST_DISPLAY of class
    ZCL_ALVGRID [Already done ; its  just fyi]
           WA_alv      TYPE                   TY_FINAL.
    DATA :V_CLN(255) TYPE C, " For no. of records
           V_LINE TYPE I. " for conversion of integer to character
    *                 Selection Screen                                     *
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    PARAMETERS:
    SELECT-OPTIONS: " PARAMETERS and Range on selection screen
    SELECTION-SCREEN END OF BLOCK B1.
    AT SELECTION-SCREEN OUTPUT.
    *                        START  OF  SELECTION                          *
    START-OF-SELECTION.
    *  SELECT * FROM INTO CORRESPONDING FIELDS OF TABLE IT_DATA WHERE ....in ....
       IF SY-SUBRC = 0.
         LOOP AT IT_DATA INTO WA_DATA.
           MOVE-CORRESPONDING WA_DATA TO wa_alv. " if data is fetched from only one table
           APPEND wa_alv TO it_alv.
           CLEAR : wa_alv,WA_DATA.
         ENDLOOP.
         DESCRIBE TABLE it_alv LINES V_LINE.
         V_CLN = V_LINE.
       ENDIF.
    END-OF-SELECTION.
       PERFORM DISPLAY_ALV.
    *&      Module  STATUS  OUTPUT
    *       text
    MODULE STATUS_2000 OUTPUT.
       SET PF-STATUS 'STATUS'.
       SET TITLEBAR 'ALV'.
    *  ** Creating Docking Container
       CREATE OBJECT o_docking
       EXPORTING
    *    side = cl_gui_docking_container=>dock_at_right
         ratio = '95'.
       IF sy-subrc EQ 0.
    * Splitting the Docking container
         CREATE OBJECT o_split
         EXPORTING
           parent        = o_docking
           sash_position = 05 "Position of Splitter Bar (in Percent)
           with_border   = 0. "With Border = 1 Without Border = 0
    *   Placing the containers in the splitter
         o_top_container = o_split->top_left_container .
         o_bottom_container = o_split->bottom_right_container .
    *   Creating the document
         CREATE OBJECT z_document
         EXPORTING
           style = 'ALV_GRID'.
       ENDIF.
    * Calling the methods for dynamic text
       CALL METHOD z_document->add_text
       EXPORTING
         TEXT         = 'No. of Records:'
         sap_emphasis = cl_dd_area=>strong. " For bold
    * Adding GAP
       CALL METHOD z_document->add_gap
       EXPORTING
         width = 10.
    * Adding Text
       CALL METHOD z_document->add_text
       EXPORTING
         TEXT = v_cln.
    * Adding Line
       CALL METHOD z_document->new_line.
    * Display the data
       CALL METHOD z_document->display_document
       EXPORTING
         parent = o_top_container.
       IF zcl_alvgrid IS INITIAL .
    *----Creating ALV Grid instance
         CREATE OBJECT zcl_alvgrid
         EXPORTING
           i_parent          = o_bottom_container
         EXCEPTIONS
           error_cntl_create = 1
           error_cntl_init   = 2
           error_cntl_link   = 3
           error_dp_create   = 4
           OTHERS            = 5.
         IF sy-subrc <> 0.
           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
           WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
         ENDIF.
    * Calling the method of ALV to process top of page
         CALL METHOD zcl_alvgrid->list_processing_events
         EXPORTING
           i_event_name = 'TOP_OF_PAGE'
           i_dyndoc_id  = z_document.
    * Preparing field catalog.
         PERFORM T_FIELDCAT USING:
                    '1'        'BRNCD'      'BRAND'.
    *          'Column no' 'FIELDNAME' 'Column Heading' 
         WA_LAYOUT-CWIDTH_OPT = 'X'.
         WA_LAYOUT-ZEBRA = 'X'.
         WA_LAYOUT-SEL_MODE =  'A'.
    * Setting table for first display
         CALL METHOD ZCL_ALVGRID->SET_TABLE_FOR_FIRST_DISPLAY
         EXPORTING
           IS_LAYOUT                     = WA_LAYOUT
         CHANGING
           IT_OUTTAB                     = it_alv
           IT_FIELDCATALOG               = IT_FIELDCAT
         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.
       ELSE.
         CALL METHOD ZCL_ALVGRID->REFRESH_TABLE_DISPLAY
         EXCEPTIONS
           FINISHED = 1
           OTHERS   = 2.
         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.
    ENDMODULE.                 " STATUS  OUTPUT
    MODULE USER_COMMAND_2000 INPUT.
       DATA: V_OK_CODE TYPE SY-UCOMM,
             V_SAVE_OK TYPE SY-UCOMM.
       V_OK_CODE = SY-UCOMM.
       V_SAVE_OK = V_OK_CODE.
       CASE SY-UCOMM.
         WHEN 'BACK'.
           SET SCREEN 1000.
         WHEN 'EXIT'.
           LEAVE program.
         WHEN OTHERS.
           SET SCREEN 1000.
       ENDCASE.
       CLEAR V_SAVE_OK.
       SET SCREEN 0.
       LEAVE SCREEN.
    ENDMODULE.                 " USER_COMMAND_2000  INPUT
    *&      Form  T_FIELDCAT
    *       text
    *      -->x   text
    *      -->y   text
    *      -->z   text
    FORM T_FIELDCAT  USING VALUE(X) TYPE ANY
           VALUE(Y) TYPE ANY
           VALUE(Z) TYPE ANY.
       WA_FIELDCAT-COL_POS = X.
       WA_FIELDCAT-FIELDNAME = Y.
       WA_FIELDCAT-COLTEXT  = Z.
       APPEND WA_FIELDCAT TO IT_FIELDCAT.
       CLEAR WA_FIELDCAT.
    ENDFORM.                      " T_FIELDCAT
    *&      Form  DISPLAY_ALV
    *       text
    *  -->  p1        text
    *  <--  p2        text
    FORM DISPLAY_ALV .
       IF NOT it_alv[] IS INITIAL.
         CALL SCREEN 2000.
       ELSE.
         MESSAGE 'No data for Display' TYPE 'I'.
       ENDIF.
    ENDFORM.                    " DISPLAY_ALV

    Hello Jay,
    Calling methods, creating instances, casting etc are not OOP. When you say you've developed an OO-report you think OO, refer to this blog to see what i mean - Global Data in ABAP OO Programs
    BR,
    Suhas

  • END_OF_PAGE in alv report using oops

    Experts,
    Could you please give me the solution for the below issue?
    Requirement is like this:
    I have to display two grids in my report, and in that one grid will have top-of-page and other one will
    have end-of-page. Here, I am able to display the data in the top-of-page but not able to display the data in
    end of page. (Here I am using cl_gui_alv_grid : Class and Event is: END_OF_LIST.).
    I gone through the BCALV_TEST_GRID_EVENTS, but that is not helpful to me.
    Please anyone can you send the code snippet for the above one.
    Thanks...
    Sridhar..

    Hi,
    In the class cl_salv_table you have method get_event get the event from the method.
    Pass u r end of page iver here .it raises the event end of page
    thanks

  • ALV Interactive Report  using oops

    Hi All ,
                   Pls anybody send me the code for ALV interactive report using OOPS  , that reports covers the following things like Header , Logo , Total& subtotals  .....etc  ,
                   with this i can complete my object .
    thanks in Adv
    Rgds
    Rafi .

    Hi
    this code is helpful for u.check it.
    REPORT ZZ_22038_22098_002 NO STANDARD PAGE HEADING LINE-SIZE 650
    MESSAGE-ID ZZ_9838 .
    TYPE-POOLS: SLIS.
    *type declaration for values from ekko
    TYPES: BEGIN OF I_EKKO,
    EBELN LIKE EKKO-EBELN,
    AEDAT LIKE EKKO-AEDAT,
    BUKRS LIKE EKKO-BUKRS,
    BSART LIKE EKKO-BSART,
    LIFNR LIKE EKKO-LIFNR,
    END OF I_EKKO.
    DATA: IT_EKKO TYPE STANDARD TABLE OF I_EKKO INITIAL SIZE 0,
    WA_EKKO TYPE I_EKKO.
    *type declaration for values from ekpo
    TYPES: BEGIN OF I_EKPO,
    EBELN LIKE EKPO-EBELN,
    EBELP LIKE EKPO-EBELP,
    MATNR LIKE EKPO-MATNR,
    MENGE LIKE EKPO-MENGE,
    MEINS LIKE EKPO-MEINS,
    NETPR LIKE EKPO-NETPR,
    END OF I_EKPO.
    DATA: IT_EKPO TYPE STANDARD TABLE OF I_EKPO INITIAL SIZE 0,
    WA_EKPO TYPE I_EKPO .
    *variable for Report ID
    DATA: V_REPID LIKE SY-REPID .
    *declaration for fieldcatalog
    DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
    WA_FIELDCAT TYPE SLIS_FIELDCAT_ALV.
    DATA: IT_LISTHEADER TYPE SLIS_T_LISTHEADER.
    declaration for events table where user comand or set PF status will
    be defined
    DATA: V_EVENTS TYPE SLIS_T_EVENT,
    WA_EVENT TYPE SLIS_ALV_EVENT.
    declartion for layout
    DATA: ALV_LAYOUT TYPE SLIS_LAYOUT_ALV.
    declaration for variant(type of display we want)
    DATA: I_VARIANT TYPE DISVARIANT,
    I_VARIANT1 TYPE DISVARIANT,
    I_SAVE(1) TYPE C.
    *PARAMETERS : p_var TYPE disvariant-variant.
    *Title displayed when the alv list is displayed
    DATA: I_TITLE_EKKO TYPE LVC_TITLE VALUE 'FIRST LIST DISPLAYED'.
    DATA: I_TITLE_EKPO TYPE LVC_TITLE VALUE 'SECONDRY LIST DISPLAYED'.
    INITIALIZATION.
    V_REPID = SY-REPID.
    PERFORM BUILD_FIELDCATLOG.
    PERFORM EVENT_CALL.
    PERFORM POPULATE_EVENT.
    START-OF-SELECTION.
    PERFORM DATA_RETRIEVAL.
    PERFORM BUILD_LISTHEADER USING IT_LISTHEADER.
    PERFORM DISPLAY_ALV_REPORT.
    *& Form BUILD_FIELDCATLOG
    Fieldcatalog has all the field details from ekko
    FORM BUILD_FIELDCATLOG.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-FIELDNAME = 'EBELN'.
    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-FIELDNAME = 'AEDAT'.
    WA_FIELDCAT-SELTEXT_M = 'DATE.'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-FIELDNAME = 'BUKRS'.
    WA_FIELDCAT-SELTEXT_M = 'COMPANY CODE'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-FIELDNAME = 'BUKRS'.
    WA_FIELDCAT-SELTEXT_M = 'DOCMENT TYPE'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKKO'.
    WA_FIELDCAT-FIELDNAME = 'LIFNR'.
    WA_FIELDCAT-NO_OUT = 'X'.
    WA_FIELDCAT-SELTEXT_M = 'VENDOR CODE'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    ENDFORM. "BUILD_FIELDCATLOG
    *& Form EVENT_CALL
    we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = V_EVENTS
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. "EVENT_CALL
    *& Form POPULATE_EVENT
    Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT.
    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
    IF SY-SUBRC EQ 0.
    WA_EVENT-FORM = 'TOP_OF_PAGE'.
    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
    ENDIF.
    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'USER_COMMAND'.
    IF SY-SUBRC EQ 0.
    WA_EVENT-FORM = 'USER_COMMAND'.
    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-NAME.
    ENDIF.
    ENDFORM. "POPULATE_EVENT
    *& Form data_retrieval
    retreiving values from the database table ekko
    FORM DATA_RETRIEVAL.
    SELECT EBELN AEDAT BUKRS BSART LIFNR FROM EKKO INTO TABLE IT_EKKO.
    ENDFORM. "data_retrieval
    *& Form bUild_listheader
    text
    -->I_LISTHEADEtext
    FORM BUILD_LISTHEADER USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA HLINE TYPE SLIS_LISTHEADER.
    HLINE-INFO = 'this is my first alv pgm'.
    HLINE-TYP = 'H'.
    ENDFORM. "build_listheader
    *& Form display_alv_report
    text
    FORM DISPLAY_ALV_REPORT.
    V_REPID = SY-REPID.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_CALLBACK_PROGRAM = V_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
    I_GRID_TITLE = I_TITLE_EKKO
    I_GRID_SETTINGS =
    IS_LAYOUT = ALV_LAYOUT
    IT_FIELDCAT = I_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    i_default = 'ZLAY1'
    I_SAVE = 'A'
    is_variant = i_variant
    IT_EVENTS = V_EVENTS
    TABLES
    T_OUTTAB = IT_EKKO
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. "display_alv_report
    *& Form TOP_OF_PAGE
    text
    FORM TOP_OF_PAGE.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = IT_LISTHEADER
    i_logo =
    I_END_OF_LIST_GRID =
    ENDFORM. "TOP_OF_PAGE
    *& Form USER_COMMAND
    text
    -->R_UCOMM text
    -->, text
    -->RS_SLEFIELDtext
    FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
    RS_SELFIELD TYPE SLIS_SELFIELD.
    CASE R_UCOMM.
    WHEN '&IC1'.
    READ TABLE IT_EKKO INTO WA_EKKO INDEX RS_SELFIELD-TABINDEX.
    PERFORM BUILD_FIELDCATLOG_EKPO.
    PERFORM EVENT_CALL_EKPO.
    PERFORM POPULATE_EVENT_EKPO.
    PERFORM DATA_RETRIEVAL_EKPO.
    PERFORM BUILD_LISTHEADER_EKPO USING IT_LISTHEADER.
    PERFORM DISPLAY_ALV_EKPO.
    ENDCASE.
    ENDFORM. "user_command
    *& Form BUILD_FIELDCATLOG_EKPO
    text
    FORM BUILD_FIELDCATLOG_EKPO.
    WA_FIELDCAT-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT-FIELDNAME = 'EBELN'.
    WA_FIELDCAT-SELTEXT_M = 'PO NO.'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'IT_EKPO'.
    WA_FIELDCAT-FIELDNAME = 'EBELP'.
    WA_FIELDCAT-SELTEXT_M = 'LINE NO'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
    WA_FIELDCAT-FIELDNAME = 'MATNR'.
    WA_FIELDCAT-SELTEXT_M = 'MATERIAL NO.'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
    WA_FIELDCAT-FIELDNAME = 'MENGE'.
    WA_FIELDCAT-SELTEXT_M = 'QUANTITY'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
    WA_FIELDCAT-FIELDNAME = 'MEINS'.
    WA_FIELDCAT-SELTEXT_M = 'UOM'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    WA_FIELDCAT-TABNAME = 'I_EKPO'.
    WA_FIELDCAT-FIELDNAME = 'NETPR'.
    WA_FIELDCAT-SELTEXT_M = 'PRICE'.
    APPEND WA_FIELDCAT TO I_FIELDCAT.
    CLEAR WA_FIELDCAT.
    ENDFORM. "BUILD_FIELDCATLOG_EKPO
    *& Form event_call_ekpo
    we get all events - TOP OF PAGE or USER COMMAND in table v_events
    FORM EVENT_CALL_EKPO.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
    I_LIST_TYPE = 0
    IMPORTING
    ET_EVENTS = V_EVENTS
    EXCEPTIONS
    LIST_TYPE_WRONG = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. "event_call_ekpo
    *& Form POPULATE_EVENT
    Events populated for TOP OF PAGE & USER COMAND
    FORM POPULATE_EVENT_EKPO.
    READ TABLE V_EVENTS INTO WA_EVENT WITH KEY NAME = 'TOP_OF_PAGE'.
    IF SY-SUBRC EQ 0.
    WA_EVENT-FORM = 'TOP_OF_PAGE'.
    MODIFY V_EVENTS FROM WA_EVENT TRANSPORTING FORM WHERE NAME =
    WA_EVENT-FORM.
    ENDIF.
    ENDFORM. "POPULATE_EVENT
    *& Form TOP_OF_PAGE
    text
    FORM F_TOP_OF_PAGE.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    EXPORTING
    IT_LIST_COMMENTARY = IT_LISTHEADER
    i_logo =
    I_END_OF_LIST_GRID =
    ENDFORM. "TOP_OF_PAGE
    *& Form USER_COMMAND
    text
    -->R_UCOMM text
    -->, text
    -->RS_SLEFIELDtext
    *retreiving values from the database table ekko
    FORM DATA_RETRIEVAL_EKPO.
    SELECT EBELN EBELP MATNR MENGE MEINS NETPR FROM EKPO INTO TABLE IT_EKPO.
    ENDFORM.
    FORM BUILD_LISTHEADER_EKPO USING I_LISTHEADER TYPE SLIS_T_LISTHEADER.
    DATA: HLINE1 TYPE SLIS_LISTHEADER.
    HLINE1-TYP = 'H'.
    HLINE1-INFO = 'CHECKING PGM'.
    ENDFORM.
    FORM DISPLAY_ALV_EKPO.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    I_CALLBACK_PROGRAM = V_REPID
    I_CALLBACK_PF_STATUS_SET = ' '
    I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'
    I_CALLBACK_TOP_OF_PAGE = 'TOP_OF_PAGE'
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME =
    I_BACKGROUND_ID = ' '
    I_GRID_TITLE = I_TITLE_EKPO
    I_GRID_SETTINGS =
    IS_LAYOUT =
    IT_FIELDCAT = I_FIELDCAT[]
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT =
    I_SAVE = 'A'
    IS_VARIANT =
    IT_EVENTS = V_EVENTS
    TABLES
    T_OUTTAB = IT_EKPO
    EXCEPTIONS
    PROGRAM_ERROR = 1
    OTHERS = 2
    IF SY-SUBRC <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM.
    Regards,
    Sree

  • Display error message in ALV grid  using OOPS

    Hi,
    I have a requirement to display report in ALV. I have created ALV grid using OOPS with three editable cells and 1 button on toolbar. When user enter values in Ediatble cell  and click on the Toolbar button, sales order item should be assigned to contract.
    When the user select  the row and click on toolbar button, a salesorder item should be assigned  to contract and i am using BAPI and fine with BAPI. All the error message should be displayed in a popup and the corresponding failed row  should change its color .
    Once the user identified the failed row, he can edit the value in the ediatble cells and should reprocess in the same screen ( without going back to selection screen).
    To display POP Up, I  am using FM BAL_LOG_CREATE, BAL_LOG_MSG_ADD, BAL_DSP_PROFILE_NO_TREE_GET, BAL_CNTL_CREATE.
    by using above 4 FM , i can display POP UP. but i cannot change the color of the failed row. 
    Once I identified the failed row and reprocess from the same screen , I am successful in processing the failed row, but my error log still has the reprocessed row as failed row because,  error log is not refreshing.
    Please suggest me how to clear error log which was created by using the above FM's and change the color of the failed row .
    Thanks in Advance

    Hi
    Please suggest me how to clear error log which was created by using the above FM's....
    U can use BAL_LOG_REFRESH
    ....and change the color of the failed row
    You need to insert a new field for Colour Attributes in your output table and input its name in the layout structure:
    IS_LAYOUT-INFO_FNAME = <field name for colour>
    The field has to be a CHAR 3 and its value can be -
    > Cxy
    C is a constant
    x is the colour number (from 1 to 9)
    y is intensified (0 = off, 1 = on)
    After changing the value of output table you need to run the method REFRESH_TABLE_DISPLAY for refreshing the output
    Max

  • Toolbar in alv display using oops alv

    i have written code for displaying toolbar in alv display using oops, but it is not displaying please find the below code and let me know reason.
    *& Report  ZTRANSFER_ORDER2                                            *
    REPORT  ZTRANSFER_ORDER2   .
    *& Report  ZTRANSFER_ORDER                                             *
       TABLES:sflight.
       TYPE-POOLS : icon.
      * G L O B A L   I N T E R N  A L   T A B L E S
    CLASS lcl_event_receiver DEFINITION DEFERRED.
    types : begin of ty_mara,
            matnr type matnr,
            mtart type mtart,
            mbrsh type mbrsh,
            matkl type matkl,
            bismt type bismt,
            meins type meins,
            end of ty_mara.
      DATA: t_mara type STANDARD TABLE OF ty_mara.
      * G L O B A L   D A T A
       DATA: ok_code LIKE sy-ucomm,
             g_wa_mara type ty_mara.
        DATA : t_fcat type LVC_T_FCAT.
      DATA  : l_VAR TYPE disvariant.
      DATA :  gs_layout type lvc_s_layo.
      * Declare reference variables to the ALV grid and the container
    G L O B A L   D A T A
      DATA: ok_code LIKE sy-ucomm.
    Declare reference variables to the ALV grid and the container
       DATA:
         go_grid             TYPE REF TO cl_gui_alv_grid,
         go_custom_container TYPE REF TO cl_gui_custom_container.
      data :  it_toolbar  TYPE stb_button,
      event_receiver TYPE REF TO lcl_event_receiver.
      * S T A R T - O F - S E L E C T I O N.
       START-OF-SELECTION.
        CALL SCREEN 100   .
    *CLASS lcl_event_receiver DEFINITION.
    CLASS lcl_event_receiver DEFINITION.
    PUBLIC SECTION.
        CLASS-METHODS:
    *handling toolbar for interactive
         handle_toolbar
            FOR EVENT toolbar OF cl_gui_alv_grid
                IMPORTING e_object e_interactive,
    *handling menu button
         handle_menu_button
            FOR EVENT menu_button OF cl_gui_alv_grid
                IMPORTING e_object e_ucomm,
    *On click of the menu button
        handle_user_command
            FOR EVENT user_command OF cl_gui_alv_grid
                IMPORTING e_ucomm.
        PRIVATE SECTION.
        ENDCLASS.
    CLASS lcl_event_receiver IMPLEMENTATION.
    METHOD handle_toolbar.
    handle toolbar
    CLEAR it_toolbar.
    MOVE 'DETAIL' TO it_toolbar-function.
        MOVE icon_detail TO it_toolbar-icon.
        MOVE 2 TO it_toolbar-butn_type.
        APPEND it_toolbar TO e_object->mt_toolbar.
        ENDMETHOD.                    "handle_toolbar
        METHOD handle_menu_button.
    handle own menubuttons
        IF e_ucomm = 'DETAIL'.
          CALL METHOD e_object->add_function
            EXPORTING
              fcode = 'DISPLAY'
              text  = 'DISPLAY'.
        ENDIF.
      ENDMETHOD.                    "handle_menu_button
      METHOD handle_user_command.
    *On click
        CASE e_ucomm.
          WHEN 'DISPLAY'.
            MESSAGE 'Menu Clicked' TYPE 'I'.
        ENDCASE.
      ENDMETHOD.                           "handle_user_command
    ENDCLASS.                    "lcl_event_receiver IMPLEMENTATION
      *&      Module  USER_COMMAND_0100  INPUT
      MODULE user_command_0100 INPUT.
        CASE ok_code.
          WHEN 'EXIT'.
            LEAVE TO SCREEN 0.
        ENDCASE.
      ENDMODULE.                 " USER_COMMAND_0100  INPUT
      *&      Module  STATUS_0100  OUTPUT
       MODULE status_0100 OUTPUT.
        sET PF-STATUS 'STATUS'.
    Create objects
         IF go_custom_container IS INITIAL.
           CREATE OBJECT go_custom_container
             EXPORTING container_name = 'ALV_CONTAINER'.
           CREATE OBJECT go_grid
             EXPORTING
               i_parent = go_custom_container.
           PERFORM load_data_into_grid.
         ENDIF.
       ENDMODULE.                 " STATUS_0100  OUTPUT
      *&      Form  load_data_into_grid
       FORM load_data_into_grid.
    Read data from table SFLIGHT
         SELECT matnr mtart mbrsh matkl bismt meins
           FROM mara
           INTO corresponding fields of TABLE t_mara.
       PERFORM fld_cate changing T_fcat.
        l_var-report = sy-repid.
      gs_layout-grid_title = 'Analysis Report'.
    gs_layout-NO_TOOLBAR = 'X'.
    gs_layout-BOX_FNAME = 'Selection'.
    Load data into the grid and display them
            caLL METHOD go_grid->set_table_for_first_display
            EXPORTING
            i_structure_name = 'S_MVKE'
              i_save          = 'A'
               is_variant       = l_var
                is_layout             = gs_layout
           CHANGING
             it_outtab        = t_mara[]
             it_fieldcatalog  = t_fcat.
      endform.
    *&      Module  pai  INPUT
          text
    MODULE pai INPUT.
    data: l_valid type c.
       clear ok_code.
       break-point.
       ok_code = sy-ucomm.
           CASE ok_code.
           WHEN 'EXIT'.
             LEAVE TO SCREEN 0.
           WHEN 'BACK'.
             call method go_grid->check_changed_data
                 importing
                    e_valid = l_valid.
            loop at t_mara into g_wa_mara.
            endloop.
         ENDCASE.
    ENDMODULE.                 " pai  INPUT
    *&      Form  fld_cate
          text
         <--P_T_FCAT  text
    FORM fld_cate  CHANGING P_T_FCAT  TYPE lvc_t_fcat.
    DATA : s_fcat type LVC_S_FCAT .
    REFRESH: t_fcat.
      CLEAR s_fcat.
    s_fcat-fieldname = 'BOX1'.
    s_fcat-coltext =   'Box1'.
    s_fcat-seltext =   'Box1'.
    s_fcat-CHECKBOX = 'X'.
    s_fcat-EDIT = 'X'.
    APPEND s_fcat TO P_T_FCAT.
      CLEAR s_fcat.
      s_fcat-row_pos = 1.
      s_fcat-col_pos = 1.
      s_fcat-fieldname = 'MATNR'.
      s_fcat-ref_field = 'MATNR'.
      s_fcat-ref_table = 'T_MARA'.
      s_fcat-coltext =   'Material'.
      s_fcat-seltext =   'Material'.
    s_fcat-EDIT = 'X'.
      APPEND s_fcat TO P_T_FCAT.
      CLEAR s_fcat.
       s_fcat-row_pos = 2.
      s_fcat-col_pos = 2.
      s_fcat-fieldname = 'MTART'.
      s_fcat-ref_field = 'MTART'.
      s_fcat-ref_table = 'T_MARA'.
      s_fcat-coltext =   'Material type'.
      s_fcat-seltext =   'Material type'.
      APPEND s_fcat TO P_T_FCAT.
    CLEAR s_fcat.
    s_fcat-fieldname = 'BOX2'.
    s_fcat-coltext =   'Box2'.
    s_fcat-seltext =   'Box2'.
    s_fcat-CHECKBOX = 'X'.
    s_fcat-EDIT = 'X'.
    APPEND s_fcat TO P_T_FCAT.
      CLEAR s_fcat.
      s_fcat-row_pos = 3.
      s_fcat-col_pos = 3.
      s_fcat-fieldname = 'MBRSH'.
      s_fcat-ref_field = 'MBRSH'.
      s_fcat-ref_table = 'T_MARA'.
      s_fcat-coltext =   'Industry Sector'.
      s_fcat-seltext =   'Industry Sector'.
      APPEND s_fcat TO P_T_FCAT.
      CLEAR s_fcat.
        s_fcat-row_pos = 4.
      s_fcat-col_pos = 4.
      s_fcat-fieldname = 'MATKL'.
      s_fcat-ref_field = 'MATKL'.
      s_fcat-ref_table = 'T_MARA'.
      s_fcat-coltext =   'Material Group'.
      s_fcat-seltext =   'Material Group'.
      APPEND s_fcat TO P_T_FCAT.
      CLEAR s_fcat.
        s_fcat-row_pos = 5.
      s_fcat-col_pos = 5.
      s_fcat-fieldname = 'BISMT'.
      s_fcat-ref_field = 'BISMT'.
      s_fcat-ref_table = 'T_MARA'.
      s_fcat-coltext =   'Old material number'.
      s_fcat-seltext =   'Old material number'.
      APPEND s_fcat TO P_T_FCAT.
      CLEAR s_fcat.
        s_fcat-row_pos = 6.
      s_fcat-col_pos = 6.
      s_fcat-fieldname = 'MEINS'.
      s_fcat-ref_field = 'MEINS'.
      s_fcat-ref_table = 'T_MARA'.
      s_fcat-coltext =   'Base Unit of Measure'.
      s_fcat-seltext =   'Base Unit of Measure'.
      APPEND s_fcat TO P_T_FCAT.
    CLEAR s_fcat.
    s_fcat-fieldname = 'BOX3'.
    s_fcat-coltext =   'Box3'.
    s_fcat-seltext =   'Box3'.
    s_fcat-CHECKBOX = 'X'.
    s_fcat-EDIT = 'X'.
    APPEND s_fcat TO P_T_FCAT.
    ENDFORM.                    " fld_cate                     .

    MOVE 2 TO it_toolbar-butn_type.
    Try changing the 2 (menu) to 0 (button) and see if that helps
    also you need to set the event handler after you create your alv object
    set handler handle_toolbar for [whatever object is called].
    Edited by: Kev Mycock on Jul 24, 2008 7:59 AM

  • How to add button in ALV report (Class method )?

    Hello experts,
    I have developed one ALV report using classes.
    I want to add one more  button on the report like already is there named DISPLQUA
    How ca i do that here?
    Following the code of CLASS definition & implimentation
    CLASS lcl_handle_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          handle_on_user_command FOR EVENT added_function OF cl_salv_events
            IMPORTING e_salv_function.
    ENDCLASS.                    "lcl_handle_events DEFINITION
          CLASS lcl_handle_events IMPLEMENTATION
    CLASS lcl_handle_events IMPLEMENTATION.
      METHOD handle_on_user_command.
        CASE e_salv_function.
          WHEN 'DISPLQUA'.
            PERFORM show_quant_record.
         WHEN 'DISPQM03'.                                " Here i want to add button
           PERFORM display_quality_notification.
          WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.                    "handle_on_user_command
    ENDCLASS.                    "lcl_handle_events IMPLEMENTATION

    HI Ronny.
    Code snippet for reference.
    CLASS LCL_EVENT_HANDLER DEFINITION .
      PUBLIC SECTION.
        METHODS :
    *--Toolbar control
          HANDLE_TOOLBAR FOR EVENT TOOLBAR
            OF CL_GUI_ALV_GRID IMPORTING E_OBJECT
                                         E_INTERACTIVE,
    ENDCLASS
    CLASS LCL_EVENT_HANDLER IMPLEMENTATION.
    *--handle toolbar
      METHOD HANDLE_TOOLBAR.
    * append a separator to normal toolbar
        CLEAR G_TOOLBAR.
        G_TOOLBAR-BUTN_TYPE = 3.
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
        CLEAR G_TOOLBAR.
        G_TOOLBAR-FUNCTION = 'SAVE'.
        G_TOOLBAR-ICON = ICON_SYSTEM_SAVE.
        G_TOOLBAR-BUTN_TYPE = 0.
        G_TOOLBAR-QUICKINFO = 'Save the Customer'(203).
        APPEND G_TOOLBAR TO E_OBJECT->MT_TOOLBAR.
      ENDMETHOD.                    "HANDLE_TOOLBAR
    Hope this helps.
    Gary.
    <REMOVED BY MODERATOR>
    Edited by: Alvaro Tejada Galindo on Apr 7, 2008 5:41 PM

  • Control User Specific button in ALV report

    Hi,
    Can anybody please suggest me how to control "USER SPECIFIC" button in ALV report layout using authorization object. I mean if you can tell me which authorization object is responsible to control the "USER SPECIFIC" button.

    additional info to what Lakshmi already said:-
    normally the restrictions for saving layouts/display variants are done at 2 levels:
    1) The developer of an ALV list first predetermines the authorization in the 'i_save' parameter within the code.
    I_SAVE = ' '     -
    layouts cannot be saved
    I_SAVE = 'A'   -
    user-specific and cross-user layouts can be saved
    I_SAVE = 'X'   --- cross-user layouts can be saved
    I_SAVE = 'U'  ---  user-specific layouts can be saved
    2) The second level comes to us restriciting the S_ALV_LAYO which gives access to users to save global layouts if I_SAVE for that particular transaction is A or X.
    for example, a report has I_SAVE= 'A', which means
    it will allow to save  User-specific  layouts without any restrictions.
    and if user has S_ALV_LAYO then he can save both User-Specific and Global Layouts(variants).
    it would be better to keep this object separate.

  • Button in ALV Report

    Hi All,
    I want to know how to create a button in alv report .
    Please respond to my query.
    Thanks and Regards,
    Aman

    hi aman,
    u can try this example:
    where i have a created a button:
    *& Report  Z_GURU_ALV_EVENT01                                          *
    report  z_guru_alv_event01                      .
    tables: mara, makt.
    type-pools slis.
    data: begin of imara occurs 0,
            matnr like mara-matnr,
            ernam like mara-ernam,
            ersda like mara-ersda,
          end of imara.
    data: begin of imakt occurs 0,
            matnr like mara-matnr,
            spras like makt-spras,
            maktx like makt-maktx,
          end of imakt.
    data: ffc type slis_t_fieldcat_alv,
          ievents type slis_t_event with header line,
          iievent type slis_t_event with header line.
    select-options: s_matnr for mara-matnr.
    initialization.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
       i_list_type           = 0
    importing
       et_events             = ievents[]
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    read table ievents with key name = slis_ev_top_of_page.
    ievents-form = 'TOPP'.
    modify ievents transporting form where name = slis_ev_top_of_page.
    clear ievents.
    read table ievents with key name = slis_ev_user_command.
    ievents-form = 'USR_COM'.
    modify ievents transporting form where name = slis_ev_user_command.
    clear ievents.
    read table ievents with key name = slis_ev_pf_status_set.
    ievents-form = 'PFSTAT'.
    modify ievents transporting form where name = slis_ev_pf_status_set.
    clear ievents.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
       i_list_type           = 0
    importing
       et_events             = iievent[]
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    read table iievent with key name = slis_ev_pf_status_set.
    iievent-form = 'PFSTAT'.
    modify iievent transporting form where name = slis_ev_pf_status_set.
    clear iievent.
    read table iievent with key name = slis_ev_user_command.
    iievent-form = 'USERCOM'.
    modify iievent transporting form where name = slis_ev_user_command.
    clear iievent.
    start-of-selection.
    select matnr ernam ersda from mara into table imara where matnr
    in s_matnr.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
       i_program_name               = sy-repid
       i_internal_tabname           = 'IMARA'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
       i_inclname                   = sy-repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      changing
        ct_fieldcat                  = ffc
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
       i_callback_top_of_page            = 'ALV_BACKGROUND'
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
       i_callback_html_end_of_list       = 'ALV_BACKGROUND'
      I_STRUCTURE_NAME                  =
       i_background_id                   = 'ALV_BACKGROUND'
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = ffc
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       it_events                         = ievents[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = imara
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    form topp.
    data: it_top type slis_t_listheader,"”having s , h ,a
           wa type slis_listheader.
          IT_SPEC TYPE SLIS_T_SPECIALCOL_ALV,
          WA1 TYPE SLIS_SPECIALCOL_ALV.
    wa-typ = 'H'.
    wa-info = 'RELIANCE GLOBAL SERVICES' .
    append wa to it_top.
    clear wa.
    wa-typ = 'S'.wa-key = 'NO:23'.
    wa-info = 'TRIPLICANE HIGH ROAD'.
    append wa to it_top.
    clear wa.
    wa-typ = 'S'.
    wa-info = 'TRIPLICANE'.
    append wa to it_top.
    clear wa.
    wa-typ = 'A'.
    wa-info = 'sample'.
    append wa to it_top.
    clear wa.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
       exporting
         it_list_commentary       = it_top
        i_logo                   = 'ENJOYSAP_LOGO'
       I_END_OF_LIST_GRID       =
       I_ALV_FORM               =
    endform.
    form usr_com using r_ucomm type sy-ucomm r_selfield type slis_selfield.
    case r_ucomm.
    when 'CANC'.
    leave to screen 0.
    endcase.
    data: ff type slis_t_fieldcat_alv.
    data: v_vbeln(18) type n.
    v_vbeln = r_selfield-value.
    select matnr spras maktx
    from makt into table imakt
    up to 10 rows
    where matnr = v_vbeln.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
       i_program_name               = sy-repid
       i_internal_tabname           = 'IMAKT'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
       i_inclname                   = sy-repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      changing
        ct_fieldcat                  = ff
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = ff
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       it_events                         = iievent[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = imakt
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform. "USR_COM
    form pfstat using extab type slis_t_extab.
    set pf-status 'STD' excluding extab.
    endform. " pfstat
    form usercom using rucom type sy-ucomm rselfield type slis_selfield.
    case rucom.
    when 'CANC'.
    leave to screen 0.
    endcase.
    data: ffc type slis_t_fieldcat_alv,
          v_matnr(18) type n.
    v_matnr = rselfield-value.
    select matnr ernam ersda from mara into table imara
    where matnr = v_matnr.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
       i_program_name               = sy-repid
       i_internal_tabname           = 'IMARA'
      I_STRUCTURE_NAME             =
      I_CLIENT_NEVER_DISPLAY       = 'X'
       i_inclname                   = sy-repid
      I_BYPASSING_BUFFER           =
      I_BUFFER_ACTIVE              =
      changing
        ct_fieldcat                  = ffc
    EXCEPTIONS
      INCONSISTENT_INTERFACE       = 1
      PROGRAM_ERROR                = 2
      OTHERS                       = 3
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       i_callback_program                = sy-repid
      I_CALLBACK_PF_STATUS_SET          = ' '
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      =
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       it_fieldcat                       = ffc
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
       it_events                         = iievent[]
      IT_EVENT_EXIT                     =
      IS_PRINT                          =
      IS_REPREP_ID                      =
      I_SCREEN_START_COLUMN             = 0
      I_SCREEN_START_LINE               = 0
      I_SCREEN_END_COLUMN               = 0
      I_SCREEN_END_LINE                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      I_HTML_HEIGHT_TOP                 =
      I_HTML_HEIGHT_END                 =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      tables
        t_outtab                          = imara
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
    if sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    endif.
    endform.

  • Summation button in ALV report is giving shortdump

    Dear All,
    I have developed a ALV report. The report is a simple ALV report (Using REUSE_ALV_GRID_DISPLAY). When I am pressing the summation button at the top, it is giving a shortdump. The reason I have found out is the no. of columns are very large (45 to 50). Can anyone suggest how to handle this situation?
    Best wishes,
    Atanu

    Hi atanu,
    then you can use DO_SUM = 'X' (for the field which you want to sum option) in the fieldcat , this will try to sum while display it self.i mean in list display it will show the totals also.
    then you need not to explicitly click on SUM button.
    Regards
    vijay

  • How to give  push button in alv report  output

    hi,
    my requirement is that , i have to give push button in alv report output(item level) not in application toolbar, i am using reuse_alv_grid_display FM, can any body provide me sample code
    regards,
    siva kumar

    have a look at this thread, also has a sample report at the end from Uwe Schieferstein.
    [button on alv list|How to add and program a pushbutton on ALV grid line;
    seems not to work try this:
    How to add and program a pushbutton on ALV grid line
    Edited by: Micky Oestreich on May 15, 2008 10:20 PM

Maybe you are looking for

  • Report Navigation Issue after upgrading from 10g to 11g

    Hi Experts I have recently upgarded my solution from 10g to 11g. Issue is when I click on column value for navigation it doen't navigate the display remains unchanged 1) I have created new dashboard and placed this report in new dashboard the navigat

  • *** Can I add notes on the iPhone?

    I am thinking about buying an iPhone but one key component I need is to be able to add notes when I think of things. Is this possible to do on the iPhone or do all notes/apts need to originate in iCal and sync? Thanks in advance!

  • How to set an Application Item from PL/SQL

    I am attempting to set an Application Item After login to my app, I want to retrieve a row from my SETTINGS table and populate some Application Items with the settings information so that I can display some of that settings information on every page.

  • Importing iPhoto '09 library (8.1.2) into Aperture

    I have two older macbooks (purchased in mid-2007 and mid-2009) running 10.6.8 Snow Leopard, and I have recently purchased a new iMac. I was told at the Mac store that I would be able to import my old iPhoto libraries into my new iMac if I purchased A

  • Fixed tool bar in Java Web dyn pro

    Hi, I need to fix a toolbar at the top of screen, that should not scroll up when the page scrolls up. This needs to be done in JAVA Webdynpro. The scroll bars should nt scroll the toolbar upp while rest of the page is scrolled up. The user can scroll