ALV Grid left Most Button

Hi All,
I had created a ALV grid control. I want to handle the left most button of the alv grid, which when clicked , entire row gets selected.
I have to do some functionality when this button is clicked. So, can anybody help me in handling this button event.

How about just making the row a hotspot.  When user double clicks the row, trigger some functionality.
Here is a sample program
report zrich_0001.
data: begin of i_alv occurs 0,
      matnr type mara-matnr,
      maktx type makt-maktx,
      end of i_alv.
*       CLASS lcl_event_receiver DEFINITION      Handles Double Click
class lcl_event_receiver definition.
  public section.
    methods handle_double_click
      for event double_click of cl_gui_alv_grid
      importing e_row e_column.
  private section.
endclass.
*       CLASS lCL_EVENT_RECEIVER IMPLEMENTATION    Handles Double Click
class lcl_event_receiver implementation.
  method handle_double_click.
    perform drill_down using e_row-index.
  endmethod.
endclass.
data: alv_container  type ref to cl_gui_custom_container.
data: event_receiver type ref to lcl_event_receiver.
data: alv_grid       type ref to cl_gui_alv_grid.
data: layout    type lvc_s_layo.
data: fieldcat  type lvc_t_fcat.
selection-screen begin of block b1 with frame title text-001 .
select-options: s_matnr for i_alv-matnr.
selection-screen end of block b1.
start-of-selection.
  select * into corresponding fields of table i_alv
        from mara
          inner join makt
            on mara~matnr = makt~matnr
               where mara~matnr in s_matnr
                 and makt~spras = sy-langu.
  sort i_alv ascending by matnr.
  call screen 100.
*      Module  status_0100  OUTPUT
module status_0100 output.
  set pf-status '0100'.
  set titlebar '0100'.
  data: variant type  disvariant.
  variant-report = sy-repid.
  variant-username = sy-uname.
* Create Controls
  create object alv_container
         exporting
               container_name    = 'ALV_CONTAINER'.
  create object alv_grid
         exporting
               i_parent          =  alv_container.
*  Create Event Receiver
  create object event_receiver.
*  ALV Specific. Data selection.
*  Populate Field Catalog
  data: ls_fcat type lvc_s_fcat.
  refresh: fieldcat.
  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Number'.
  ls_fcat-coltext    = 'Material Number'.
  ls_fcat-fieldname  = 'MATNR'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '18'.
  ls_fcat-col_pos    = 1.
  append ls_fcat to fieldcat.
  clear: ls_fcat.
  ls_fcat-reptext    = 'Material Description'.
  ls_fcat-coltext    = 'Material Description'.
  ls_fcat-fieldname  = 'MAKTX'.
  ls_fcat-ref_table  = 'I_ALV'.
  ls_fcat-outputlen  = '40'.
  ls_fcat-col_pos    = 2.
  append ls_fcat to fieldcat.
* Set table for display
  call method alv_grid->set_table_for_first_display
      exporting
           is_layout              = layout
           is_variant             = variant
           i_save                 = 'U'
           i_structure_name       = 'I_ALV'
      changing
           it_outtab       = i_alv[]
           it_fieldcatalog = fieldcat[].
*   handler for ALV grid
  set handler event_receiver->handle_double_click for alv_grid.
endmodule.
*      Module  USER_COMMAND_0100  INPUT
module user_command_0100 input.
  case sy-ucomm.
    when 'BACK' or 'CANC'.
      if not alv_container is initial.
        call method alv_container->free.
        clear: alv_container.
        free : alv_container.
      endif.
      if sy-subrc = 0.
        set screen 0.
        leave screen.
      else.
        leave program.
      endif.
    when 'EXIT'.
      if not alv_container is initial.
        call method alv_container->free.
        clear: alv_container.
        free : alv_container.
      endif.
      leave program.
  endcase.
endmodule.
* DRILL_DOWN
form drill_down using index.
  read table i_alv index index.
  if sy-subrc = 0.
    set parameter id 'MAT' field i_alv-matnr.
    call transaction 'MM03' and skip first screen.
    if not alv_container is initial.
      call method alv_container->free.
      clear: alv_container.
      free : alv_container.
    endif.
  endif.
endform.
Regards,
Rich Heilman

Similar Messages

  • Alv Grid and Refresh Button

    Hello ;
    My Program is type of report, not a moduler program.
    And I’m using  the alv grid ,  But there isn’t refresh button ,I couldn’t see it.
    How can I see refresh button?
    Thanks.

    Hai
    Check the following Code
    REPORT z_alv_grid_ctrl_refresh_2.
    ALV Grid Control *
    This report reads and displays data from table MARA, using *
    the Method set_table_for_first_display of CL_GUI_ALV_GRID *
    Button 'NEXT_PAGE' : displays the next N records *
    Button 'PREV_PAGE' : displays the previous N records *
    Button 'FIRST_PAGE' : displays the first page *
    Button 'LAST_PAGE' : displays the last page *
    When the buttons Sort up, sort down, Filter, Delete Filter are *
    pressed, N record are still displayed *
    Steps : *
    - Create the report Z_ALV_GRID_CTRL_REFRESH_2 *
    - Create the Dynpro 0100 (size 27x120) *
    - Add OKCODE (type OK) in the element list *
    - Modify the flow logic of dynpro 0100 : *
    * PROCESS BEFORE OUTPUT. *
    MODULE pbo_0100. *
    * PROCESS AFTER INPUT. *
    MODULE user_command_0100. *
    - Create a status named 'MAIN' *
    with the buttons : REFRESH BACK EXIT *
    and the buttons : FIRST_PAGE PREV_PAGE NEXT_PAGE LAST_PAGE *
    Author : Michel PIOUD *
    Email : [email protected] HomePage : http://www.geocities.com/mpioud *
    CONSTANTS:
    c_first_page TYPE syucomm VALUE 'FIRST_PAGE',
    c_next_page TYPE syucomm VALUE 'NEXT_PAGE',
    c_prev_page TYPE syucomm VALUE 'PREV_PAGE',
    c_last_page TYPE syucomm VALUE 'LAST_PAGE'.
    TYPES:
    BEGIN OF ty_s_mara,
    ernam LIKE mara-ernam,
    matnr LIKE mara-matnr,
    ersda LIKE mara-ersda,
    brgew LIKE mara-brgew,
    END OF ty_s_mara.
    CLASS lcl_event_alv DEFINITION DEFERRED.
    DATA:
    gt_mara TYPE STANDARD TABLE OF ty_s_mara,
    go_container TYPE REF TO cl_gui_docking_container,
    go_alv_grid TYPE REF TO cl_gui_alv_grid,
    go_events TYPE REF TO lcl_event_alv,
    gt_mara_ftr TYPE STANDARD TABLE OF ty_s_mara, " Data filtered
    gt_mara_all TYPE STANDARD TABLE OF ty_s_mara, " Data readfrom DB
    okcode TYPE syucomm,
    gv_okcode TYPE syucomm.
    CLASS lcl_event_alv DEFINITION
    CLASS lcl_event_alv DEFINITION.
    PUBLIC SECTION.
    METHODS:
    h_user_command FOR EVENT after_user_command OF cl_gui_alv_grid
    IMPORTING e_ucomm
    sender.
    ENDCLASS. " LCL_EVENT_ALV DEFINITION
    Class (Implementation) lcl_event_alv
    CLASS lcl_event_alv IMPLEMENTATION.
    METHOD h_user_command.
    CASE e_ucomm.
    WHEN '&SORT_ASC' OR '&SORT_DSC'. " Sort
    PERFORM f_sort_big_table.
    PERFORM f_read_data USING c_first_page.
    PERFORM f_refresh_table.
    WHEN '&FILTER'. " Filter
    PERFORM f_filter_data.
    PERFORM f_read_data USING c_first_page.
    PERFORM f_refresh_table.
    WHEN '&DELETE_FILTER'. " Delete filter
    gt_mara_ftr[] = gt_mara_all[].
    PERFORM f_read_data USING c_first_page.
    PERFORM f_refresh_table.
    ENDCASE.
    ENDMETHOD. " user_command
    ENDCLASS. " LCL_EVENT_ALV
    SELECTION-SCREEN :
    BEGIN OF LINE,COMMENT 10(20) v_1 FOR FIELD p_max. "#EC NEEDED
    PARAMETERS p_max(2) TYPE n DEFAULT '30' OBLIGATORY.
    SELECTION-SCREEN END OF LINE.
    INITIALIZATION.
    v_1 = 'Lines per page'.
    START-OF-SELECTION.
    SELECT matnr ernam ersda brgew
    INTO TABLE gt_mara_all
    FROM mara.
    gt_mara_ftr[] = gt_mara_all[].
    PERFORM f_read_data USING c_first_page.
    CALL SCREEN 100.
    Module pbo_0100 OUTPUT
    MODULE pbo_0100 OUTPUT.
    SET PF-STATUS 'MAIN'.
    PERFORM create_and_init_alv.
    ENDMODULE. " PBO_0100 OUTPUT
    Module user_command_0100 INPUT
    MODULE user_command_0100 INPUT.
    gv_okcode = okcode.
    CLEAR okcode.
    CASE gv_okcode.
    WHEN 'BACK'.
    SET SCREEN 0.
    WHEN 'EXIT'.
    LEAVE PROGRAM.
    WHEN c_first_page OR c_next_page OR c_last_page OR c_prev_page.
    PERFORM f_read_data USING gv_okcode. " Update gt_mara
    PERFORM f_refresh_table.
    ENDCASE.
    ENDMODULE. " USER_COMMAND_0100 INPUT
    Form f_read_data
    FORM f_read_data USING u_ucomm TYPE syucomm.
    STATICS :
    l_1 TYPE sytabix,
    l_2 TYPE sytabix.
    DATA l_max TYPE sytabix. " Internal table size
    DESCRIBE TABLE gt_mara_ftr LINES l_max.
    CASE u_ucomm.
    WHEN c_first_page. " 1st page
    l_1 = 1.
    WHEN c_prev_page. " Previous page
    SUBTRACT p_max FROM l_1.
    IF l_1 < 1.
    l_1 = 1.
    ENDIF.
    WHEN c_next_page. " Next page
    IF l_1 IS INITIAL.
    l_1 = 1.
    ELSE.
    ADD p_max TO l_1.
    ENDIF.
    IF l_1 > l_max.
    l_1 = l_max.
    ENDIF.
    WHEN c_last_page. " Last page
    l_1 = l_max - p_max + 1.
    IF l_1 < 1.
    l_1 = 1.
    ENDIF.
    ENDCASE.
    l_2 = l_1 + p_max - 1.
    IF l_2 > l_max.
    l_2 = l_max.
    ENDIF.
    REFRESH gt_mara.
    IF l_max > 0.
    APPEND LINES OF gt_mara_ftr FROM l_1
    TO l_2
    TO gt_mara.
    ENDIF.
    ENDFORM. " F_READ_DATA
    Form create_and_init_alv
    FORM create_and_init_alv.
    Macro definition
    DEFINE m_fieldcat.
    add 1 to ls_alv_cat-col_pos.
    ls_alv_cat-fieldname = &1.
    ls_alv_cat-ref_table = 'MARA'.
    append ls_alv_cat to lt_alv_cat.
    END-OF-DEFINITION.
    DATA:
    ls_variant TYPE disvariant,
    lt_alv_cat TYPE lvc_t_fcat,
    ls_alv_cat TYPE lvc_s_fcat,
    ls_alv_lay TYPE lvc_s_layo,
    l_offline TYPE char1.
    CHECK go_container IS INITIAL.
    CALL METHOD cl_gui_alv_grid=>offline
    RECEIVING e_offline = l_offline.
    IF l_offline EQ 0.
    CREATE OBJECT go_container
    EXPORTING
    extension = 2000
    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 e208(00) WITH 'The control could not be created'.
    ENDIF.
    ENDIF.
    Create an instance of alv control
    CREATE OBJECT go_alv_grid
    EXPORTING i_parent = go_container.
    CREATE OBJECT go_events.
    SET HANDLER go_events->h_user_command FOR go_alv_grid.
    Build field catalog
    m_fieldcat 'ERNAM'.
    m_fieldcat 'MATNR'.
    m_fieldcat 'ERSDA'.
    m_fieldcat 'BRGEW'.
    Layout
    CLEAR ls_alv_lay.
    ls_alv_lay-zebra = 'X'.
    ls_alv_lay-cwidth_opt = 'X'.
    ls_variant-report = sy-cprog.
    Display
    CALL METHOD go_alv_grid->set_table_for_first_display
    EXPORTING
    is_variant = ls_variant
    is_layout = ls_alv_lay
    i_save = 'A'
    CHANGING
    it_outtab = gt_mara
    it_fieldcatalog = lt_alv_cat.
    ENDFORM. " CREATE_AND_INIT_ALV
    Form F_REFRESH_TABLE
    FORM f_refresh_table.
    DATA: ls_layout TYPE lvc_s_layo.
    CALL METHOD go_alv_grid->get_frontend_layout
    IMPORTING es_layout = ls_layout.
    ls_layout-cwidth_opt = 'X'.
    CALL METHOD go_alv_grid->set_frontend_layout
    EXPORTING is_layout = ls_layout.
    CALL METHOD go_alv_grid->refresh_table_display.
    ENDFORM. " F_REFRESH_TABLE
    Form F_SORT_BIG_TABLE
    FORM f_sort_big_table.
    DATA:
    lt_sort_kkblo TYPE kkblo_t_sortinfo,
    lt_sort TYPE lvc_t_sort.
    CALL METHOD go_alv_grid->get_sort_criteria
    IMPORTING et_sort = lt_sort.
    CHECK NOT lt_sort[] IS INITIAL.
    Format LVC --> KKBLO
    CALL FUNCTION 'LVC_TRANSFER_TO_KKBLO'
    EXPORTING
    it_sort_lvc = lt_sort
    IMPORTING
    et_sort_kkblo = lt_sort_kkblo.
    The big tables must be sorted like the small one
    PERFORM fb_outtab_sort(saplkkbl) TABLES gt_mara_ftr
    lt_sort_kkblo
    USING 'X'
    'X'.
    PERFORM fb_outtab_sort(saplkkbl) TABLES gt_mara_all
    lt_sort_kkblo
    USING 'X'
    'X'.
    ENDFORM. " F_SORT_BIG_TABLE
    Form f_filter_data
    FORM f_filter_data.
    DATA:
    lt_filter_lvc TYPE lvc_t_filt,
    lt_filter_index TYPE lvc_t_fidx WITH HEADER LINE.
    CALL METHOD go_alv_grid->get_filter_criteria
    IMPORTING et_filter = lt_filter_lvc.
    Find data to filter
    CALL FUNCTION 'LVC_FILTER_APPLY'
    EXPORTING
    it_filter = lt_filter_lvc
    IMPORTING
    et_filter_index = lt_filter_index[]
    TABLES
    it_data = gt_mara_all.
    gt_mara_ftr[] = gt_mara_all[].
    SORT lt_filter_index DESCENDING.
    LOOP AT lt_filter_index.
    DELETE gt_mara_ftr INDEX lt_filter_index.
    ENDLOOP.
    ENDFORM. " F_FILTER_DATA
    END OF PROGRAM Z_ALV_GRID_CTRL_REFRESH_2 ********************
    Thanks & regards
    Sreenivasulu P

  • Select row button not getting displayed in alv grid.

    Hi ,
    As per my requirement I am using tab strip in module pool.
    Each tab strip is containing one ALV.
    And user can change delete or create one record when the alv is displayed.
    The same should be saved in the database and ALV should be refreshed.
    When I am displaying the ALV the left most option of the ALV with which I can select the whole row is not coming.
    Because of which I am unable to call the method to get the selected row and delete or change accordingly.
    Why this button is not coming?
    I am using set_table_for_first_display in my program.
    Please help.

    Hi,
    In the method SET_TABLE_FOR_FIRST_DISPLAY, you will have to change the Selection Mode to 'A'. I guess you are not passing any values to the Layout parameters.
    Once you do that, you will find what your are looking for.
    Data : LA_LAYO type LVC_S_LAYO.
    LS_LAYO_SEL_MODE = 'A'.
    and pass this to the method's layout parameter.
    Cheers,
    SKC,

  • Button in alv grid cell using REUSE_ALV_GRID_DISPLAY

    Hi all,
      I want to make the contents of 2 columns of my alv grid as push button with values as text on it. I am not using classes or methods but alv grid fm. On clicking the button one dialog box has to pop up which gives edit option for the values in that coloumn, my question is how to introduce button in alv grid cell? if i can use t_fieldcatalog-icon, then please give me the complete steps for that.
    Thanks.

    this may helps u
    u need to copy stadard screen elemetn to MARATAB1(at PF -STATUS)
    You should copy the 'STANDARD' GUI status from program <b>SAPLSLVC_FULLSCREEN</b>
    type this one in SE41 program name is:<b>SAPLSLVC_FULLSCREEN</b>
    status : <b>STANDARD_FULLSCREEN</b>
    and copy it ...
             Type-pool
    type-pools slis.
             Tables
    tables: mara,sscrfields.
           Selection screen
    select-options: s_matnr for mara-matnr.
    PARAMETERS: p_email TYPE somlreci1-receiver.
    TYPES: BEGIN OF t_charmara,
      matnr(18)  TYPE c,                   " Material Number
      ernam(12)  TYPE c,                   " Person Credited
      aenam(12)  TYPE c,                   " Person Changed Object
      pstat(15)  TYPE c,                   " Maintenance Status
    END OF t_charmara.
             Data Declarations
    data: rt_extab    type slis_t_extab,   " Table of inactive function
                                           codes
          wa_charmara TYPE t_charmara,     " work area of mara Table
          fs_fieldcat type slis_t_fieldcat_alv,
                                           " Field catalog with field
                                           descriptions
          t_fieldcat  like line of fs_fieldcat,
                                           " Table of Field catalog
          r_ucomm     like sy-ucomm,       " User Command
          rs_selfield TYPE slis_selfield.  " cursor position ALV
    data: filedlayout   type slis_layout_alv,
          heading       type slis_t_listheader with header line,
          t_event       type slis_t_event.
    data: fs_event      like line of t_event.
    data: fs_sort type slis_sortinfo_alv,
           t_sort type slis_t_sortinfo_alv.
    data: w_char(200) type c,
          w_matnr     type mara-matnr.
    fs_sort-fieldname = 'MATNR'.
    fs_sort-up        = 'X'.
    fs_sort-group     = '*'.
    append fs_sort to t_sort.
    clear fS_sort.
    DATA:   t_packing_list  LIKE sopcklsti1 OCCURS 0 WITH HEADER LINE,
            t_contents      LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            t_receivers     LIKE somlreci1  OCCURS 0 WITH HEADER LINE,
            t_attachment    LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            t_object_header LIKE solisti1   OCCURS 0 WITH HEADER LINE,
            w_cnt           TYPE i,
            w_sent_all(1)   TYPE c,
            w_doc_data      LIKE sodocchgi1,
            gd_error        TYPE sy-subrc,
            gd_reciever     TYPE sy-subrc.
             Internal Tables
    data: begin of it_mara occurs 0,
            matnr like mara-matnr,         " Material Number
            ernam like mara-ernam,         " Person Credited
            aenam like mara-aenam,         " Person Changed Object
            pstat like mara-pstat,         " Maintenance Status
          end of it_mara.
    DATA:   it_message TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    DATA:   it_attach TYPE STANDARD TABLE OF solisti1 INITIAL SIZE 0
                    WITH HEADER LINE.
    *at selection-screen on field event
    AT SELECTION-SCREEN on s_matnr.
    PERFORM f0100_VALIDATE_MATERIAL_NUMBER.
    start-of-selection.
    retrive Data from the data base table Mara
    perform retrive_data_from_mara.
    end-of-selection.
    *Field catalog with field descriptions
    perform fieldcat.
    *perform top_of_page.
    PERFORM EVENT_LIST.
    *ALV Grid Display
    perform alv_display.
    Creating one Push button ENTER
    perform maratab1 USING    RT_EXTAB.
    *&      Form  f0100_VALIDATE_MATERIAL_NUMBER
          text
    There are no interface parameters to be passed to this subroutine
    FORM F0100_VALIDATE_MATERIAL_NUMBER .
    select matnr                          " Material Number
       from mara
      up to 1 rows
       into mara-matnr
      where matnr in s_matnr.
      endselect.
    IF sy-subrc NE 0.
          clear sscrfields-ucomm.
          MESSAGE e000 WITH 'Enter valid Material number'(003).
        ENDIF.                             " IF sy-subrc NE 0
    ENDFORM.                               " f0100_VALIDATE_MATERIAL_NUMBER
    *&      Form  retrive_data_from_mara
          text
    *There are no interface parameters to be passed to this subroutine
    FORM retrive_data_from_mara .
    select   matnr                         " Material Number
             ernam                         " Person Credited
             aenam                         " Person Changed Object
             pstat                         " Maintenance Status
        from mara
        into table It_mara
       where matnr in s_matnr.
    IF sy-subrc NE 0.
          MESSAGE i001 WITH 'Records are not found'.
          exit.
          stop.
        ENDIF.                             " IF sy-subrc NE 0
    ENDFORM.                               " retrive_data_from_mara
    *&      Form  fieldcat
          text
    *There are no interface parameters to be passed to this subroutine
    FORM fieldcat .
    *field catalog for MATNR
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'MATNR'.
      t_fieldcat-col_pos     = 1.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for ERNAM
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'ERNAM'.
      t_fieldcat-col_pos     = 2.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for AENAM
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'AENAM'.
      t_fieldcat-col_pos     = 3.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    *field catalog for PSTAT
      t_FIELDCAT-REF_TABNAME = 'MARA'.
      t_fieldcat-fieldname   = 'PSTAT'.
      t_fieldcat-col_pos     = 4.
      append t_fieldcat to fs_fieldcat.
      clear t_fieldcat.
    ENDFORM.                               " fieldcat
    *&      Form  EVENT_LIST
          text
    *There are no interface parameters to be passed to this subroutine
    FORM EVENT_LIST .
      fs_event-name ='TOP_OF_PAGE'.
      fs_event-form = 'TOP_PAGE'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
      fs_event-name ='END_OF_PAGE'.
      fs_event-form = 'END_PAGE'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
      fs_event-name ='END_OF_LIST'.
      fs_event-form = 'LIST_END'.
      append fs_event TO t_EVENT.
      CLEAR FS_EVENT.
    ENDFORM.                               " EVENT_LIST
    *&      Form  alv_display
          text
    *There are no interface parameters to be passed to this subroutine
    FORM alv_display .
    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       = 'MARATAB1'
       I_CALLBACK_USER_COMMAND        = 'USER_COMMAND'
      I_STRUCTURE_NAME               =
      IS_LAYOUT                      =
       IT_FIELDCAT                    = FS_FIELDCAT
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
       IT_SORT                        = T_SORT
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
       IT_EVENTS                      = T_EVENT
      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
      IR_SALV_LIST_ADAPTER           =
      IT_EXCEPT_QINFO                =
      I_SUPPRESS_EMPTY_DATA          = ABAP_FALSE
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
      TABLES
        T_OUTTAB                       = IT_MARA[]
    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.                               " alv_display
    form TOP_PAGE.
      data:tbl_listheader type slis_t_listheader,
            wa_listheader type slis_listheader .
       wa_listheader-typ = 'S'.
       wa_listheader-info = 'Created by : Vijay Pawar'.
       append wa_listheader to tbl_listheader.
       wa_listheader-typ = 'S'.
       concatenate ' Date ' sy-datum into
                  wa_listheader-info separated by space.
        append wa_listheader to tbl_listheader.
       wa_listheader-typ = 'S'.
       concatenate ' From ' s_matnr-low '  To  ' s_matnr-high into
                           wa_listheader-info separated by space.
       append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    endform.                               " form TOP_PAGE.
    form END_PAGE.
      STATICS W_PAGE TYPE I .
      data:tbl_listheader type slis_t_listheader,
            wa_listheader type slis_listheader .
      wa_listheader-typ   = 'S'.
      wa_listheader-info  = W_PAGE.
      append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    add 1 to w_page.
    endform.                               " form END_PAGE.
    form list_end.
      data:tbl_listheader type slis_t_listheader,
      wa_listheader type slis_listheader .
      wa_listheader-typ = 'S'.
      wa_listheader-info = '......................................Last Page'
      append wa_listheader to tbl_listheader.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
      EXPORTING
        IT_LIST_COMMENTARY       = tbl_listheader
      I_LOGO                   =
      I_END_OF_LIST_GRID       =
      I_ALV_FORM               =
    endform.                               " form list_end.
    *&      Form  maratab1
          text
         -->P_RT_EXTAB  text
    FORM maratab1  USING    P_RT_EXTAB.
      SET PF-STATUS 'MARATAB1' EXCLUDING rt_extab.
    ENDFORM.                               " maratab1
    FORM user_command  USING r_ucomm LIKE sy-ucomm
                         rs_selfield TYPE slis_selfield.
    case r_ucomm.
       when 'ENTER'.
       perform bulid_xls_data_table.
       PERFORM send_file_as_email_attachment
                                      tables it_message
                                             it_attach
                                       using p_email "'[email protected]'
                                    'Example .xls documnet attachment'
                                             'XLS'
                                             'filename'
                                    changing gd_error
                                             gd_reciever.
        perform populate_email_message_body.
        PERFORM initiate_mail_execute_program.
      endcase.                             " case r_ucomm.
    endform.                               " FORM user_command
    perform populate_email_message_body.
    PERFORM initiate_mail_execute_program.
         CALL FUNCTION 'RH_START_EXCEL_WITH_DATA'
    EXPORTING
       DATA_FILENAME             = 'MARA.XLS'
       DATA_PATH_FLAG            = 'W'
      DATA_ENVIRONMENT          =
       DATA_TABLE                = ITAB[]
      MACRO_FILENAME            =
      MACRO_PATH_FLAG           = 'E'
      MACRO_ENVIRONMENT         =
       WAIT                      = 'X'
      DELETE_FILE               = 'X'
    EXCEPTIONS
       NO_BATCH                  = 1
       EXCEL_NOT_INSTALLED       = 2
       INTERNAL_ERROR            = 3
       CANCELLED                 = 4
       DOWNLOAD_ERROR            = 5
       NO_AUTHORITY              = 6
       FILE_NOT_DELETED          = 7
       OTHERS                    = 8
       IF SY-SUBRC <> 0.
        MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
            WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
       ENDIF.
       leave to list-processing.
    endcase.
    *&      Form  bulid_xls_data_table
          text
    *There are no interface parameters to be passed to this subroutine
    FORM bulid_xls_data_table .
    CONSTANTS: con_cret TYPE x VALUE '0D',  "OK for non Unicode
                con_tab TYPE x VALUE '09'.   "OK for non Unicode
    *If you have Unicode check active in program attributes thnen you will
    *need to declare constants as follows
    *class cl_abap_char_utilities definition load.
    constants:
        con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB,
        con_cret type c value cl_abap_char_utilities=>CR_LF.
      CONCATENATE 'matnr' 'ernam' 'aenam' 'pstat'
             INTO it_attach SEPARATED BY con_tab.
      CONCATENATE con_cret it_attach  INTO it_attach.
      APPEND  it_attach.
      LOOP AT It_mara INTO wa_charmara.
        CONCATENATE wa_charmara-matnr wa_charmara-ernam
                    wa_charmara-aenam wa_charmara-pstat
               INTO it_attach SEPARATED BY con_tab.
        CONCATENATE con_cret it_attach  INTO it_attach.
        APPEND  it_attach.
      ENDLOOP.                             " LOOP AT it_mara INTO...
    ENDFORM.                               " bulid_xls_data_table
    *&      Form  send_file_as_email_attachment
       Send email
         -->P_IT_MESSAGE  text
         -->P_IT_ATTACH  text
         -->P_P_EMAIL  text
         -->P_0387   text
         -->P_0388   text
         -->P_0389   text
         -->P_0390   text
         -->P_0391   text
         -->P_0392   text
         <--P_GD_ERROR  text
         <--P_GD_RECIEVER  text
    FORM send_file_as_email_attachment tables pit_message
                                              pit_attach
                                        using p_email
                                              p_mtitle
                                              p_format
                                              p_filename
                                              p_attdescription
                                              p_sender_address
                                              p_sender_addres_type
                                     changing p_error
                                              p_reciever.
      DATA: ld_error               TYPE sy-subrc,
            ld_reciever            TYPE sy-subrc,
            ld_mtitle              LIKE sodocchgi1-obj_descr,
            ld_email               LIKE  somlreci1-receiver,
            ld_format              TYPE  so_obj_tp ,
            ld_attdescription      TYPE  so_obj_nam ,
            ld_attfilename         TYPE  so_obj_des ,
            ld_sender_address      LIKE  soextreci1-receiver,
            ld_sender_address_type LIKE  soextreci1-adr_typ,
            ld_receiver            LIKE  sy-subrc.
      ld_email               = p_email.
      ld_mtitle              = p_mtitle.
      ld_format              = p_format.
      ld_attdescription      = p_attdescription.
      ld_attfilename         = p_filename.
      ld_sender_address      = p_sender_address.
      ld_sender_address_type = p_sender_addres_type.
    Fill the document data.
      w_doc_data-doc_size = 1.
    Populate the subject/generic message attributes
      w_doc_data-obj_langu = sy-langu.
      w_doc_data-obj_name  = 'SAPRPT'.
      w_doc_data-obj_descr = ld_mtitle .
      w_doc_data-sensitivty = 'F'.
    Fill the document data and get size of attachment
      CLEAR w_doc_data.
      READ TABLE it_attach INDEX w_cnt.
      w_doc_data-doc_size =
         ( w_cnt - 1 ) * 255 + STRLEN( it_attach ).
      w_doc_data-obj_langu  = sy-langu.
      w_doc_data-obj_name   = 'SAPRPT'.
      w_doc_data-obj_descr  = ld_mtitle.
      w_doc_data-sensitivty = 'F'.
      CLEAR t_attachment.
      REFRESH t_attachment.
      t_attachment[] = pit_attach[].
    Describe the body of the message
      CLEAR t_packing_list.
      REFRESH t_packing_list.
      t_packing_list-transf_bin  = space.
      t_packing_list-head_start  = 1.
      t_packing_list-head_num    = 0.
      t_packing_list-body_start  = 1.
      DESCRIBE TABLE it_message LINES t_packing_list-body_num.
      t_packing_list-doc_type    = 'RAW'.
      APPEND t_packing_list.
    Create attachment notification
      t_packing_list-transf_bin = 'X'.
      t_packing_list-head_start = 1.
      t_packing_list-head_num   = 1.
      t_packing_list-body_start = 1.
      DESCRIBE TABLE t_attachment LINES t_packing_list-body_num.
      t_packing_list-doc_type   =  ld_format.
      t_packing_list-obj_descr  =  ld_attdescription.
      t_packing_list-obj_name   =  ld_attfilename.
      t_packing_list-doc_size   =  t_packing_list-body_num * 255.
      APPEND t_packing_list.
    Add the recipients email address
      CLEAR t_receivers.
      REFRESH t_receivers.
      t_receivers-receiver   = ld_email.
      t_receivers-rec_type   = 'U'.
      t_receivers-com_type   = 'INT'.
      t_receivers-notif_del  = 'X'.
      t_receivers-notif_ndel = 'X'.
      APPEND t_receivers.
      CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
           EXPORTING
                document_data              = w_doc_data
                put_in_outbox              = 'X'
                sender_address             = ld_sender_address
                sender_address_type        = ld_sender_address_type
                commit_work                = 'X'
           IMPORTING
                sent_to_all                = w_sent_all
           TABLES
                packing_list               = t_packing_list
                contents_bin               = t_attachment
                contents_txt               = it_message
                receivers                  = t_receivers
           EXCEPTIONS
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                OTHERS                     = 8.
    Populate zerror return code
      ld_error = sy-subrc.
    Populate zreceiver return code
      LOOP AT t_receivers.
        ld_receiver = t_receivers-retrn_code.
      ENDLOOP.
    ENDFORM.                               " send_file_as_email_attachment
    *&      Form  INITIATE_MAIL_EXECUTE_PROGRAM
          Instructs mail send program for SAPCONNECT to send email.
    FORM initiate_mail_execute_program.
      WAIT UP TO 2 SECONDS.
      SUBMIT rsconn01 WITH mode = 'INT'
                    WITH output = 'X'
                    AND RETURN.
    ENDFORM.                               " INITIATE_MAIL_EXECUTE_PROGRAM
    *&      Form  POPULATE_EMAIL_MESSAGE_BODY
           Populate message body text
    form populate_email_message_body.
      REFRESH it_message.
      it_message = 'Please find attached a list test mara records'.
      APPEND it_message.
    endform.                               "form populate_email_message_bod
    rewards if it helps u

  • Remove delete option from button 'Layout' ALV grid

    The ALV grid displays the button to change the layout (global/user specific).
    The user can create his/her own layout variant or change it. However, I would like to hide/remove the option 'Delete layout' from the possible options.
    Is this possible?
    Regards,
    Henry

    Henry,
    Since Layout DELETE button is part of another program, you can't simply exclude it from your ALV grid display.
    But, I suppose that layout deletion is possible only from the menu bar using 'Layout Management' and is not possible from the Application toolbar buttons of ALV grid. Also, all other functionalities for layout (new creation, change layout etc ) are possible without using this 'Layout Management' option from menu bar.
    So, I think you can meet your requirement hiding the 'Layout Management' option itself simply by excluding it from the grid.
    gs_excluding-fcode = '&ERW'.
      APPEND gs_excluding TO gt_excluding.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
        EXPORTING
          it_excluding                      = gt_excluding
    BR,
    Diwakar

  • ALV grid to ABAP list

    Hi ,
    I am displaying data in ALV grid, using a button I am updating Production orders, if the order is successfully updated, i need to write the text" Order updated" to list.
    I am using statement leave to list processing .
    the text is dislayed in list but i am not able to go BACK to ALV grid or selection screen.
    How to navigate to list from ALV and from list to ALV.

    My gut tells me you won't be going for BAL_DSP_LOG_DISPLAY and stick to list.
    In which case check if you also use
    LEAVE TO LIST-PROCESSING AND RETURN TO SCREEN 0.
      LEAVE SCREEN.
    and to get back to your screen:
    LEAVE LIST-PROCESSING
    edit.
    And do you have a PF-status when you're in the list? One with a back button?

  • How to make the first row  selected before the display of ALV grid

    Hello Experts,
    I created a ALV grid using custom container in a screen . Now i want do the follwing:
    1. i want that, the  <b>first line must be selected before the display of ALV.</b>
    2. I have selection buttons . But i dont want the multiselect button and the  
        standard  toolbar in the ALV grid.
    Could any one please help me regarding the above?
    Thanks & Regards
    Sudhansu

    can u pls explain in more details with an example?
    I am telling u the scenario.
    1. i have a screen(Modal dialog Box)  containing ALV grid with selection buttons for each row  (top part) and a subscreen(second part).
          Now when i click on a selection button, it will display the corresponding values in the subscreen.
        When this screen will display for the first time , then first row of the ALV grid should be selected and the corresponding values should be displayed in  the subscreen.
    i   wrote the following code in the PAI. But when i select a record its not triggering the PAI.
    DATA:
         gi_index_rows TYPE lvc_t_row, " Internal table for indexes of selected rows
         g_selected_row LIKE lvc_s_row, " Information about 1 row
         l_lines TYPE i.
      CLEAR g_wa_vdmeko.
    *get selected row
      CALL METHOD g_alv_grid->get_selected_rows
        IMPORTING
          et_index_rows = gi_index_rows.
      DESCRIBE TABLE gi_index_rows LINES l_lines.
      LOOP AT gi_index_rows INTO g_selected_row.
        READ TABLE g_int_vdmeko INDEX g_selected_row-index INTO g_wa_vdmeko.
        SELECT SINGLE  *
               FROM vdmepov
               WHERE bukrs = g_wa_vdmeko-bukrs AND
                     styp  = g_wa_vdmeko-styp  AND
                     sbez  = g_wa_vdmeko-sbez  AND
                     svym  = g_wa_vdmeko-svym  AND
                     svnr  = g_wa_vdmeko-svnr.
      ENDLOOP.
    I am displayinng the ALV using method "set_alv_for_first_display".
    Please help if u have any idea..................
    Thanks
    Sudhansu

  • How to implement functionkeys on the ALV GRID tool bar

    Hello All,
    I need to implement functionkeys(Ex.given below) to the standard buttons like Ascending order etc. on the ALVGRID Tool Bar . I have implementedObject orient concept( Methods) to display the out put.I tried by using set pf-status but it is not comming.
    Ex:
    ALV Grid Toll Bar Buttons                ( Func.Keys )      
    Print Preview                       ( CtrlShiftF10)
    Sort in Ascending order        ( Ctrl+F6 )
    Thanks in Advance.
    Vijay
    Edited by: Vijay Reddy on Aug 19, 2008 10:12 AM
    Edited by: Vijay Reddy on Aug 19, 2008 10:13 AM

    Hi,
    check this code,
    REPORT  zcl_timesheet_approval MESSAGE-ID zcl_msg.
    *  CLASS L_CL_EVENTS DEFINITION                                        *
    *  Class for inserting buttons on the toolbar                          *
    CLASS l_cl_events DEFINITION.
      PUBLIC SECTION.
        METHODS:
          toolbar FOR EVENT toolbar
                  OF cl_gui_alv_grid
                  IMPORTING e_object
                            e_interactive,
          user_command FOR EVENT user_command
                       OF cl_gui_alv_grid
                       IMPORTING e_ucomm .
    ENDCLASS.                              " L_CL_EVENTS DEFINITION
    *  CLASS L_CL_EVENTS IMPLEMENTATION                                    *
    *  Implementation of class L_CL_EVENTS                                 *
    CLASS l_cl_events IMPLEMENTATION.
      METHOD toolbar.
        PERFORM event_toolbar USING e_object.
      ENDMETHOD.                           " TOOLBAR
      METHOD user_command.
        PERFORM event_ucomm USING e_ucomm.
      ENDMETHOD.                           " USER_COMMAND
    ENDCLASS.                              " L_CL_EVENTS IMPLEMENTATION
    CONSTANTS:
       c_boolean_yes(1)     TYPE c         " Boolean - yes
                           VALUE 'X',
       c_approve_status(1)  TYPE c         " Approval status
                           VALUE 'A',
       c_rej_status(1)      TYPE c         " Rejected status
                           VALUE 'R',
       c_save_status(1)     TYPE c         " Save status
                           VALUE 'S',
       c_fcode_approve(7)   TYPE c         " Function code - APPROVE
                           VALUE 'APPROVE',
       c_fcode_rej(6)       TYPE c         " Function code - REJECT
                           VALUE 'REJECT',
       c_fcode_back(4)      TYPE c         " Function code - BACK
                           VALUE 'BACK',
       c_fcode_onli(4)      TYPE c         " Function code - EXECUTE
                           VALUE 'ONLI',
       c_fcode_exit(4)      TYPE c         " Function code - EXIT
                           VALUE 'EXIT',
       c_fcode_cancel(6)    TYPE c         " Function code - CANCEL
                           VALUE 'CANCEL',
       c_zero(1)            TYPE c         " Constant value 0
                           VALUE '0',
       c_alv_scr(7)         TYPE c         " GUI status : ALV screen
                           VALUE 'ALV_SCR'.
    * Field-string declarations...........................................
    DATA:
    * Field-string to build fieldcat.
       fs_fcat TYPE lvc_s_fcat,
    * Field-string for t_temp
       fs_temp TYPE type_s_temp.
    * Working variables...................................................
    * Internal table declarations........................................
    DATA:
    * Internal table to build fieldcat.
       t_fcat      TYPE lvc_t_fcat,
    * For ALV ...........................................................
    DATA:
    * To create instance for cl_gui_custom_container
      g_grid      TYPE REF TO cl_gui_custom_container,
    * To create instance for cl_gui_alv_grid
      g_alv       TYPE REF TO cl_gui_alv_grid,
    * To create instance for l_cl_events
      g_events    TYPE REF TO l_cl_events,
    * To assign name for custom container
      g_container TYPE scrfname VALUE 'CONTAINER',
    * To assign layout
      g_fcatlayo  TYPE lvc_s_layo.
    *            AT SELECTION-SCREEN EVENT                                 *
    AT SELECTION-SCREEN.
    * To perform user actions on the selection screen
      PERFORM user_command.
    *  MODULE  STATUS_0100  OUTPUT                                         *
    *  This module will create the objects for the instance and display    *
    *  the records                                                         *
    MODULE status_0100 OUTPUT.
      SET PF-STATUS c_alv_scr.
      PERFORM set_titlebar USING w_display.
    * If program executed in foreground.
      IF sy-batch IS INITIAL.
    * If g_grid is empty.
        IF g_grid IS INITIAL.
    * To create object for instance grid
          CREATE OBJECT g_grid
            EXPORTING
              container_name = g_container.
    * To create object for object grid
          CREATE OBJECT g_alv
            EXPORTING
              i_parent = g_grid.
        ELSE.
    *     IF W_SUBMIT EQ
          CALL METHOD g_alv->refresh_table_display.
        ENDIF.                             " IF G_GRID IS INITIAL
      ENDIF.                               " IF SY-BATCH IS INITIAL
      REFRESH t_fcat.
    * If w_display eq 'X' .
      IF w_display EQ c_boolean_yes.
    * To display all records except saved data
        PERFORM display_allrecords.
      ENDIF.                               " IF W_FLAG EQ C_BOOLEAN_YES
      IF w_submit EQ c_boolean_yes.
    * To display submitted records
        PERFORM submitted_records.
      ENDIF.                               " IF W_SUBMIT EQ C_BOOLEAN_YES
    ENDMODULE.                             " STATUS_0100  OUTPUT
    *  MODULE USER_COMMAND_0100  INPUT                                     *
    *  To perform user actions in the screen 100                           *
    MODULE user_command_0100 INPUT.
    * To update the data in the ALV grid
      PERFORM check_changed_data.
      w_okcode = ok_code.
      CLEAR ok_code.
      CASE w_okcode.
        WHEN c_fcode_back.
          LEAVE TO SCREEN 0.
        WHEN c_fcode_exit OR c_fcode_cancel.
          LEAVE PROGRAM.
      ENDCASE.                             " CASE W_OKCODE
    ENDMODULE.                             " USER_COMMAND_0100
    *  FORM BUILD_FCAT                                                     *
    *  To build the field catalog giving managers comment in editable mode *
    *  -->PR_Tabname   type lvc_tname                                      *
    *  -->PR_Fieldname type lvc_fname                                      *
    *  -->PR_Coltext   type lvc_txtcol                                     *
    *  -->PR_Colpos    type lvc_colpos                                     *
    FORM build_fcat USING pr_tabname   TYPE lvc_tname
                          pr_fieldname TYPE lvc_fname
                          pr_coltext   TYPE lvc_txtcol
                          pr_colpos    TYPE lvc_colpos.
      CLEAR fs_fcat.
      fs_fcat-tabname   = pr_tabname.
      fs_fcat-fieldname = pr_fieldname.
      fs_fcat-coltext   = pr_coltext.
      fs_fcat-col_pos   = pr_colpos.
      IF fs_fcat-fieldname EQ 'MNGCOMMENT'.
        fs_fcat-edit      = c_boolean_yes.
        fs_fcat-lowercase = c_boolean_yes.
        fs_fcat-dd_outlen = 60.
      ELSE.
        fs_fcat-edit      = space.
      ENDIF.                               " IF FS_FCAT-FIELDNAME...
      APPEND fs_fcat TO t_fcat.
    ENDFORM.                               " BUILD_FCAT
    *   FORM BUILD_FCATD                                                   *
    *  To build fieldcatalog in the display mode                           *
    *  -->pr_Tabname   type lvc_tname                                      *
    *  -->pr_Fieldname type lvc_fname                                      *
    *  -->pr_Coltext   type lvc_txtcol                                     *
    *  -->pr_Colpos    type lvc_colpos                                     *
    FORM build_fcatd USING pr_tabname   TYPE lvc_tname
                           pr_fieldname TYPE lvc_fname
                           pr_coltext   TYPE lvc_txtcol
                           pr_colpos    TYPE lvc_colpos .
      CLEAR fs_fcat.
      fs_fcat-tabname   = pr_tabname.
      fs_fcat-fieldname = pr_fieldname.
      fs_fcat-coltext   = pr_coltext.
      fs_fcat-col_pos   = pr_colpos.
      fs_fcat-edit      = space.
      APPEND fs_fcat TO t_fcat.
    ENDFORM.                               " BUILD_FCATD
    *  FORM ALV_DISPLAY                                                    *
    *  To display data in ALV                                              *
    *  --> pr_table type standard table                                    *
    *  --> pr_fcat  type lvc_t_fcat                                        *
    FORM alv_display USING pr_table TYPE STANDARD TABLE
                           pr_fcat  TYPE lvc_t_fcat .
    * Local data declaration....
      DATA: lt_exclude TYPE ui_functions.
    * To exclude buttons on the ALV grid
      PERFORM exclude_tb_functions CHANGING lt_exclude.
    * To display ALV
      CALL METHOD g_alv->set_table_for_first_display
        EXPORTING
          i_default            = space
          is_layout            = g_fcatlayo
          it_toolbar_excluding = lt_exclude
        CHANGING
          it_outtab            = pr_table[]
          it_fieldcatalog      = pr_fcat[].
    ENDFORM.                               " ALV_DISPLAY
    *  FORM EVENT_TOOLBAR                                                  *
    *  Setting toolbar in the alv grid                                     *
    *  -->E_OBJECT TYPE REF TO CL_ALV_EVENT_TOOLBAR_SET                    *
    FORM event_toolbar USING e_object
                             TYPE REF TO cl_alv_event_toolbar_set.
    * Local declaration for the button.
      DATA: ls_toolbar TYPE stb_button.
    * To add Approve button
      ls_toolbar-function  = c_fcode_approve.
      ls_toolbar-butn_type = c_zero.
      ls_toolbar-text      = text-001.
      APPEND ls_toolbar TO e_object->mt_toolbar.
    * To add Reject button
      CLEAR ls_toolbar.
      ls_toolbar-function  = c_fcode_rej.
      ls_toolbar-butn_type = c_zero.
      ls_toolbar-text      = text-013.
      APPEND ls_toolbar TO e_object->mt_toolbar.
    ENDFORM.                               " EVENT_TOOLBAR
    *  FORM EXCLUDE_TB_FUNCTIONS                                           *
    *  To exclude buttons from ALV grid                                    *
    *  <--> PR_EXCLUDE TYPE UI_FUNCTIONS                                   *
    FORM exclude_tb_functions  CHANGING pr_exclude TYPE ui_functions.
    * Local data declaration...
      DATA ls_exclude TYPE ui_func.
    * To remove the buttons on the ALV grid.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
      APPEND ls_exclude TO pr_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
      APPEND ls_exclude TO pr_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
      APPEND ls_exclude TO pr_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
      APPEND ls_exclude TO pr_exclude.
      ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
      APPEND ls_exclude TO pr_exclude.
    ENDFORM.                               " EXCLUDE_TB_FUNCTIONS
    *  FORM EVENT_UCOMM                                                    *
    *  After Input in the ALV grid,if user select record and press         *
    *  approve or reject then the record will get updated                  *
    *  --> PR_ucomm type sy-ucomm                                          *
    FORM event_ucomm USING pr_ucomm LIKE sy-ucomm.
      CASE pr_ucomm.
    * If e_ucomm contains 'APP' i.e.function code for Approve button
        WHEN c_fcode_approve.              " To approve selected record
          PERFORM app_timesheet USING c_approve_status.
    * If e_ucomm contains 'REJ' i.e. function code for Reject
        WHEN c_fcode_rej.                  " To reject selected record
          PERFORM app_timesheet USING c_rej_status.
      ENDCASE.                             " CASE E_UCOMM
    ENDFORM.                               " EVENT_UCOMM
    *  FORM APP_TIMESHEET                                                  *
    *  To get the selected records and update the records in database      *
    *   --> pr_status type char01                                          *
    FORM app_timesheet USING pr_status TYPE char01 .
    * Local data declaration......
      DATA:
       lt_marked_rows TYPE lvc_t_roid,     " Table to get rowid
       l_fs_marked_row LIKE LINE OF lt_marked_rows.
                                           " Field-string for lt_marked_rows
    * To get all the selected rows in the table lt_marked_rows
      CALL METHOD g_alv->get_selected_rows
        IMPORTING
          et_row_no = lt_marked_rows.
    * Reading each row id and updating the database.
      LOOP AT lt_marked_rows INTO l_fs_marked_row.
    * Reading the table t_timesheet with rowid
        READ TABLE t_timesheet INTO fs_timesheet INDEX
                                                 l_fs_marked_row-row_id.
    * If record is there in the table.
        IF sy-subrc EQ 0.
          CLEAR fs_timesheet-appstatus.
          GET PARAMETER ID 'ZEMPID' FIELD w_empid.
    * Changing the appstatus.
          fs_timesheet-appstatus = pr_status.
          fs_timesheet-approvedby = w_empid.
    * Updating the database table.
          UPDATE zcl_timesheet FROM fs_timesheet.
          IF sy-subrc EQ 0.
           fs_temp-empid = fs_timesheet-empid.
           fs_temp-workdate = fs_timesheet-workdate.
           fs_temp-linenum  = fs_timesheet-linenum.
           append fs_temp to t_temp.
          ENDIF.                           " IF SY-SUBRC EQ 0.
        ENDIF.                             " IF SY-SUBRC EQ 0
      ENDLOOP.                             " LOOP AT LT_MARKED_ROWS...
      perform delete_data .
      PERFORM refresh_table USING pr_status.
    ENDFORM.                               " APP_TIMESHEET
    *  FORM CHECK_CHANGED_DATA                                             *
    *  To change the data                                                  *
    *  No parameters are passsed to this subroutine                        *
    FORM check_changed_data .
    * To change the data.
      CALL METHOD g_alv->check_changed_data.
    ENDFORM.                               " CHECK_CHANGED_DATA
    *  FORM REFFRESH_TABLE                                                 *
    *  To refresh output table and  issue message according p_status       *
    *  -->PR_STATUS TYPE CHAR01                                            *
    FORM refresh_table  USING pr_status TYPE char01.
    * To refresh output table.
      CALL METHOD g_alv->refresh_table_display.
    * Depending upon pr_status message is given.
      IF pr_status EQ c_approve_status.
        MESSAGE s001.
      ELSE.
        MESSAGE s002.
      ENDIF.                               " IF P_STATUS EQ C_APPROVE_STATUS
    ENDFORM.                               " REFRESH_TABLE
    *  FORM SET_TITLEBAR                                                   *
    *  To set titlebar on the screen 100.                                  *
    *  -->PR_STATUS TYPE CHAR01                                            *
    FORM set_titlebar USING pr_status TYPE char01.
    * If pr_status eq 'X'.
      IF pr_status EQ c_boolean_yes.
        SET TITLEBAR c_alv_scr WITH text-017.
      ELSE.
        SET TITLEBAR c_alv_scr WITH text-018.
      ENDIF.                               " IF P_STATUS EQ C_BOOLEAN_YES
    ENDFORM.                               " SET_TITLEBAR
    *  FORM USER_COMMAND                                                   *
    *  According to sy-ucomm the action is performed in the screen 100     *
    *  No parameters are passsed to this subroutine                        *
    FORM user_command .
      CASE sy-ucomm.
    * If p_app is selected, submitted data will be displayed for approval
        WHEN c_fcode_onli OR c_fcode_approve.
          CLEAR sy-ucomm.
    * To display the submitted records.
          IF p_app EQ c_boolean_yes.
            w_submit = c_boolean_yes.
    * To get submitted records
            PERFORM get_data.
          ENDIF.                           " IF P_APP EQ C_BOOLEAN_YES
    * To display all records according to selection.
          IF p_disp EQ c_boolean_yes.
            w_display = c_boolean_yes.
    * To display
            PERFORM display_all.
            CLEAR w_display.
          ENDIF.                           " IF P_DISP EQ C_BOOLEAN_YES
         IF p_sdn EQ c_boolean_yes.
           PERFORM GET_GRAPH.
         ENDIF.
      ENDCASE.                             " CASE SY-UCOMM
    ENDFORM.                               " USER_COMMAND
    *  FORM  DISPLAY_ALLRECORDS                                            *
    *  To display all the records in the display mode                      *
    *  No parameters are passsed to this subroutine                        *
    FORM display_allrecords .
      CLEAR w_display.
      PERFORM build_fcatd USING 'T_TIME' 'WORKDATE'     text-002 '1'.
      PERFORM build_fcatd USING 'T_TIME' 'EMPID'        text-009 '2'.
      PERFORM build_fcatd USING 'T_TIME' 'PROJECTID'    text-003 '3'.
      PERFORM build_fcatd USING 'T_TIME' 'PROJECTNAME'  text-004 '4'.
      PERFORM build_fcatd USING 'T_TIME' 'OBJECTID'     text-005 '5'.
      PERFORM build_fcatd USING 'T_TIME' 'OBJECTNAME'   text-006 '6'.
      PERFORM build_fcatd USING 'T_TIME' 'ACTIVITYID'   text-007 '7'.
      PERFORM build_fcatd USING 'T_TIME' 'ACTIVITYNAME' text-008 '8'.
      PERFORM build_fcatd USING 'T_TIME' 'TIMEWORKED'   text-010 '9'.
      PERFORM build_fcatd USING 'T_TIME' 'DESCRIPTION'  text-011 '10'.
      PERFORM build_fcatd USING 'T_TIME' 'APPSTATUS'    text-012 '11'.
      PERFORM build_fcatd USING 'T_TIME' 'BILLSTATUS'   text-016 '12'.
      PERFORM build_fcatd USING 'T_TIME' 'SDNSTATUS'    text-019 '13'.
      PERFORM build_fcatd USING 'T_TIME' 'MNGCOMMENT'   text-014 '14'.
      PERFORM alv_display USING t_time t_fcat.
    ENDFORM.                               " DISPLAY_ALLRECORDS
    *  FORM SUBMITTED_RECORDS                                              *
    *  To display submitted records for the manager to approve             *
    *  No parameters are passsed to this subroutine                        *
    FORM submitted_records .
      CLEAR w_submit.
    * To create object for instance g_events
      CREATE OBJECT g_events.
    * If w_first equal to space
      IF w_first IS INITIAL.
        SET HANDLER g_events->toolbar
                FOR g_alv.
        w_first = c_boolean_yes.
      ENDIF.                               " IF W_FIRST IS INITIAL..
      SET HANDLER g_events->user_command
              FOR g_alv.
      g_fcatlayo-sel_mode = c_approve_status.
      REFRESH t_fcat.
      * to fill ur field cat table.
    ENDFORM.                               " SUBMITTED_RECORDS
    * FORM DELETE_DATA                                                     *
    * This form is used to delete thedata from output table after updating *
    * the database                                                         *
    * No parameters are passsed to this subroutine                         *
    form delete_data .
       loop at t_temp into fs_temp.
         loop at t_timesheet into fs_timesheet where
                             empid = fs_temp-empid
                         and workdate = fs_temp-workdate
                         and linenum = fs_temp-linenum.
          delete  t_timesheet index sy-tabix.
          endloop.                         " LOOP AT T_TEMP INTO FS_TEMP
       endloop .                           " LOOP AT T_TIMESHEET INTO FS_T..
    endform.                               " DELETE_DATA
    Hope it helps you.
    Regards
    Manjari.

  • ALV Grid Event Problem

    Hi,
    I have a dialog that contains an ALV grid and three buttons.  When the ALV grid is created, it's parent is specified as a custom container.
    Container
    data : g_custom_container type ref to cl_gui_custom_container.
    ALV Grid
    data : g_grid             type ref to cl_gui_alv_grid.
        create object g_custom_container
               exporting container_name = p_cont_name.
        create object g_grid
               exporting i_parent = g_custom_container
               I_APPL_EVENTS = 'X'.
    I would like the user to be able to just hit enter to accept the values displayed in the ALV.  My problem is that when the dialog is created, the ALV has focus so the event isn't getting to the PAI of the dialog.  If I click the mouse outside of the ALV to take focus away from the ALV, hitting the enter key does trigger the correct event in the dialog PAI.  How can I either set the focus outside of the ALV when the dialog loads, or make the ALV forward the event to the dialog.
    Thank you very much for any isight you can lend!
    John Richason

    Hi John, are you working with an editable ALV grid?  If so, the code below will allow an event to be fired when the user hits enter after the data has been changed.
               call method alv_grid->register_edit_event
                            exporting
                               i_event_id = cl_gui_alv_grid=>mc_evt_enter.
    You then need to create an event handler to handle the event being fired when the data is changed.
    *   create Event Receiver
              create object event_receiver.
    *   handler for ALV grid
              set handler event_receiver->handle_data_changed for alv_grid.
    REgards,
    Rich Heilman

  • Alv grid buttons

    Hi all,
    my requirement is to remove buttons in left side of grid output
    in existing alv grid report ,
    i am sending sample code of pls revert me with modification
    pls do needful
    TYPE-POOLS: slis.
    DATA: BEGIN OF i_data OCCURS 0,
    MATNR LIKE mara-MATNR,
    MTART LIKE mara-MTART,
    MATKL LIKE mara-MATKL,
    ws_row TYPE i,
    ws_char(5) TYPE c,
    chk,
    END OF i_data.
    DATA: report_id LIKE sy-repid.
    DATA: ws_title TYPE lvc_title VALUE 'An ALV Report'.
    DATA: i_layout TYPE slis_layout_alv.
    DATA: i_fieldcat TYPE slis_t_fieldcat_alv.
    DATA: i_events TYPE slis_t_event.
    DATA: i_header TYPE slis_t_listheader.
    DATA: i_extab TYPE slis_t_extab.
    SELECT MATNR MTART MATKL
    INTO TABLE i_data
    FROM mara up to 10 rows.
    *WHERE qmnum <= '00030000010'.
    LOOP AT i_data.
      i_data-ws_row = sy-tabix.
      i_data-ws_char = 'AAAAA'.
      MODIFY i_data.
    ENDLOOP.
    report_id = sy-repid.
    PERFORM f1000_layout_init CHANGING i_layout.
    PERFORM f2000_fieldcat_init CHANGING i_fieldcat.
    PERFORM f3000_build_header CHANGING i_header.
    PERFORM f4000_events_init CHANGING i_events.
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = 'X'
    I_BUFFER_ACTIVE = ' '
    i_callback_program = report_id
    *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 = ws_title
    I_GRID_SETTINGS =
    is_layout = i_layout
    it_fieldcat = i_fieldcat
    IT_EXCLUDING =
    IT_SPECIAL_GROUPS =
    IT_SORT =
    IT_FILTER =
    IS_SEL_HIDE =
    I_DEFAULT = 'X'
    i_save = 'U'
    IS_VARIANT = sy-repid
    it_events = i_events
    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_ADD_FIELDCAT =
    IT_HYPERLINK =
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER =
    ES_EXIT_CAUSED_BY_USER =
    TABLES
    t_outtab = i_data
    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 F1000_Layout_Init
    FORM f1000_layout_init USING i_layout TYPE slis_layout_alv.
      CLEAR i_layout.
      i_layout-colwidth_optimize = 'X'.
      i_layout-edit = 'X'.
      i_layout-zebra             = 'X'.
    ENDFORM. " F1000_Layout_Init
    *& Form f2000_fieldcat_init
    FORM f2000_fieldcat_init CHANGING i_fieldcat TYPE slis_t_fieldcat_alv.
      DATA: line_fieldcat TYPE slis_fieldcat_alv.
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'MATNR'. " The field name and the table
      line_fieldcat-tabname = 'I_DATA'. " name are the two minimum req.
      line_fieldcat-key = 'X'. " Specifies the column as a key (Blue)
    line_fieldcat-seltext_m = 'Notification No.'. " Column Header
      APPEND line_fieldcat TO i_fieldcat.
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'MTART'.
      line_fieldcat-ref_tabname = 'I_DATA'.
      line_fieldcat-hotspot = 'X'. " Shows the field as a hotspot.
    line_fieldcat-seltext_m = 'Notif Type'.
      APPEND line_fieldcat TO i_fieldcat.
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'MATKL'.
      line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Description'.
      APPEND line_fieldcat TO i_fieldcat.
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'WS_ROW'.
      line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_m = 'Row Number'.
      APPEND line_fieldcat TO i_fieldcat.
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'WS_CHAR'.
      line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Test Character Field'.
      line_fieldcat-datatype = 'CHAR'.
      line_fieldcat-outputlen = '15'. " You can specify the width of a
      APPEND line_fieldcat TO i_fieldcat. " column.
      CLEAR line_fieldcat.
      line_fieldcat-fieldname = 'CHK'.
      line_fieldcat-tabname = 'I_DATA'.
    line_fieldcat-seltext_l = 'Checkbox'.
      line_fieldcat-checkbox = 'X'. " Display this field as a checkbox
      line_fieldcat-edit = 'X'. " This option ensures that you can
      " edit the checkbox. Else it will
      " be protected.
      APPEND line_fieldcat TO i_fieldcat.
    ENDFORM. " f2000_fieldcat_init
    *& Form f3000_build_header
    FORM f3000_build_header USING i_header TYPE slis_t_listheader.
      DATA: gs_line TYPE slis_listheader.
      CLEAR gs_line.
      gs_line-typ = 'H'.
      gs_line-info = 'This is line of type HEADER'.
      APPEND gs_line TO i_header.
      CLEAR gs_line.
      gs_line-typ = 'S'.
      gs_line-key = 'STATUS 1'.
      gs_line-info = 'This is line of type STATUS'.
      APPEND gs_line TO i_header.
      gs_line-key = 'STATUS 2'.
      gs_line-info = 'This is also line of type STATUS'.
      APPEND gs_line TO i_header.
      CLEAR gs_line.
      gs_line-typ = 'A'.
      gs_line-info = 'This is line of type ACTION'.
      APPEND gs_line TO i_header.
    ENDFORM. " f3000_build_header
    *& Form f4000_events_init
    FORM f4000_events_init CHANGING i_events TYPE slis_t_event.
      DATA: line_event TYPE slis_alv_event.
      CLEAR line_event.
      line_event-name = 'TOP_OF_PAGE'.
      line_event-form = 'F4100_TOP_OF_PAGE'.
      APPEND line_event TO i_events.
      CLEAR line_event.
      line_event-name = 'PF_STATUS_SET'.
      line_event-form = 'F4200_PF_STATUS_SET'.
      APPEND line_event TO i_events.
    ENDFORM. " f3000_events_init
    FORM F4100_TOP_OF_PAGE *
    FORM f4100_top_of_page.
      CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
        EXPORTING
          it_list_commentary = i_header.
    ENDFORM.                    "f4100_top_of_page
    FORM F4200_PF_STATUS_SET *
    FORM f4200_pf_status_set USING i_extab TYPE slis_t_extab.
      REFRESH i_extab.
      PERFORM f4210_exclude_fcodes CHANGING i_extab.
      SET PF-STATUS 'STANDARD' OF PROGRAM 'SAPLSALV'." EXCLUDING i_extab.
    ENDFORM.                    "f4200_pf_status_set
    *& Form f4210_exclude_fcodes
    FORM f4210_exclude_fcodes USING i_extab TYPE slis_t_extab.
      DATA: ws_fcode TYPE slis_extab.
      CLEAR ws_fcode.
      ws_fcode = '&EB9'. " Call up Report.
      APPEND ws_fcode TO i_extab.
      ws_fcode = '&ABC'. " ABC Analysis.
      APPEND ws_fcode TO i_extab.
      ws_fcode = '&NFO'. " Info Select.
      APPEND ws_fcode TO i_extab.
      ws_fcode = '&LFO'. " Information.
      APPEND ws_fcode TO i_extab.
    ENDFORM. " f4210_exclude_fcodes

    Nagendra k,
    Instead of doing the way u are doing just try this way.
    Define excluding function codes table
      data:
            i_EXTAB TYPE SLIS_T_EXTAB OCCURS 0 WITH HEADER LINE.
    Build the table with function codes for which buttons u dont wat.
      i_extab-fcode = '&EB9'.
      APPEND  i_extab.
      CLEAR   i_extab.
      i_extab-fcode = '&ABC'.
      APPEND  i_extab.
      CLEAR   i_extab.
    i_extab-fcode = '&NFO'.
      APPEND  i_extab.
      CLEAR   i_extab.
      i_extab-fcode = '&LFO'.
      APPEND  i_extab.
      CLEAR   i_extab.
    Pass that table through FM REUSE_ALV_GRID_DISPLAY.
      DATA :l_program TYPE sy-repid.
      l_program = sy-repid.
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
        EXPORTING
          i_callback_program          = l_program
    *      i_callback_top_of_page      = 'TOP_OF_PAGE'
          i_callback_html_top_of_page = 'TOP_OF_PAGE'
          IT_EXCLUDING                = i_extab
          is_layout                   = w_layout
          it_events                   = i_events
          it_fieldcat                 = i_fieldcat
        TABLES
          t_outtab                    = i_pa0001.
      IF sy-subrc <> 0.
        MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
      ENDIF.
    I hope that it helps u .
    Regards,
    Venkat.O

  • Position button at the end of ALV grid

    Hi,
    I have a requirement to place position button (like in OB52 or any table/view maintenance ) to search and position the record on the top of list. I have placed the position pushbutton with function code and have called TABLE_GET_KEY_TO_SET_CUR_ROW for the input . My alv grid doesn't show the toolbar till the records cross one page. can you please suggest 1- how to make the scrollbar visible always ? 2- How to make the position button work as in tables for ALV grid?
    Regards,
    Garima

    I have created the pushbutton in the same screen as container and assigned a function code. I have put this logic in user-command for this button and refreshed display. But it doesn't work, moreover the scrollbar is not visible if the records are less than one page.
    MODULE USER_COMMAND_0100 INPUT.
      CASE SY-UCOMM.
        WHEN '&BACK&'.
          LEAVE TO SCREEN 0.
        WHEN '&EXIT&'.
          LEAVE PROGRAM.
        WHEN '&POSI&'.
          DATA: LV_EBELN(15) TYPE C,
                IT_EXCL TYPE VIMEXCLFLD OCCURS 0,
          WA_EXCL TYPE VIMEXCLFLD,
          LV_PO TYPE EKKO-EBELN.
          DATA: LT_CELL1 TYPE TABLE OF LVC_S_ROID,
           LS_ROW_ID TYPE LVC_S_ROID,
           LS_COL_ID TYPE LVC_S_COL.
          DATA: LWA_CELL1 LIKE LINE OF LT_CELL1.
          WA_EXCL-FIELDNAME = 'MANDT'.
          APPEND WA_EXCL TO IT_EXCL.
          CALL FUNCTION 'TABLE_GET_KEY_TO_SET_CUR_ROW'
            EXPORTING
              TABLE             = 'EKKO'
            IMPORTING
              TABLE_KEY         = LV_EBELN
            TABLES
              EXCLUDE_FIELDS    = IT_EXCL
            EXCEPTIONS
              CANCELLED_BY_USER = 1
              TABLE_NOT_FOUND   = 2
              OTHERS            = 3.
          IF SY-SUBRC EQ 0.
            SHIFT LV_EBELN LEFT DELETING LEADING SPACE.
            MOVE LV_EBELN+0(10) TO LV_PO.
            READ TABLE GT_FINAL INTO WA_FINAL WITH KEY EBELN = LV_PO.
            CALL METHOD R_GRID->GET_SCROLL_INFO_VIA_ID
             iMPORTING
                ES_ROW_NO   = LS_ROW_ID
                ES_COL_INFO = LS_COL_ID.
            LS_ROW_ID-ROW_ID = sy-tabix.
            LS_COL_ID-FIELDNAME = 'EKGRP'.
            data: ls_row type LVC_S_ROW,
           ls_col type LVC_S_COL.
    ls_row-index = 2.
    CALL METHOD r_grid->set_scroll_info_via_id
       EXPORTING
         IS_ROW_INFO = ls_row
         is_col_info = ls_col.
          ENDIF.
        **Row and column of the alv are refreshed after changing values
      STABLE-ROW = 'X'.
      STABLE-COL = 'X'.
    *REfreshed ALV display with the changed values
    *This ALV is non editable and contains new values
      CALL METHOD R_GRID->REFRESH_TABLE_DISPLAY
        EXPORTING
          IS_STABLE = STABLE
        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.
    Please help!!

  • Adding button in the secondary list and alv grid

    Hi all ,
                i have devloped an alv grid interactive report as below, my problem is i want to add some button in the secondary list and do some interactions. but i dont know how to do that. i m sending u my code below ,,, plzz suggest what can be done do add that.
    <code>
    *& Report  Z_demo_SALESDOC
    REPORT  z_demo_salesdoc.
    TABLES: vbak, vbap.
    TYPE-POOLS:slis.
    DATA: BEGIN OF it_vbak OCCURS 0,
           vbeln TYPE vbak-vbeln,
           ernam TYPE vbak-ernam,
           erdat TYPE vbak-erdat,
           auart TYPE vbak-auart,
           END OF it_vbak.
    DATA: BEGIN OF it_vbap OCCURS 0,
           vbeln TYPE vbap-vbeln,
           posnr TYPE vbap-vbeln,
           matnr TYPE vbap-matnr,
           zmeng TYPE vbap-zmeng,
           netwr TYPE vbap-netwr,
           END OF it_vbap.
    DATA:it_event TYPE slis_t_event.
    DATA: t_field TYPE slis_t_fieldcat_alv,
          w_field TYPE slis_fieldcat_alv,
          t_field1 TYPE slis_t_fieldcat_alv,
          w_field1 TYPE slis_fieldcat_alv,
          w_layout TYPE slis_layout_alv,
          t_sort TYPE slis_t_sortinfo_alv,
          w_sort TYPE slis_sortinfo_alv.
    CONSTANTS: c_top_of_page  TYPE slis_formname VALUE 'TOP_OF_PAGE',
               c_usercommand  TYPE slis_formname VALUE 'USER_COMMAND'.
    SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.
    SELECT-OPTIONS: s_vbeln FOR vbak-vbeln MODIF ID m1,
                    s_erdat FOR vbak-erdat MODIF ID m2.
    SELECTION-SCREEN END OF BLOCK B1.
    SELECTION-SCREEN SKIP.
    SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-001.
    PARAMETERS:rb1 RADIOBUTTON GROUP g1 USER-COMMAND us1,
               rb2 RADIOBUTTON GROUP g1 DEFAULT 'X'.
    SELECTION-SCREEN END OF BLOCK B2.
    AT SELECTION-SCREEN OUTPUT.
      IF rb1 = 'X'.
        LOOP AT SCREEN.
          IF screen-group1    = 'M1'.
         IF screen-name    CS 'S_VBELN'.
            screen-active    = '0'.
           screen-input     = '0'.
          screen-output    = '0'.
          screen-invisible = '1'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
      IF rb2 = 'X'.
        LOOP AT SCREEN.
          IF screen-group1    = 'M2'.
            screen-active    = '0'.
           screen-input     = '0'.
          screen-output    = '0'.
          screen-invisible = '0'.
            MODIFY SCREEN.
          ENDIF.
        ENDLOOP.
      ENDIF.
    AT SELECTION-SCREEN.
      DATA: v_vbeln LIKE vbak-vbeln.
      SELECT SINGLE vbeln
                      FROM vbak
                      INTO (v_vbeln)
                      WHERE vbeln IN s_vbeln .
      IF sy-subrc <> 0.
        MESSAGE e001(q) WITH 'Invalid Sales document'.
      ENDIF.
      DATA: v_erdat LIKE vbak-erdat.
      SELECT SINGLE erdat
                      FROM vbak
                      INTO (v_erdat)
                      WHERE erdat IN s_erdat.
      IF sy-subrc <> 0.
        MESSAGE e001(q) WITH 'No document available with given date'.
      ENDIF.
    START-OF-SELECTION.
      PERFORM get_data_vbak.
      PERFORM build_field_catalog.
    PERFORM fill_event.
      PERFORM print_data_vbak.
    END-OF-SELECTION.
    *&      Form  get_data_vbak
          text
    -->  p1        text
    <--  p2        text
    FORM get_data_vbak .
      SELECT vbeln ernam erdat auart
                                FROM vbak
                                INTO TABLE it_vbak
                                WHERE vbeln IN s_vbeln AND erdat IN s_erdat.
    ENDFORM.                    " get_data_vbak
    *&      Form  build_field_catalog
          text
    -->  p1        text
    <--  p2        text
    FORM build_field_catalog .
      w_field-col_pos = 1.
      w_field-fieldname = 'VBELN'.
      w_field-tabname = 'IT_VBAK'.
      w_field-seltext_m = 'Sales Order'.
      w_field-emphasize = 'C710'.
      APPEND w_field TO t_field.
      CLEAR w_field.
      w_field-col_pos = 2.
      w_field-fieldname = 'ERNAM'.
      w_field-tabname = 'IT_VBAK'.
      w_field-seltext_m = 'Created by'.
      w_field-emphasize = 'C710'.
      APPEND w_field TO t_field.
      CLEAR w_field.
      w_field-col_pos = 3.
      w_field-fieldname = 'ERDAT'.
      w_field-tabname = 'IT_VBAK'.
      w_field-seltext_m = 'Created Date'.
      w_field-emphasize = 'C710'.
      APPEND w_field TO t_field.
      CLEAR w_field.
      w_field-col_pos = 4.
      w_field-fieldname = 'AUART'.
      w_field-tabname = 'IT_VBAK'.
      w_field-seltext_m = 'Order type'.
      w_field-emphasize = 'C710'.
      APPEND w_field TO t_field.
      CLEAR w_field.
      w_sort-spos = 1.
      w_sort-fieldname = 'VBELN'.
      w_sort-up = 'X'.
      APPEND w_sort TO t_sort.
      w_layout-colwidth_optimize = 'X'.
    ENDFORM.                    " build_field_catalog
    *&      Form  user_command
          text
         -->RF_UCOMM     text
         -->RS_SELFIELD  text
    FORM user_command USING rf_ucomm    TYPE sy-ucomm
                            rs_selfield TYPE slis_selfield.
      CASE rf_ucomm.
        WHEN '&IC1'.
          IF rs_selfield-fieldname = 'VBELN'.
            READ TABLE it_vbak INDEX rs_selfield-tabindex.
            IF sy-subrc = 0.
              PERFORM get_data_vbap.
              PERFORM build_field_catalog2.
              PERFORM print_field_data.
            ENDIF.
          ENDIF.
      ENDCASE.
    ENDFORM.                    "user_command
    *&      Form  print_data_vbak
          text
    -->  p1        text
    <--  p2        text
    FORM print_data_vbak .
      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           = 'USER_COMMAND'
      I_CALLBACK_TOP_OF_PAGE            = ' '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  = I_STRUCTURE_NAME
      I_BACKGROUND_ID                   = ' '
      I_GRID_TITLE                      = I_GRID_TITLE
      I_GRID_SETTINGS                   = I_GRID_SETTINGS
         is_layout                         = w_layout
       it_fieldcat                       = t_field[]
      IT_EXCLUDING                      = IT_EXCLUDING
      IT_SPECIAL_GROUPS                 = IT_SPECIAL_GROUPS
       it_sort                           = t_sort
      IT_FILTER                         = IT_FILTER
      IS_SEL_HIDE                       = IS_SEL_HIDE
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        = IS_VARIANT
      it_events                         = it_event[]
      IT_EVENT_EXIT                     = IT_EVENT_EXIT
      IS_PRINT                          = IS_PRINT
      IS_REPREP_ID                      = 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_ALV_GRAPHICS
      IT_HYPERLINK                      = IT_HYPERLINK
      IT_ADD_FIELDCAT                   = IT_ADD_FIELDCAT
      IT_EXCEPT_QINFO                   = IT_EXCEPT_QINFO
      IR_SALV_FULLSCREEN_ADAPTER        = IR_SALV_FULLSCREEN_ADAPTER
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           = E_EXIT_CAUSED_BY_CALLER
      ES_EXIT_CAUSED_BY_USER            = ES_EXIT_CAUSED_BY_USER
        TABLES
          t_outtab                          = it_vbak
    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.                    " print_data_vbak
    *&      Form  fill_event
          text
    FORM fill_event .
      DATA : st_event TYPE slis_alv_event.
    *- Clear.
      CLEAR : st_event, it_event[].
    *- Local variable
      DATA : l_tabix TYPE sy-tabix.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = it_event
        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 event table
      READ TABLE it_event WITH KEY name = slis_ev_user_command
                           INTO st_event.
    *- Clear
      CLEAR l_tabix.
      l_tabix = sy-tabix.
    *- Check subrc
      IF sy-subrc = 0.
        st_event-form = c_usercommand.
    *- Modify
        MODIFY it_event FROM st_event INDEX l_tabix.
    *- Clear
        CLEAR st_event.
      ENDIF.
    ENDFORM.                    " fill_event
    *&      Form  get_data_vbap
          text
    FORM get_data_vbap .
      IF NOT it_vbak[] IS INITIAL.
        SELECT vbeln
               posnr
               matnr
               zmeng
               netwr
            FROM vbap
            INTO TABLE it_vbap
            WHERE vbeln = it_vbak-vbeln.
        IF sy-subrc = 0.
          SORT it_vbap BY vbeln.
        ENDIF.
      ENDIF.
    ENDFORM.                    " get_data_vbap
    *&      Form  build_field_catalog2
          text
    FORM build_field_catalog2 .
      CLEAR:t_field1,w_field1.
      w_field1-col_pos = 1.
      w_field1-fieldname = 'VBELN'.
      w_field1-tabname = 'IT_VBAP'.
      w_field1-seltext_m = 'Sales Order'.
      w_field1-emphasize = 'C710'.
      APPEND w_field1 TO t_field1.
      CLEAR w_field1.
      w_field1-col_pos = 2.
      w_field1-fieldname = 'POSNR'.
      w_field1-tabname = 'IT_VBAP'.
      w_field1-seltext_m = 'Sales Doc Item'.
      w_field1-emphasize = 'C710'.
      APPEND w_field1 TO t_field1.
      CLEAR w_field1.
      w_field1-col_pos = 3.
      w_field1-fieldname = 'MATNR'.
      w_field1-tabname = 'IT_VBAP'.
      w_field1-seltext_m = 'Material No'.
      w_field1-emphasize = 'C710'.
      APPEND w_field1 TO t_field1.
      CLEAR w_field1.
      w_field1-col_pos = 4.
      w_field1-fieldname = 'ZMENG'.
      w_field1-tabname = 'IT_VBAP'.
      w_field1-seltext_m = 'Target quan units'.
      w_field1-emphasize = 'C710'.
      APPEND w_field1 TO t_field1.
      CLEAR w_field1.
      w_field1-col_pos = 5.
      w_field1-fieldname = 'NETWR'.
      w_field1-tabname = 'IT_VBAP'.
      w_field1-seltext_m = 'Net value dc cu'.
      w_field1-emphasize = 'C710'.
      APPEND w_field1 TO t_field1.
      CLEAR w_field1.
    ENDFORM.                    " build_field_catalog2
    *&      Form  print_field_data
          text
    FORM print_field_data .
    SET PF-STATUS 'VBAP'.
      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_STRUCTURE_NAME
      I_BACKGROUND_ID                   = ' '
         i_grid_title                      = 'VBAP DETAILS'
      I_GRID_SETTINGS                   = I_GRID_SETTINGS
      IS_LAYOUT                         = IS_LAYOUT
         it_fieldcat                       = t_field1[]
      IT_EXCLUDING                      = IT_EXCLUDING
      IT_SPECIAL_GROUPS                 = IT_SPECIAL_GROUPS
      IT_SORT                           = IT_SORT
      IT_FILTER                         = IT_FILTER
      IS_SEL_HIDE                       = IS_SEL_HIDE
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        = IS_VARIANT
      IT_EVENTS                         = IT_EVENTS
      IT_EVENT_EXIT                     = IT_EVENT_EXIT
      IS_PRINT                          = IS_PRINT
      IS_REPREP_ID                      = 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_ALV_GRAPHICS
      IT_HYPERLINK                      = IT_HYPERLINK
      IT_ADD_FIELDCAT                   = IT_ADD_FIELDCAT
      IT_EXCEPT_QINFO                   = IT_EXCEPT_QINFO
      IR_SALV_FULLSCREEN_ADAPTER        = IR_SALV_FULLSCREEN_ADAPTER
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           = E_EXIT_CAUSED_BY_CALLER
      ES_EXIT_CAUSED_BY_USER            = ES_EXIT_CAUSED_BY_USER
        TABLES
          t_outtab                          = it_vbap
       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.                    " print_field_data
    </code>

    Hi Satya..
    This is the Sample code...
    DATA : V_FORM_GUI TYPE SLIS_FORMNAME VALUE 'F_GUI'.  "Form name
    **Secondary List
    FORM print_field_data .
    SET PF-STATUS 'VBAP'.  "This statement will not work for ALV
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
    I_INTERFACE_CHECK = ' '
    I_BYPASSING_BUFFER = ' '
    I_BUFFER_ACTIVE = ' '
    i_callback_program = sy-repid
    <b> I_CALLBACK_PF_STATUS_SET = V_FORM_GUI  
                                                      "Subroutine in which GUI status is called</b>
    I_CALLBACK_USER_COMMAND = 'F_USER_COMMAND'   "To handle GUI
    I_CALLBACK_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_TOP_OF_PAGE = ' '
    I_CALLBACK_HTML_END_OF_LIST = ' '
    I_STRUCTURE_NAME = I_STRUCTURE_NAME
    I_BACKGROUND_ID = ' '
    i_grid_title = 'VBAP DETAILS'
    I_GRID_SETTINGS = I_GRID_SETTINGS
    IS_LAYOUT = IS_LAYOUT
    it_fieldcat = t_field1[]
    IT_EXCLUDING = IT_EXCLUDING
    IT_SPECIAL_GROUPS = IT_SPECIAL_GROUPS
    IT_SORT = IT_SORT
    IT_FILTER = IT_FILTER
    IS_SEL_HIDE = IS_SEL_HIDE
    I_DEFAULT = 'X'
    I_SAVE = ' '
    IS_VARIANT = IS_VARIANT
    IT_EVENTS = IT_EVENTS
    IT_EVENT_EXIT = IT_EVENT_EXIT
    IS_PRINT = IS_PRINT
    IS_REPREP_ID = 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_ALV_GRAPHICS
    IT_HYPERLINK = IT_HYPERLINK
    IT_ADD_FIELDCAT = IT_ADD_FIELDCAT
    IT_EXCEPT_QINFO = IT_EXCEPT_QINFO
    IR_SALV_FULLSCREEN_ADAPTER = IR_SALV_FULLSCREEN_ADAPTER
    IMPORTING
    E_EXIT_CAUSED_BY_CALLER = E_EXIT_CAUSED_BY_CALLER
    ES_EXIT_CAUSED_BY_USER = ES_EXIT_CAUSED_BY_USER
    TABLES
    t_outtab = it_vbap
    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. " print_field_data
    FORM F_GUI USING rt_extab TYPE slis_t_extab.
    SET PF-STATUS 'GUI_1'.  "Double click and Create this GUI status and add buttons
    ENDFORM.
    <b><REMOVED BY MODERATOR></b>
    Message was edited by:
            Alvaro Tejada Galindo

  • Button in ALV Grid

    Hi ,
    I want to display a ALV Grid layout output and on that I want to insert a button on the application bar .When I click on it I should call a screen and dispaly that out on that screen .
    Prg :
    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
       EXPORTING
         i_callback_program                = 'ZL_NAV'
         I_CALLBACK_PF_STATUS_SET          = 'ZL_PF_STATUS'
      I_CALLBACK_USER_COMMAND           = ' '
      I_CALLBACK_TOP_OF_PAGE            = ' '
          i_structure_name                  = 'ZLT_MARKET_VALUE'
          is_layout                         =  gs_layout
          i_save                            =  g_save
      IT_FIELDCAT                       =
      IT_EVENTS                         =
        TABLES
          t_outtab                          = i_market_value
    EXCEPTIONS
      PROGRAM_ERROR                     = 1
      OTHERS                            = 2
      IF sy-subrc <> 0.
      ENDIF.
    Iam settingthe pf status as 'ZL_PF_STATUS' and writing the sub routine for the same.
    form 'ZL_PF_STATUS'
    set pf-status = 'NAVDISP' .
    endform .
    But iam getting a dump that there are one actual parameter and zero formal parameters .
    Help in this regard
    Bye
    Santosh ..

    Hello!
    Take this code:
    Regards
    Ilhan
    TYPE-POOLS: col, icon.
    DATA:
      BEGIN OF wa_sflight.
    INCLUDE TYPE sflight.
    DATA: color(4),
        light,  "graphical indicator for booking status
        it_field_colors TYPE lvc_t_scol, "for cell highlighting
        changes_possible TYPE icon-id,
      END OF wa_sflight,
      it_sflight LIKE TABLE OF wa_sflight.
    DATA:
      ok_code LIKE sy-ucomm.
    DATA:
      alv TYPE REF TO cl_gui_alv_grid,
      cont TYPE REF TO cl_gui_custom_container.
    DATA: my_variant TYPE disvariant,
          my_print TYPE lvc_s_prnt.
    DATA:
      wa_layout TYPE lvc_s_layo,
      wa_field_color LIKE LINE OF wa_sflight-it_field_colors.
    DATA:
      it_field_cat TYPE lvc_t_fcat,
      wa_field_cat LIKE LINE OF it_field_cat.
    DATA:
      bookings_total TYPE i,
      bookings_total_c(10),
      message_text(60).
    DATA: row TYPE i.
    DATA: it_row_no TYPE lvc_t_roid,
          wa_row_no LIKE LINE OF it_row_no,
          it_lines type i.
    DATA: BEGIN OF wa_sel_flights,
            mandt TYPE sy-mandt,
            carrid TYPE sflight-carrid,
            connid TYPE sflight-connid,
            fldate TYPE sflight-fldate,
          END OF wa_sel_flights,
          it_sel_flights LIKE TABLE OF wa_sel_flights.
    SELECT-OPTIONS: so_car FOR wa_sflight-carrid,
                    so_con FOR wa_sflight-connid.
    SELECTION-SCREEN SKIP.
    PARAMETERS: pa_lv TYPE disvariant-variant.
    **********************  CLASS  **************************
    CLASS: lcl_handler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS: on_doubleclick
                         FOR EVENT double_click OF cl_gui_alv_grid
                         IMPORTING es_row_no,
                       print_top
                         FOR EVENT print_top_of_page OF cl_gui_alv_grid,
                       print_tol
                         FOR EVENT print_top_of_list OF cl_gui_alv_grid,
                       on_toolbar
                         FOR EVENT toolbar OF cl_gui_alv_grid
                         IMPORTING e_object,
                       on_user_command
                         FOR EVENT user_command OF cl_gui_alv_grid
                         IMPORTING e_ucomm,
                         on_context_menu_request
             FOR EVENT context_menu_request OF cl_gui_alv_grid
             IMPORTING e_object.
    ENDCLASS.                    "lcl_handler DEFINITION
    CLASS: lcl_handler IMPLEMENTATION.
      METHOD on_doubleclick.
        READ TABLE it_sflight INTO wa_sflight INDEX es_row_no-row_id.
        IF sy-subrc NE 0.
          MESSAGE i075(bc408).
          EXIT.
        ENDIF.
        bookings_total = wa_sflight-seatsocc + wa_sflight-seatsocc_b +
                           wa_sflight-seatsocc_f.
        bookings_total_c = bookings_total.
        CONCATENATE 'Total number of bookings:'(m01)
                    bookings_total_c
          INTO message_text.
        MESSAGE message_text TYPE 'I'.
      ENDMETHOD.                    "on_doubleclick
      METHOD print_top.
        DATA: pos TYPE i.
        FORMAT COLOR COL_HEADING.
        WRITE: / sy-datum.
        pos = sy-linsz / 2 - 3. " length of pagno: 6 chars
        WRITE AT pos sy-pagno.
        pos = sy-linsz - 11. " length of username: 12 chars
        WRITE: AT pos sy-uname.
        ULINE.
      ENDMETHOD.                    "print_top
      METHOD print_tol.
        DATA: wa_so_car LIKE LINE OF so_car,
              wa_so_con LIKE LINE OF so_con.
        CONSTANTS: end TYPE i VALUE 20.
        FORMAT COLOR COL_HEADING.
        WRITE: / 'Select options'(000), AT end space.           "#EC *
        SKIP.
        WRITE: / 'Airlines'(001), AT end space.                 "#EC *
        ULINE AT /(end).
        FORMAT COLOR COL_NORMAL.
        LOOP AT so_car INTO wa_so_car.
          WRITE: / wa_so_car-sign,
                   wa_so_car-option,
                   wa_so_car-low,
                   wa_so_car-high.
        ENDLOOP.
        SKIP.
        FORMAT COLOR COL_HEADING.
        WRITE: / 'Connections'(002), AT end space .             "#EC *
        ULINE AT /(end).
        FORMAT COLOR COL_NORMAL.
        LOOP AT so_con INTO wa_so_con.
          WRITE: / wa_so_con-sign,
                   wa_so_con-option,
                   wa_so_con-low NO-ZERO,
                   wa_so_con-high NO-ZERO.
        ENDLOOP.
        SKIP.
      ENDMETHOD.                    "print_tol
      METHOD on_toolbar.
        DATA l_wa_button TYPE stb_button.
        l_wa_button-butn_type = 3.
        INSERT l_wa_button INTO TABLE e_object->mt_toolbar.
        CLEAR l_wa_button.
        l_wa_button-function = 'AENDERN'.
        l_wa_button-icon = ICON_MC_CONTENTINDICATOR.
        l_wa_button-quickinfo =  'FLÜGE ANZEIGEN'.           "#EC *
        l_wa_button-butn_type = 0.
        l_wa_button-text = 'ÄNDERN FLÜGE'.
        INSERT l_wa_button INTO TABLE e_object->mt_toolbar.
    * Create button "Display bookings"
        CLEAR l_wa_button.
        l_wa_button-function = 'ANZEGEN'.
        l_wa_button-icon = ICON_FLIGHT.
        l_wa_button-quickinfo =
        'FLÜGE ANZEIGEN'.           "#EC *
        l_wa_button-butn_type = 0.
        l_wa_button-text = 'ANZEIGEN FLÜGE'.
        INSERT l_wa_button INTO TABLE e_object->mt_toolbar.
      ENDMETHOD.                    "on_toolbar
    *        Ereignisbehandlung                                           *
      METHOD on_user_command.
        CASE e_ucomm.
          WHEN 'AENDERN'.
          message 'Was möchten Sie ändern ?' type 'I'.
          WHEN 'ANZEGEN '.
          message 'Was möchten Sie denn anzeigen ?' type 'I'.
       ENDCASE.
      ENDMETHOD.                    "on_user_command
      METHOD on_context_menu_request.
        DATA:
          column_info TYPE lvc_s_col.
        CALL METHOD alv->get_current_cell
          IMPORTING
            e_row     = row
            es_col_id = column_info.
        CASE column_info-fieldname.
          WHEN 'CARRID'.
            CALL METHOD e_object->add_function
              EXPORTING
                fcode = 'CARRIER_INFO'
                text  = 'Carrier info'(me1). "#EC *
          WHEN OTHERS.
        ENDCASE.
      ENDMETHOD.
    ENDCLASS.                    "lcl_handler IMPLEMENTATION
    **********************  ENDCLASS  ***********************
    *ABAP events
    START-OF-SELECTION.
      SELECT * FROM sflight
        INTO CORRESPONDING FIELDS OF TABLE it_sflight
        WHERE carrid IN so_car
        AND   connid IN so_con.
      LOOP AT it_sflight INTO wa_sflight.
        CLEAR: wa_sflight-it_field_colors.
    * set indicator for flights of current month
    * Fluege des laufenden Monats hervorheben
        IF wa_sflight-fldate(6) = sy-datum(6).
          CONCATENATE 'C' col_negative '01' INTO wa_sflight-color.
        ENDIF.
    * set icon for bookings status
    * Ikone für Buchungsstatus belegen
        IF wa_sflight-seatsocc = 0.
          wa_sflight-light = 1.
        ELSEIF wa_sflight-seatsocc < 50.
          wa_sflight-light = 2.
        ELSE.
          wa_sflight-light = 3.
        ENDIF.
    * highlight specific aircraft
    * besonderen Flugzeugtyp hervorheben
        IF wa_sflight-planetype = '747-400'.
          wa_field_color-fname = 'PLANETYPE'.
          wa_field_color-color-col = col_positive.
          wa_field_color-color-int = 1.
          wa_field_color-color-inv = 0.
          APPEND wa_field_color TO wa_sflight-it_field_colors.
        ENDIF.
    * set indicator for flights in the past
    * Ikone setzen für Flüge in der Vergangenheit
        IF wa_sflight-fldate < sy-datum.
          wa_sflight-changes_possible = icon_space.
        ELSE.
          wa_sflight-changes_possible = icon_okay.
        ENDIF.
        MODIFY it_sflight
          FROM wa_sflight
          TRANSPORTING color light it_field_colors changes_possible.
      ENDLOOP.
      CALL SCREEN 100.
    *PBO modules
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'DYN'.
      SET TITLEBAR 'T1'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    MODULE clear_ok_code OUTPUT.
      CLEAR ok_code.
    ENDMODULE.                 " clear_ok_code  OUTPUT
    MODULE create_and_transfer OUTPUT.
      CHECK cont IS INITIAL.
      CREATE OBJECT cont
        EXPORTING
          container_name              = 'MY_CONTROL_AREA'
        EXCEPTIONS
          OTHERS                      = 1.
      IF sy-subrc <> 0 AND sy-batch IS INITIAL.
        MESSAGE a010(bc408).
      ENDIF.
      CREATE OBJECT alv
        EXPORTING
          i_parent          = cont
        EXCEPTIONS
          OTHERS            = 1.
      IF sy-subrc <> 0 AND sy-batch IS INITIAL.
        MESSAGE a010(bc408).
      ENDIF.
    * register event handlers
      SET HANDLER:
        lcl_handler=>on_toolbar      FOR alv,
        lcl_handler=>on_user_command FOR alv,
        lcl_handler=>on_doubleclick  FOR alv,
        lcl_handler=>print_top       FOR alv,
        lcl_handler=>print_tol       FOR alv,
        lcl_handler=>on_context_menu_request FOR alv.
      my_variant-report = sy-cprog.
      IF NOT pa_lv IS INITIAL.
        my_variant-variant = pa_lv.
      ENDIF.
      my_print-prntlstinf = 'X'.
      my_print-grpchgedit = 'X'.
    *define layout
      wa_layout-grid_title = 'Flights'(h01).                    "#EC *
      wa_layout-no_hgridln = 'X'.
      wa_layout-no_vgridln = 'X'.
    *field that contains information on row color
      wa_layout-info_fname = 'COLOR'.
    *internal table that contains information on cell color
      wa_layout-ctab_fname = 'IT_FIELD_COLORS'.
    *field that contains information on exception (indicator)
      wa_layout-excp_fname = 'LIGHT'.
    *multiple row and column selection
      wa_layout-sel_mode = 'A'.
    *fill field catalog
      wa_field_cat-fieldname = 'SEATSOCC'.
      wa_field_cat-do_sum = 'X'.
      APPEND wa_field_cat TO it_field_cat.
      CLEAR wa_field_cat.
      wa_field_cat-fieldname = 'PAYMENTSUM'.
      wa_field_cat-no_out = 'X'.
      APPEND wa_field_cat TO it_field_cat.
      CLEAR wa_field_cat.
      wa_field_cat-fieldname = 'LIGHT'.
      wa_field_cat-coltext = 'Utilization'(h02).                "#EC *
      APPEND wa_field_cat TO it_field_cat.
      CLEAR wa_field_cat.
      wa_field_cat-fieldname = 'CHANGES_POSSIBLE'.
      wa_field_cat-col_pos = 5.
      wa_field_cat-coltext = 'Changes possible'(h03).           "#EC *
      wa_field_cat-tooltip = 'Are changes possible?'(t01).      "#EC *
      APPEND wa_field_cat TO it_field_cat.
      CALL METHOD alv->set_table_for_first_display
        EXPORTING
          i_structure_name = 'SFLIGHT'
          is_variant       = my_variant
          i_save           = 'A'
          is_layout        = wa_layout
          is_print         = my_print
        CHANGING
          it_outtab        = it_sflight
          it_fieldcatalog  = it_field_cat
        EXCEPTIONS
          OTHERS           = 1.
      IF sy-subrc <> 0.
        MESSAGE a012(bc408).
      ENDIF.
    ENDMODULE.                 " create_and_transfer OUTPUT
    *PAI modules
    MODULE user_command_0100 INPUT.
      CASE ok_code.
        WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
          PERFORM free.
          SET SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *Form routines
    FORM free.
      CALL METHOD: alv->free,
                   cont->free.
      FREE: alv,
            cont.
    ENDFORM.                    " free

  • Display button in ALV Grid

    Hi,
    I have a requirement in ALV:
    I need to display a button on the top of alv grid list.Could you please help me out with this.
    Thanks,
    Sandeep

    Hi,
    In the below links some ALV GRID programs are there.Once u check this.I think this is very helpful to u.
    http://www.abap-tutorials.com/tag/alv-grid/
    TO achieve this you should copy the u2018STANDARDu2019 GUI status from program SAPLKKBL using transaction SE90 u2013>Programming SubObjectsu2013> Gui Status.
    Steps:
    1). Using SE80/SE41 you can copy a GUI status from one program to another. It mentions which one in the FMu2019s help.
    2). Create a form named like so:
    Code:
    Form Set_pf_status
    Notes: Called by FM REUSE_ALV_GRID_DISPLAY
    FORM set_pf_status USING rt_extab TYPE slis_t_extab.
      SET PF-STATUS u2018ZSTANDARDu2019.
    ENDFORM. u201CSet_pf_status
    In the above case the GUI status copied was named ZSTANDARD and adjusted accordingly, adding and removing the desired buttons. A button was added called u2018%DELETEu2019.
    3). Create the following report:
    Code:
    Form User_command
    Notes: Called by FM REUSE_ALV_GRID_DISPLAY
           Detects whether the icon/button for
           u2018Return Tag Deletionu2019 has been pressed. If it has then
           detect whether any rows have been highlighted and then
           set the delete flag.
    FORM user_command USING r_ucomm     LIKE sy-ucomm
                            rs_selfield TYPE slis_selfield.
    DATA: li_count TYPE I.
    IF r_ucomm EQ u2018%DELETEu2019.
      LOOP AT %g00 WHERE mark EQ u2018Xu2019.
        ADD 1 TO li_count.
      ENDLOOP.
      IF li_count GT 0.
        gc_delete_flag = u2018Xu2019.
        r_ucomm = u2018&F03u2032. u201CBack arraow
      ELSE.
        MESSAGE W000 WITH u2018Please highlight the rows to be deleted!u2019.
      ENDIF.
    ENDIF.
    ENDFORM.  u201CUser_command
    As Iu2019ve added an extra button to indicate which records should be deleted I need to identify a form to be called to process when this button is chosen.
    Then when you call the ALV function you to specify the following extra details:
    Code:
        call function u2018REUSE_ALV_GRID_DISPLAYu2019
             exporting  i_callback_program = gc_repid
                        I_CALLBACK_PF_STATUS_SET = u2018SET_PF_STATUSu2019
                        I_CALLBACK_USER_COMMAND  = u2018USER_COMMANDu2019
                        i_grid_title       = lc_grid_title
                        is_layout          = lc_layout
                        it_fieldcat        = gt_fieldcat
                        it_sort            = sort
                        i_save             = l_save
                        is_reprep_id       = l_bbs_id
                        is_variant         = l_variant
             tables     t_outtab           = %g00
             exceptions program_error      = 1
                        others             = 2.
    The parameters in capitals are the extra ones that need to be added.

  • How to send the ALV GRID output to spool by using the print button in std t

    How to send the ALV GRID output to spool by using the print button in standard tool bar.
    We have created a button in the va02 transaction.  If user click on the button the new screen will be display on that screen we are populating the alv grid output using the oops concept.  But i am unable to send the output to spool using the print button in the standard tool bar.
    I am able to display the Print parameter dialog box but i am not able to send it to spool.
    Kindly help.
    Thanks In Advance.
    G.V.Ramana

    Hi Shaik,
    There is not properties button in my print screen.
    MODULE user_command_0900 INPUT.
        WHEN 'EXCEL'.
          PERFORM excel_download.                              
        WHEN 'PRI'.
          PERFORM print_output.
    form Print_output.
    CALL FUNCTION 'RSPO_LIST_LAYOUT_FITS'
               EXPORTING
                    columns        = 80
                    device         = 'ANY '
                    lines          = 65
                    maxpenality    = 1999
               TABLES
                    layouts        = lt_layouts1
               EXCEPTIONS
                    unknown_device = 1
                    OTHERS         = 2.
          IF sy-subrc = 0.
            LOOP AT lt_layouts1.
              IF lt_layouts1-penality < 1000        AND
                 lt_layouts1-penality < l_min_penality.
                l_layout       = lt_layouts1-layout.
                l_min_penality = lt_layouts1-penality.
              ENDIF.
            ENDLOOP.
            IF NOT l_layout IS INITIAL.
              CALL FUNCTION 'GET_PRINT_PARAMETERS'
                   EXPORTING
                        mode                   = 'CURRENT'
                        line_size              = 80             "#EC *
                new_list_id            = l_new_list_id
                        no_dialog              = l_no_dialog
                        layout                 = l_layout
                   IMPORTING
                        out_archive_parameters = rs_arc_params
                        out_parameters         = rs_pri_params
                        valid                  = l_valid
                   EXCEPTIONS
                        archive_info_not_found = 1
                        invalid_print_params   = 2
                        invalid_archive_params = 3
                        OTHERS                 = 4.
              IF sy-subrc NE 0.                                 " INS SLIN
              ENDIF.                                            " INS SLIN
              IF rs_pri_params-linsz LT 80 OR
                 rs_pri_params-linsz LT gt_stack-s_lprint-width.
                gt_stack-print_line_break = 'X'.
              ELSE.
                CLEAR gt_stack-print_line_break.
              ENDIF.
              IF l_valid NE 'X'.
                rs_pri_params = ls_pri_params_sav.
                rs_arc_params = ls_arc_params_sav.
              ENDIF.
            ENDIF.
          ENDIF.
    endform.                    " Print_output
        CALL METHOD gv_cost_tot_alv_grand->set_table_for_first_display
                EXPORTING
                   is_layout         = gs_layout_cost_tot_grand
                CHANGING
                   it_fieldcatalog   = gt_fcat_cost_tot_grand[]
                   it_outtab         = gt_cost_tot_grand[].
    Please check my code

Maybe you are looking for

  • Trouble upgrading to Photoshop Elements 4.0

    Hi there, I received the upgrade to Elements 4.0 for Christmas (downloaded and saved to CD). My computer refuses to read the lone file on the CD--or rather, it takes at least 5 minutes to read it, and then gives me an error message. My computer is su

  • How do I get rid of buump.me it has taken over my home page and iI have found no way to dump it no do

    I have no clue hoe it got on my pc I have looked on e explorer bing ask me yahoo and I come up with no answer it pops up your alternative search it seem to tied in with face book and you tube of which I do not use

  • GL account & Wbs field is modifiable in MIRO

    Hi, When creating a MIRO, after keying in the PO, the field GL account & WBS element is modifiable, I can make changes. However sometime back it was not so. I need it to be greyed out & not modifiable. What could have caused & is there any way to cor

  • How can I reset a password

    Hello. I'm new here so please bear with me. I have a similar question to the one posed on "Second Ownership Setup." I also have a second hand Mac that I purchased at auction. All of the previous owner's files have been deleted, but I cannot install a

  • How to start DefaultCacheServer remortly

    Hello guys, I've been attempting to find out the best way to start DefaultCacheServer from a remote machine. I tried ssh like below. ssh username@hostname <COHERENCE_HOME>/bin/cache-config.sh This command seemed to work out at first, but then result