Hotspot-clicking (Insert function) plus ALV Sorting

Hi,
I have a requirement where the ALV display has to be SORTED based on values entered/changed on a certain column. The sort works ok when used with a custom APPEND button for new records (always inserted at the bottom of the list).
However, it does not work correctly when used with the Hotspot-click (INSERT functionality). It looks like if you CLICK on a particular record onscreen, you are actually addressing the original record in that position before the SORT was effected. 
Is the Hotspot-clicking (Insert functionality) possible with ALV sorting? The ideal solution would be to have the ALV sorted at PBO and also at PAI so that the user can change existing records and add new ones with the sorting being updated everytime ON_DATA_CHANGED is triggered.
Will appreciate any help on this.
Thanks!
Michael

Hello Michael
Thanks for further specifying your requirements. I have created the sample variant ZUS_SDN_ALVGRID_HOTSPOT_SORT_1 which contains two differences as compared to its template:
Replace table VBAK with VBAP (so we have two levels of sorting: VBELN, POSNR)
Move SET_TABLE_FOR_FIRST_DISPLAY method call into PBO
When I click on the hotspot (VBELN) a new row entry for the order number is created. The sorting (VBELN, POSNR) is kept even though the new row has been appended to the itab.
*& Report  ZUS_SDN_ALVGRID_HOTSPOT_SORT
*& Thread: Hotspot-clicking (Insert function) plus ALV Sorting
*& <a class="jive_macro jive_macro_thread" href="" __jive_macro_name="thread" modifiedtitle="true" __default_attr="1159431"></a>
REPORT  zus_sdn_alvgrid_hotspot_sort.
TYPES: BEGIN OF ty_s_outtab.
INCLUDE TYPE vbap.
TYPES: END OF ty_s_outtab.
TYPES: ty_t_outtab    TYPE STANDARD TABLE OF ty_s_outtab
                      WITH DEFAULT KEY.
DATA: gt_outtab    TYPE ty_t_outtab.
DATA:
  gd_okcode        TYPE ui_func,
  gd_repid         TYPE syrepid,
  gt_sort          TYPE lvc_t_sort,
  gt_fcat          TYPE lvc_t_fcat,
  gs_layout        TYPE lvc_s_layo,
  gs_variant       TYPE disvariant,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_grid          TYPE REF TO cl_gui_alv_grid.
*       CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.
    CLASS-DATA:
      ms_sel_row    TYPE lvc_s_row. " selected row
    CLASS-METHODS:
      handle_data_changed FOR EVENT data_changed OF cl_gui_alv_grid
        IMPORTING
          er_data_changed
          e_onf4
          e_onf4_before
          e_onf4_after
          sender,
      handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid
        IMPORTING
          e_row_id
          e_column_id
          es_row_no
          sender.
ENDCLASS.                    "lcl_eventhandler DEFINITION
*       CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
  METHOD handle_data_changed.
    FIELD-SYMBOLS: <lt_outtab>  TYPE ty_t_outtab.
    BREAK-POINT.
  ENDMETHOD.                    "handle_data_changed
  METHOD handle_hotspot_click.
    " define local data
    DATA: ls_outtab    TYPE ty_s_outtab,
          ld_msg        TYPE bapi_msg.
    BREAK-POINT.
    CLEAR: lcl_eventhandler=>ms_sel_row.
    ms_sel_row = e_row_id.
    READ TABLE gt_outtab INTO ls_outtab INDEX e_row_id-index.
    CONCATENATE 'Selected Sales Order = ' ls_outtab-vbeln ' / '
                                          ls_outtab-posnr
      INTO ld_msg.
      message i398(00) with ld_msg.
    " Trigger PAI
    CALL METHOD cl_gui_cfw=>set_new_ok_code
      EXPORTING
        new_code = 'INSERT'
*      IMPORTING
*        rc       =
  ENDMETHOD.                    "handle_hotspot_click
ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
PARAMETERS:
  p_vkorg      TYPE vkorg  DEFAULT '0001'  OBLIGATORY.
START-OF-SELECTION.
**  SELECT  * FROM  vbak INTO CORRESPONDING FIELDS OF TABLE gt_outtab
**    UP TO 200 ROWS
**         WHERE  vkorg = p_vkorg.
  SELECT * FROM vbap INTO CORRESPONDING FIELDS OF TABLE gt_outtab
    UP TO 100 ROWS.
  PERFORM init_controls.
* Build fieldcatalog and set hotspot for field KUNNR
  PERFORM build_fieldcatalog.
  PERFORM set_layout_and_variant.
  PERFORM set_sorting.
  " Register EDIT event
  CALL METHOD go_grid->register_edit_event
    EXPORTING
      i_event_id = cl_gui_alv_grid=>mc_evt_enter
    EXCEPTIONS
      error      = 1
      OTHERS     = 2.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  SET HANDLER:
    lcl_eventhandler=>handle_data_changed  FOR go_grid,
    lcl_eventhandler=>handle_hotspot_click FOR go_grid.
* Link the docking container to the target dynpro
  gd_repid = syst-repid.
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = gd_repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* ok-code field = GD_OKCODE
  CALL SCREEN '0100'.
END-OF-SELECTION.
*&      Module  STATUS_0100  OUTPUT
*       text
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.
*  SET TITLEBAR 'xxx'.
* Display data
  CALL METHOD go_grid->set_table_for_first_display
    EXPORTING
      i_bypassing_buffer            = abap_true
      is_variant                    = gs_variant
      i_save                        = 'A'
*      i_default                     = 'X'
      is_layout                     = gs_layout
*      is_print                      =
*      it_special_groups             =
*      it_toolbar_excluding          =
*      it_hyperlink                  =
*      it_alv_graphics               =
*      it_except_qinfo               =
*      ir_salv_adapter               =
    CHANGING
      it_outtab                     = gt_outtab
      it_fieldcatalog               = gt_fcat
      it_sort                       = gt_sort
*      it_filter                     =
    EXCEPTIONS
      invalid_parameter_combination = 1
      program_error                 = 2
      too_many_lines                = 3
      OTHERS                        = 4.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
**  CALL METHOD go_grid->refresh_table_display
***        EXPORTING
***          IS_STABLE      =
***          I_SOFT_REFRESH =
**    EXCEPTIONS
**      finished       = 1
**      OTHERS         = 2.
**  IF sy-subrc ne 0.
***       MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
***                  WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
**  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
*       text
MODULE user_command_0100 INPUT.
  CASE gd_okcode.
    WHEN 'BACK' OR
         'EXIT'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.
    WHEN 'INSERT'.
      PERFORM insert_row.
    WHEN OTHERS.
      " Check for changed data at the frontend (= grid control)
      CALL METHOD go_grid->check_changed_data( ).
  ENDCASE.
  CALL METHOD go_grid->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      finished       = 1
      OTHERS         = 2.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CLEAR: gd_okcode.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  INIT_CONTROLS
*       text
*  -->  p1        text
*  <--  p2        text
FORM init_controls .
* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent = cl_gui_container=>screen0
      ratio  = 90
    EXCEPTIONS
      others = 6.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  CALL METHOD go_docking->set_extension
    EXPORTING
      extension  = 99999
    EXCEPTIONS
      cntl_error = 1
      OTHERS     = 2.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Create ALV grid
  CREATE OBJECT go_grid
    EXPORTING
      i_parent = go_docking
    EXCEPTIONS
      others   = 5.
  IF sy-subrc NE 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDFORM.                    " INIT_CONTROLS
*&      Form  BUILD_FIELDCATALOG
*       text
*  -->  p1        text
*  <--  p2        text
FORM build_fieldcatalog.
* define local data
  DATA:
    ls_fcat        TYPE lvc_s_fcat.
  CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
    EXPORTING
*     I_BUFFER_ACTIVE              =
      i_structure_name             = 'VBAP'  " 'VBAK'
*     I_CLIENT_NEVER_DISPLAY       = 'X'
*     I_BYPASSING_BUFFER           =
*     I_INTERNAL_TABNAME           =
    CHANGING
      ct_fieldcat                  = gt_fcat
    EXCEPTIONS
      inconsistent_interface       = 1
      program_error                = 2
      OTHERS                       = 3.
  IF sy-subrc NE 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
**  LOOP AT gt_fcat INTO ls_fcat.
**    CASE ls_fcat-fieldname.
**      WHEN 'VBELN'  OR
**           'ERDAT'  OR
**           'ERZET'  OR
**           'ERNAM'  OR
**           'AUART'  OR
**           'NETWR'  OR
**           'WAERK'.
**        CONTINUE.
**      WHEN OTHERS.
**        ls_fcat-no_out = abap_true.
**    ENDCASE.
**    MODIFY gt_fcat FROM ls_fcat INDEX syst-tabix.
**  ENDLOOP.
* Only non-key fields are editable
**  ls_fcat-edit = 'X'.
**  MODIFY gt_fcat FROM ls_fcat
**    TRANSPORTING edit
**    WHERE ( fieldname NE space ).
  ls_fcat-hotspot = abap_true.
  MODIFY gt_fcat FROM ls_fcat
    TRANSPORTING hotspot
    WHERE ( fieldname = 'AUART'   OR
            fieldname = 'VBELN' ).
**  DELETE gt_fcat FROM 15 TO 99.
ENDFORM.                    " BUILD_FIELDCATALOG_KNB1
*&      Form  SET_LAYOUT_AND_VARIANT
*       text
*  -->  p1        text
*  <--  p2        text
FORM set_layout_and_variant .
  CLEAR: gs_layout,
         gs_variant.
  gs_layout-cwidth_opt = abap_true.
  gs_variant-report = syst-repid.
  gs_variant-handle = 'GRID'.
ENDFORM.                    " SET_LAYOUT_AND_VARIANT
*&      Form  SET_SORTING
*       text
*  -->  p1        text
*  <--  p2        text
FORM set_sorting .
* define local data
  DATA: ls_sort   TYPE lvc_s_sort.
  REFRESH: gt_sort.
  CLEAR: ls_sort.
  ls_sort-spos = 1.
  ls_sort-fieldname = 'VBELN'.
  ls_sort-up = abap_true.
  APPEND ls_sort TO gt_sort.
  CLEAR: ls_sort.
  ls_sort-spos = 1.
  ls_sort-fieldname = 'POSNR'.
  ls_sort-up = abap_true.
  APPEND ls_sort TO gt_sort.
ENDFORM.                    " SET_SORTING
*&      Form  INSERT_ROW
*       text
*  -->  p1        text
*  <--  p2        text
FORM insert_row .
* define local data
  DATA: ls_outtab   TYPE ty_s_outtab,
        ld_order    TYPE vbeln.
  READ TABLE gt_outtab INTO ls_outtab
                       INDEX lcl_eventhandler=>ms_sel_row-index.
  ld_order = ls_outtab-vbeln.
  " Find last item of sales order
  LOOP AT gt_outtab INTO ls_outtab
                    WHERE ( vbeln = ld_order ).
  ENDLOOP.
  " Create next item:
  add 10 to ls_outtab-posnr.
  " NOTE: added at the end of the list
  APPEND ls_outtab TO gt_outtab.
  " NOTE: insert new row AFTER selected row => works, too
**  INSERT ls_outtab INTO gt_outtab
**                   INDEX lcl_eventhandler=>ms_sel_row-index.
ENDFORM.                    " INSERT_ROW

Similar Messages

  • Hotspot click  in methods for alv grid list

    Hi all ,
    i written a program for grid display and hotspot click.
    but it is not capturing the value at the event hotspot click,
    please anybody help me in capturing the value in the following code.
    it will be great will it happens soon.
    REPORT zag_tables MESSAGE-ID zag .
    DATA : gt_tables TYPE TABLE OF  zag_tables,
           gs_tables type zag_tables.
    DATA : gt_cust_cont TYPE REF TO cl_gui_custom_container       ,
           gt_alv_grid TYPE REF TO cl_gui_alv_grid,
           gt_cont TYPE scrfname VALUE 'ZAG_TABLES'.
    *data declarations for grid layout
    DATA : gt_fieldcat TYPE lvc_t_fcat,
           gs_fieldcat TYPE lvc_s_fcat,
           gs_layout TYPE lvc_s_layo,
           gs_variant TYPE disvariant.
    DATA : gv_repid TYPE syrepid,
            okcode TYPE syucomm..
    *data : gs_row_id type lvc_s_row,
          gs_col_id type lvc_s_col,
          gs_row_no type lvc_s_roid.
    data : e_row_id type lvc_s_row,
           gs_col_id type lvc_s_col,
           gs_row_no type lvc_s_roid.
    *CLASS DEFINITIONS
    CLASS cl_event_handler  DEFINITION.
      PUBLIC SECTION.
    CLASS-METHODs  : cm_hotspot_click FOR EVENT  hotspot_click OF
                      cl_gui_alv_grid IMPORTING
                      e_row_id e_column_id es_row_no .
    ENDCLASS.
          CLASS cl_event_handler IMPLEMENTATION
    CLASS cl_event_handler IMPLEMENTATION.
      METHOD : cm_hotspot_click .
      PERFORM hotspot_click.
    ENDMETHOD.
    ENDCLASS.
    START-OF-SELECTION.
      PERFORM select_data.
    END-OF-SELECTION.
      CALL SCREEN 100.
    *&      Form  select_data
          text
    -->  p1        text
    <--  p2        text
    FORM select_data.
      SELECT  *  FROM zag_tables INTO TABLE gt_tables.
    ENDFORM.                    " select_data
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'ZAG_TABLES'.
      SET TITLEBAR 'ZAG_TABLES'.
      gv_repid  = sy-repid.
      IF gt_cust_cont IS INITIAL.
        CREATE OBJECT gt_cust_cont
          EXPORTING
            container_name              = gt_cont
          EXCEPTIONS
            cntl_error                  = 1
            cntl_system_error           = 2
            create_error                = 3
            lifetime_error              = 4
            lifetime_dynpro_dynpro_link = 5
            others                      = 6
        IF sy-subrc <> 0.
        ENDIF.
        CREATE OBJECT gt_alv_grid
          EXPORTING
       I_SHELLSTYLE      = 0
       I_LIFETIME        =
            i_parent          = gt_cust_cont
       I_APPL_EVENTS     = space
       I_PARENTDBG       =
       I_APPLOGPARENT    =
       I_GRAPHICSPARENT  =
       I_USE_VARIANT_CLASS = SPACE
       I_NAME            =
          EXCEPTIONS
            error_cntl_create = 1
            error_cntl_init   = 2
            error_cntl_link   = 3
            error_dp_create   = 4
            others            = 5
        IF sy-subrc <> 0.
        ENDIF.
      ELSE.
        CALL METHOD gt_alv_grid->refresh_table_display
          EXCEPTIONS
            finished       = 1
            OTHERS         = 2
        IF sy-subrc <> 0.
        ENDIF.
      ENDIF.
    *perform layout changing gs_layout.
      PERFORM  fieldcat CHANGING gt_fieldcat.
    *perform variant changing gs_variant.
      gs_layout-zebra   = 'X'.
      gs_layout-sel_mode = 'A'.
      gs_variant-report = gv_repid.
      SET HANDLER cl_event_handler=>cm_hotspot_click FOR gt_alv_grid.
      CALL METHOD gt_alv_grid->set_table_for_first_display
        EXPORTING
       I_BYPASSING_BUFFER            =
       I_BUFFER_ACTIVE               =
       I_CONSISTENCY_CHECK           =
       I_STRUCTURE_NAME              =
          is_variant                    = gs_variant
          i_save                        = 'A'
          i_default                     = 'X'
          is_layout                     = gs_layout
       IS_PRINT                      =
       IT_SPECIAL_GROUPS             =
       IT_TOOLBAR_EXCLUDING          =
       IT_HYPERLINK                  =
       IT_ALV_GRAPHICS               =
       IT_EXCEPT_QINFO               =
        CHANGING
          it_outtab                     = gt_tables
          it_fieldcatalog               = gt_fieldcat
       IT_SORT                       =
       IT_FILTER                     =
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3
          OTHERS                        = 4
      IF sy-subrc <> 0.
      ENDIF.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Form  fieldcat
          text
         <--P_GS_fieldcat  text
    FORM fieldcat CHANGING gt_fieldcat  TYPE lvc_t_fcat.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
       EXPORTING
      I_BUFFER_ACTIVE              =
         i_structure_name             = 'ZAG_TABLES'
      I_CLIENT_NEVER_DISPLAY       = 'X'
      I_BYPASSING_BUFFER           =
        CHANGING
          ct_fieldcat                  = gt_fieldcat
       EXCEPTIONS
         inconsistent_interface       = 1
         program_error                = 2
         OTHERS                       = 3
      IF sy-subrc <> 0.
      ENDIF.
      LOOP AT gt_fieldcat INTO gs_fieldcat.
        gs_fieldcat-fieldname = 'MANDT'.
        gs_fieldcat-no_out     = ''.
        MODIFY gt_fieldcat  FROM gs_fieldcat.
        gs_fieldcat-fieldname = 'Z_TABLES'.
        gs_fieldcat-hotspot     = 'X'.
        MODIFY gt_fieldcat  FROM gs_fieldcat.
      ENDLOOP.
    ENDFORM.                    " fieldcat
    *&      Form  layout
          text
    -->  p1        text
    <--  p2        text
    *form layout changing gs_layout.
    *gs_layout-zebra = 'X'.
    *gs_layout-sel_mode = 'A'.
    *endform.                    " layout
    *&      Form  variant
          text
         <--P_GS_variant  text
         <--P_ENDMODULE  text
    *form variant changing gs_variant
      gs_variant-report = gv_repid.
    *endform.                    " variant
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
      TRANSLATE okcode TO UPPER CASE.
      CASE okcode.
        WHEN 'EXIT' OR 'BACK' OR 'CANCEL'.
          LEAVE TO  SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    *&      Form  hotspot_click
          text
    -->  p1        text
    <--  p2        text
    FORM hotspot_click ."importing gs_row_id type lvc_s_row.
    data : lv_prog type syrepid,
           lv_tcode type tcode.
    read table gt_tables into gs_tables index e_row_id-index.
    if sy-subrc eq 0 and gs_col_id-fieldname = 'ZTABLES'.
    move gs_tables-z_tables to lv_prog.
    translate lv_prog to upper case.
    select single tcode from tstc into lv_tcode where pgmna = lv_prog.
    call transaction lv_tcode.
    endif.
    ENDFORM.                    " hotspot_click
    thanks in advance..
    pls

    Hi  ,
    please  go through this  Program   it was  handled  by Hot spot  only  .
    report zbnstest.
    * TABLES AND DATA DECLARATION.
    *TABLES: mara,makt.",marc.
    data syrepid like sy-repid.
    data sydatum(10). " LIKE sy-datum.
    data sypagno(3) type n.
    * WHEN USING MORE THAN ONE TABLE IN ALV WE NEEED TO DECLARE THE TYPE
    * GROUP (TYPE-POOLS--------->SLIS)
    type-pools : slis.
    * INTERNAL TABLE DECLARATION.
    * INTERNAL TABLE TO HOLD THE VALUES FROM THE MARA TABLE
    data: begin of t_mara occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    mtart like mara-mtart,
    matkl like mara-matkl,
    end of t_mara.
    * INTERNAL TABLE TO HOLD THE CONTENTS FROM THE EKKO TABLE
    data : begin of t_marc occurs 0,
    matnr like mara-matnr,
    werks like marc-werks,
    minbe like marc-minbe.
    data: end of t_marc.
    * INTERNAL TABLE TO HOLD THE VALUES FROM MAKT TABLE.
    data : begin of t_makt occurs 0,
    matnr like mara-matnr,
    maktx like makt-maktx,
    spras like makt-spras,
    end of t_makt.
    * INTERNAL TABLE WHICH ACTUALLY MERGES ALL THE OTHER INTERNAL TABLES.
    data: begin of itab1 occurs 0,
    matnr like mara-matnr,
    meins like mara-meins,
    maktx like makt-maktx,
    spras like makt-spras,
    werks like marc-werks,
    minbe like marc-minbe,
    end of itab1.
    * THE FOLLOWING DECLARATION IS USED FOR DEFINING THE FIELDCAT
    * AND THE LAYOUT FOR THE ALV.
    * HERE AS slis_t_fieldcat_alv IS A INTERNAL TABLE WITHOUT A HEADER LINE
    * WE EXPLICITELY DEFINE AN INTERNAL TABLE OF THE SAME STRUCTURE AS THAT
    * OF slis_t_fieldcat_alv BUT WITH A HEADER LINE IN THE DEFINITION.
    * THIS IS DONE TO MAKE THE CODE SIMPLER.
    * OTHERWISE WE MAY HAVE TO DEFINE THE STRUCTURE AS IN THE NORMAL SAP
    * PROGRAMS.
    * IN THE FIELDCATALOG TABLE WE ACTUALLY PASS THE FIELDS FROM ONE OR
    * MORE TABLES AND CREATE A STRUCTURE
    * IN THE LAYOUT STRUCTURE WE BASICALLY DEFINE THE FORMATTING OPTIONS
    * LIKE DISPLAY IN THE ZEBRA PATTERN ,THE HOTSPOT OPTIONS ETC.
    data: fieldcatalog type slis_t_fieldcat_alv with header line,
    fieldlayout type slis_layout_alv.
    * DECLARING THE EVENTTABLE INTERNL TABLE FOR USING EVENTS LIKE
    * TOP-OF-PAGE ETC.
    data : eventstab type slis_t_event with header line.
    * DECLARING AN INTERNAL TABLE TO HOLD THE DATA FOR THE TOP-OF-PAGE
    data : heading type slis_t_listheader with header line.
    data : heading1 type slis_t_listheader with header line.
    data : heading2 type slis_t_listheader with header line.
    data : heading3 type slis_t_listheader with header line.
    data : heading4 type slis_t_listheader with header line.
    data : heading5 type slis_t_listheader with header line.
    data : heading6 type slis_t_listheader with header line.
    data : heading7 type slis_t_listheader with header line.
    data : heading8 type slis_t_listheader with header line.
    * STRUCTURE TO PASS THE COLOR ATTRIBUTES FOR DISPLAY.
    data : colorstruct type slis_coltypes.
    * INITIALIZATION. *
    initialization.
    syrepid = sy-repid.
    sypagno = sy-pagno.
    clear fieldcatalog.
    * START-OF-SELECTION. *
    start-of-selection.
    * SUBROUTINE TO POPULATE THE COLORSTRUCT
    perform fill_colorstruct using colorstruct.
    * SUBROUTINE TO POPULATE THE FIELDS OF THE FIELD CATALOGUE
    perform populate_fieldcatalog.
    * SUBROUTINE TO SELECT DATA FROM VARIOUS TABLES AND POPULATE IT IN THE
    * INTERNAL TABLE.
    perform selectdata_and_sort.
    * SUBROUTINE TO POPULATE THE LAYOUT STRUCTURE.
    perform populate_layout using fieldlayout.
    * SUBROUTINE TO CALL THE FUNCTION MERGE TO ENSURE PROPER DISPLAY.
    perform merge_fieldcatalog.
    * SUBROUTINE TO POPULATE THE EVENTSTAB.
    perform fill_eventstab tables eventstab.
    * SUBROUTINE TO POPULATE THE HEADING TABLES.
    perform fill_headingtable tables heading using 'HEADING'.
    perform fill_headingtable tables heading1 using 'HEADING1'.
    perform fill_headingtable tables heading2 using 'HEADING2'.
    perform fill_headingtable tables heading3 using 'HEADING3'.
    perform fill_headingtable tables heading4 using 'HEADING4'.
    perform fill_headingtable tables heading5 using 'HEADING5'.
    perform fill_headingtable tables heading6 using 'HEADING6'.
    perform fill_headingtable tables heading7 using 'HEADING7'.
    perform fill_headingtable tables heading8 using 'HEADING8'.
    * SUBROUTINE TO DISPLAY THE LIST.
    perform display_alv_list.
    * FORMS
    * IN THIS SUBROUTINE WE POPULATE THE FIELDCATALOG TABLE WITH THE NAMES
    * OF THE TABLE,FIELDNAME,WHETHER IT IS KEY FIELD OR NOT,HEADING AND
    * COLUMN JUSTIFICATION.
    form populate_fieldcatalog.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATNR' 'X' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MEINS' ' '.
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MAKTX' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MTART' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MATKL' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'SPRAS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'WERKS' ' ' .
    perform fill_fields_of_fieldcatalog tables fieldcatalog
    using 'ITAB1' 'MINBE' ' ' .
    endform. " POPULATE_FIELDCATALOG
    * FORM FILL_FIELDS_OF_FIELDCATALOG *
    * --> FIELDCATALOG *
    * --> P_TABNAME *
    * --> P_FIELDNAME *
    * --> P_KEY *
    * --> P_KEY *
    form fill_fields_of_fieldcatalog tables fieldcatalog
    structure fieldcatalog
    using p_tabname
    p_fieldname
    p_key.
    * p_no_out.
    fieldcatalog-tabname = p_tabname.
    fieldcatalog-fieldname = p_fieldname.
    fieldcatalog-key = p_key.
    fieldcatalog-emphasize = '1234'.
    *fieldcatalog-no_out = p_no_out.
    append fieldcatalog.
    endform. " FILL_FIELDSOFFIELDCATALOG
    * FORM POPULATE_LAYOUT *
    * --> FIELDLAYOUT *
    form populate_layout using fieldlayout type slis_layout_alv.
    fieldlayout-f2code = '&ETA' .
    fieldlayout-zebra = 'X'.
    * FOR THE WINDOW TITLE.
    fieldlayout-window_titlebar = 'ALV with Events'.
    fieldlayout-colwidth_optimize = 'X'.
    fieldlayout-no_vline = ' '.
    *fieldlayout-no_input = 'X'.
    fieldlayout-confirmation_prompt = ''.
    fieldlayout-key_hotspot = 'X'.
    * This removes the column headings if the flag is set to 'X'
    fieldlayout-no_colhead = ' '.
    *fieldlayout-hotspot_fieldname = 'MAKTX'.
    fieldlayout-detail_popup = 'X'.
    * fieldlayout-coltab_fieldname = 'X'.
    endform. " POPULATE_LAYOUT
    * FORM SELECTDATA_AND_SORT *
    form selectdata_and_sort.
    select matnr meins mtart matkl from mara
    into corresponding fields of t_mara
    up to 500 rows .
    select matnr maktx spras from makt
    into corresponding fields of t_makt
    where matnr = t_mara-matnr and
    spras = sy-langu.
    select matnr werks minbe from marc
    into corresponding fields of t_marc
    where matnr = t_mara-matnr.
    append t_marc.
    endselect.
    append t_makt.
    endselect.
    append t_mara.
    endselect.
    perform populate_itab1.
    sort itab1 by matnr.
    endform. " SELECTDATA_AND_SORT
    * FORM MERGE_FIELDCATALOG *
    form merge_fieldcatalog.
    call function 'REUSE_ALV_FIELDCATALOG_MERGE'
    exporting
    i_program_name = syrepid
    i_internal_tabname = 'ITAB1'
    * i_structure_name = 'COLORSTRUCT'
    * I_CLIENT_NEVER_DISPLAY = 'X'
    i_inclname = syrepid
    changing
    ct_fieldcat = fieldcatalog[]
    exceptions
    inconsistent_interface = 1
    program_error = 2
    others = 3.
    endform. " MERGE_FIELDCATALOG
    * IN THIS FUNCTION THE MINIMUM PARAMETERS THAT WE NEED TO PASS IS AS
    * FOLLOWS:-
    * i_callback_program --> CALLING PROGRAM NAME
    * i_structure_name --> STRUCTURE NAME.
    * is_layout --> LAYOUT NAME.
    * it_fieldcat ---> BODY OF THE FIELD CATALOGUE INTERNAL TABLE
    form display_alv_list.
    call function 'REUSE_ALV_LIST_DISPLAY'
    exporting
    * I_INTERFACE_CHECK = ' '
    i_callback_program = syrepid
    * I_CALLBACK_PF_STATUS_SET = ' '
    * I_CALLBACK_USER_COMMAND = ' '
    i_structure_name = 'ITAB1'
    is_layout = fieldlayout
    it_fieldcat = fieldcatalog[]
    * IT_EXCLUDING =
    * IT_SPECIAL_GROUPS =
    * IT_SORT =
    * IT_FILTER =
    * IS_SEL_HIDE =
    * I_DEFAULT = 'X'
    * THE FOLLOWING PARAMETER IS SET AS 'A' INORDER TO DISPLAY THE STANDARD
    * TOOL BAR
    i_save = 'A'
    * IS_VARIANT = ' '
    it_events = eventstab[]
    * IT_EVENT_EXIT =
    * IS_PRINT =
    * I_SCREEN_START_COLUMN = 0
    * I_SCREEN_START_LINE = 0
    * I_SCREEN_END_COLUMN = 0
    * I_SCREEN_END_LINE = 0
    * IMPORTING
    * E_EXIT_CAUSED_BY_CALLER =
    * ES_EXIT_CAUSED_BY_USER =
    tables
    t_outtab = itab1
    exceptions
    program_error = 1
    others = 2.
    endform. " DISPLAY_ALV_LIST
    *& Form POPULATE_ITAB1
    * text
    * --> p1 text
    * <-- p2 text
    form populate_itab1.
    loop at t_mara.
    loop at t_makt where matnr = t_mara-matnr.
    loop at t_marc where matnr = t_mara-matnr.
    move-corresponding t_mara to itab1.
    move-corresponding t_makt to itab1.
    move-corresponding t_marc to itab1.
    append itab1.
    endloop.
    endloop.
    endloop.
    endform. " POPULATE_ITAB1
    *& Form FILL_EVENTSTAB
    * text
    * -->P_EVENTSTAB text *
    form fill_eventstab tables p_eventstab structure eventstab.
    * WHEN THE FOLLOWING FUNCTION IS CALLED THE SYSTEM POPULATES THE
    * INTERNAL TABLE EVENTSTAB WITH A LIST OF EVENTS NAME.
    * AS SHOWN BELOW WHEN USING I_LIST_TYPE = 0 THE FUNCTION RETURNS 14
    * EVENTS NAME.
    call function 'REUSE_ALV_EVENTS_GET'
    exporting
    i_list_type = 0
    importing
    et_events = p_eventstab[]
    exceptions
    list_type_wrong = 1
    others = 2.
    * BY CALLING THE ABOVE FUNCTION WE FIRST POPULATE THE EVENTSTAB WITH
    * THE PREDEFINED EVENTS AND THEN WE MOVE THE FORM NAME AS SHOWN BELOW.
    * WE ASSIGN A FORM NAME TO THE EVENT AS REQUIRED BY THE USER.
    * FORM NAME CAN BE ANYTHING.THE PERFORM STATEMENT FOR THIS FORM
    * IS DYNAMICALY CALLED.
    read table p_eventstab with key name = slis_ev_top_of_page.
    if sy-subrc = 0 .
    move 'TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_coverpage.
    if sy-subrc = 0 .
    move 'TOP_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_coverpage .
    if sy-subrc = 0 .
    move 'END_OF_COVERPAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_top_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_TOP_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_foreign_end_of_page.
    if sy-subrc = 0 .
    move 'FOREIGN_END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_list_modify.
    if sy-subrc = 0 .
    move 'LIST_MODIFY' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_top_of_list.
    if sy-subrc = 0 .
    move 'TOP_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_page.
    if sy-subrc = 0 .
    move 'END_OF_PAGE' to p_eventstab-form.
    append p_eventstab.
    endif.
    read table p_eventstab with key name = slis_ev_end_of_list .
    if sy-subrc = 0 .
    move 'END_OF_LIST' to p_eventstab-form.
    append p_eventstab.
    endif.
    endform. " FILL_EVENTSTAB
    *& Form FILL_HEADINGTABLE
    * text
    * -->P_HEADING text *
    form fill_headingtable tables p_heading structure heading
    using tablename.
    case tablename.
    when 'HEADING'.
    p_heading-typ = 'H'.
    concatenate
    ' REPORT NAME:-' syrepid
    ' ABB Industry Pte Ltd' into p_heading-info.
    append p_heading.
    write sy-datum using edit mask '__/__/____' to sydatum.
    concatenate
    ' DATE:-' sydatum ' USER: ' sy-uname 'PAGE NO:' sypagno
    into p_heading-info.
    append p_heading.
    when 'HEADING1'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING2'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-COVER-PAGE'.
    append p_heading.
    when 'HEADING3'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-TOP-OF-PAGE'.
    append p_heading.
    when 'HEADING4'.
    p_heading-typ = 'H'.
    p_heading-info = 'FOREIGN-END-OF-PAGE'.
    append p_heading.
    * WHEN 'HEADING5'.
    * P_HEADING-TYP = 'H'.
    * P_HEADING-INFO = 'LIST-MODIFY'.
    * APPEND P_HEADING.
    when 'HEADING6'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-PAGE'.
    append p_heading.
    when 'HEADING7'.
    p_heading-typ = 'H'.
    p_heading-info = 'END-OF-LIST'.
    append p_heading.
    when 'HEADING8'.
    p_heading-typ = 'H'.
    p_heading-info = 'TOP-OF-LIST'.
    append p_heading.
    endcase.
    endform. " FILL_HEADINGTABLE
    * FORM TOP_OF_PAGE *
    form top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading[]
    exceptions
    others = 1.
    endform.
    *& Form FILL_COLORSTRUCT
    * text
    * -->P_COLORSTRUCT text *
    form fill_colorstruct using p_colorstruct type slis_coltypes .
    p_colorstruct-heacolfir-col = 6.
    p_colorstruct-heacolfir-int = 1.
    p_colorstruct-heacolfir-inv = 1.
    endform. " FILL_COLORSTRUCT
    * FORM TOP_OF_COVERPAGE *
    form top_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading1[]
    exceptions
    others = 1.
    endform.
    * FORM END_OF_COVERPAGE *
    form end_of_coverpage.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading2[]
    exceptions
    others = 1.
    endform.
    * FORM FOREIGN_TOP_OF_PAGE *
    form foreign_top_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading3[]
    exceptions
    others = 1.
    endform.
    * FORM FOREIGN_END_OF_PAGE *
    form foreign_end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading4[]
    exceptions
    others = 1.
    endform.
    * FORM LIST_MODIFY *
    *FORM LIST_MODIFY.
    * CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
    * EXPORTING
    * IT_LIST_COMMENTARY = HEADING5[]
    * EXCEPTIONS
    * OTHERS = 1.
    *ENDFORM.
    * FORM END_OF_PAGE *
    form end_of_page.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading6[]
    exceptions
    others = 1.
    endform.
    * FORM END_OF_LIST *
    form end_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading7[]
    exceptions
    others = 1.
    endform.
    * FORM TOP_OF_LIST *
    form top_of_list.
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = heading8[]
    exceptions
    others = 1.
    endform.
    *--- End of Program
    Reward  points  if it is usefull ..
    Girish

  • How does the SORT function in ALV grid work?

    Hi,
    I have a report for which the o/p is displayed in ALV grid format.There is one column in the O/p strcuture which is "No of days".Based on certain conditions,i need to display the value for some of the days as Negative e.g. " - 45".Becasuse of this,I have declared the field for the "No of days" of the type "CHAR".
    Now when i sort(using ALV grid SORT function) the list on basis of this column,it doesnt give me the correct o/p.
    CAN anyone tell me how do i handle this?I want the list to be sorted correctly on basis of the "No of days" column.
    Thanks!

    This is your Fourth Cross Posting in last three days on same issue!!
    CHAR type column doesnt work for SORT function in ALV grid!
    How to sort a column of type CHAR
    I dont,ve link for your Fourth Thread on same,though i'm short memory loss.

  • Refresh the screen after a ALV hotspot click

    I have a value type I painted on my screen, i wan it to be updated after i trigger the hotspot click on my ALV list. How to do refresh the value on the screen?Because hotspot click does not update the screen for the latest value.

    Hello Lai
    I trigger PAI in the event handler method using the following coding:
    *   Trigger PAI
        CALL METHOD cl_gui_cfw=>set_new_ok_code
          EXPORTING
            new_code = e_ucomm
    *      IMPORTING
    *        rc       =
    When you are at PAI you can do all kinds of refreshing your ALV list before displaying it again. For an example see thread
    Blanking values on ALV Grid Row Duplicate
    Regards
      Uwe

  • Inserting row in ALV

    hi  experts ..
    I want to add a row in the alv when i click on add button..
    I know there is insert row and append row buttons available in alv but i dont want those names ..
    Can i change the name of standard buttons or is there sm class that i can use to develop this functionality.
    jagruti.

    Hi Jagruti,
    You just have to add a new button with whatever name you want, and map it to the existing functionality in ALV. It will work and you dont need to do anything else.
    The code will be:
    data:
    lr_button type ref to cl_salv_wd_fe_button,
    lr_function type ref to cl_salv_wd_function.
    CREATE OBJECT lr_button.
    lr_button->set_text( 'Your text' ).
    lr_button->set_tooltip( 'Your tooltip' ).
    lr_function = l_alv_model->if_salv_wd_function_settings~create_function( id = 'INSERT' ).
    <b>lr_function->set_function_std( IF_SALV_WD_C_STD_FUNCTIONS=>EDIT_APPEND_ROW ).</b>
    lr_function->set_editor( lr_button ).
    The method set_function_std sets your funcion to take the behaviour of the standard ALV function for inserting rows. So it would work automatically. You have only changed the text.
    <b>If your problem is solved, please award points and close the threads. Couple of your previous threads are still open, please close them</b>
    Regards,
    Nithya

  • Leave scren while Hotspot click

    Hi all,
    Here is my sample program  Hotspot click.
    After calling the second screen  by Hotspot click, the screen 100 is not leaving back when you pressed BACK Button in screen 100.
    When i am Pressing the Back Button in screen 100, it is checking for Hotspot click event.
    As i was new to Objects ,Anybody help me in resolving this
    REPORT zspot_test .
    TABLES mara.
    TYPES : BEGIN OF tt_mara,
    matnr TYPE matnr ,
    mtart TYPE mtart,
    matkl TYPE matkl,
    END OF tt_mara.
    DATA gt_mara TYPE STANDARD TABLE OF mara.
    SELECT-OPTIONS so_matnr FOR mara-matnr.
    SET SCREEN 100.
    START-OF-SELECTION.
      SELECT matnr mtart matkl FROM mara
      INTO CORRESPONDING FIELDS OF TABLE
      gt_mara
       WHERE matnr IN so_matnr.
    END-OF-SELECTION.
      CALL SCREEN 100.
    INCLUDE zin123.
    ***INCLUDE ZIN123 .
    *Class Definitions
    CLASS : event_handler DEFINITION.
      PUBLIC SECTION.
        METHODS : handle_hotspotclick FOR EVENT  hotspot_click OF
                 cl_gui_alv_grid IMPORTING
                                  e_row_id
                                  e_column_id
                                  es_row_no.
    ENDCLASS.
          CLASS :  EVENT_HANDLER
    CLASS : event_handler IMPLEMENTATION.
      METHOD : handle_hotspotclick.
        PERFORM handleclick
                USING
                e_row_id
                e_column_id.
               es_row_no.
      ENDMETHOD.
    ENDCLASS.
    *&      Form  handleclick
          text
         -->P_E_ROW_ID  text
         -->P_E_COLUMN_ID  text
         -->P_ES_ROW_NO  text
    FORM handleclick USING    e_row_id TYPE lvc_s_row
                              e_column_id TYPE lvc_s_col.
                             es_row_no.
      CALL SCREEN 200.
    ENDFORM.                    " handleclick
    *&      Module  STATUS_0100  OUTPUT
          text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'TEST1'.
    SET TITLEBAR 'xxx'.
      DATA gs_fieldcat TYPE lvc_s_fcat.
       DATA: evt_handler  TYPE REF TO event_handler.
      DATA :gt_cont TYPE REF TO cl_gui_custom_container,
            gt_grid TYPE REF TO cl_gui_alv_grid,
            gt_container TYPE scrfname VALUE 'SPOT_CREATE',
            gt_fieldcat TYPE lvc_t_fcat.
      CREATE OBJECT gt_cont
           EXPORTING
             container_name    = 'GRID1'.
      CREATE OBJECT gt_grid
        EXPORTING
        i_parent          = gt_cont.
      CALL FUNCTION 'LVC_FIELDCATALOG_MERGE'
           EXPORTING
                i_structure_name = 'MARA'
           CHANGING
                ct_fieldcat      = gt_fieldcat.
      LOOP AT gt_fieldcat INTO gs_fieldcat.
        IF gs_fieldcat-fieldname = 'MATNR'.
          gs_fieldcat-hotspot = 'X'.
          modify  gt_fieldcat from gs_fieldcat.
        ENDIF.
      ENDLOOP.
    create object evt_handler.
    set handler evt_handler->handle_hotspotclick FOR gt_grid.
      CALL METHOD gt_grid->set_table_for_first_display
        EXPORTING
         is_variant                    = gs_variant
          i_save                        = 'A'
          i_default                     = 'X'
         is_layout                     = gs_layout
        CHANGING
          it_outtab                     = gt_mara
          it_fieldcatalog               = gt_fieldcat.
    endmodule.
    INCLUDE zin24.
    *&      Module  USER_COMMAND_0100  INPUT
          text
    MODULE user_command_0100 INPUT.
    data gv_repid like sy-repid.
    gv_repid = sy-repid.
      CASE sy-ucomm.
        WHEN 'BACK'.
             LEAVE TO SCREEN 0.
      ENDCASE.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    module USER_COMMAND_0200 input.
    case sy-ucomm.
    when 'BACK'.
    leave to screen 100.
    endcase.
    endmodule.

    Hello Madhavi
    Your coding is somewhat messy, in particular when you call screen '0200' within the event handler method.
    The following sample report<b> ZUS_SDN_ALVGRID_EVENTS_1</b> shows how to call a <i>second screen</i> while handling and event (e.g. double_click, hotspot_click, button_click).
    *& Report  ZUS_SDN_ALVGRID_EVENTS_1
    REPORT  zus_sdn_alvgrid_events_1.
    DATA:
      gd_okcode        TYPE ui_func,
      gt_fcat          TYPE lvc_t_fcat,
      go_docking       TYPE REF TO cl_gui_docking_container,
      go_docking2      TYPE REF TO cl_gui_docking_container,
      go_grid1         TYPE REF TO cl_gui_alv_grid,
      go_grid2         TYPE REF TO cl_gui_alv_grid.
    DATA:
      gt_t001          TYPE STANDARD TABLE OF t001,
      gt_knb1          TYPE STANDARD TABLE OF knb1.
    *       CLASS lcl_eventhandler DEFINITION
    CLASS lcl_eventhandler DEFINITION.
      PUBLIC SECTION.
        CLASS-METHODS:
          handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
            IMPORTING
              e_row
              e_column
              es_row_no
              sender.
    ENDCLASS.                    "lcl_eventhandler DEFINITION
    *       CLASS lcl_eventhandler IMPLEMENTATION
    CLASS lcl_eventhandler IMPLEMENTATION.
      METHOD handle_double_click.
    *   define local data
        DATA:
          ls_t001     TYPE t001,
          ls_col_id   TYPE lvc_s_col.
        CHECK ( sender = go_grid1 ).
        READ TABLE gt_t001 INTO ls_t001 INDEX e_row-index.
        CHECK ( ls_t001-bukrs IS NOT INITIAL ).
        SELECT * FROM knb1 INTO TABLE gt_knb1
          WHERE bukrs = ls_t001-bukrs.
        IF ( syst-subrc NE 0 ).
          MESSAGE 'No customers found' TYPE 'S'.
        ELSE.
    *     Trigger PAI of dynpro '0100' and set new ok-code
          CALL METHOD cl_gui_cfw=>set_new_ok_code( 'CALL_SCREEN_0200' ).
        ENDIF.
      ENDMETHOD.                    "handle_hotspot_click
    ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
    START-OF-SELECTION.
      SELECT * FROM t001 INTO TABLE gt_t001.
      REFRESH: gt_knb1.
    * Create docking container
      CREATE OBJECT go_docking
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_docking2
        EXPORTING
          parent                      = cl_gui_container=>screen0
          ratio                       = 90
        EXCEPTIONS
          OTHERS                      = 6.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Create ALV grid
      CREATE OBJECT go_grid1
        EXPORTING
          i_parent          = go_docking
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CREATE OBJECT go_grid2
        EXPORTING
          i_parent          = go_docking2
        EXCEPTIONS
          OTHERS            = 5.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Set event handler
      SET HANDLER:
        lcl_eventhandler=>handle_double_click FOR go_grid1.
    * Display data
      CALL METHOD go_grid1->set_table_for_first_display
        EXPORTING
          i_structure_name = 'T001'
        CHANGING
          it_outtab        = gt_t001
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_grid2->set_table_for_first_display
        EXPORTING
          i_structure_name = 'KNB1'
        CHANGING
          it_outtab        = gt_knb1
        EXCEPTIONS
          OTHERS           = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * Link the docking container to the target dynpro
      CALL METHOD go_docking->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0100'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
      CALL METHOD go_docking2->link
        EXPORTING
          repid                       = syst-repid
          dynnr                       = '0200'
    *      CONTAINER                   =
        EXCEPTIONS
          OTHERS                      = 4.
      IF sy-subrc <> 0.
    *   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    * NOTE: screen '0100' does not contain any screen elements
    * Flow logic:
    *  PROCESS BEFORE OUTPUT.
    *    MODULE STATUS_0100.
    *  PROCESS AFTER INPUT.
    *    MODULE USER_COMMAND_0100.
    * ok-code field = GD_OKCODE
      CALL SCREEN '0100'.
    * NOTE: for the sake of simplicity screen '0200' contains
    *       the same flow logic like screen '0100' (see above)
    END-OF-SELECTION.
    *&      Module  STATUS_0100  OUTPUT
    *       text
    MODULE status_0100 OUTPUT.
      SET PF-STATUS 'STATUS_0100'.
    *  SET TITLEBAR 'xxx'.
    ENDMODULE.                 " STATUS_0100  OUTPUT
    *&      Module  USER_COMMAND_0100  INPUT
    *       text
    MODULE user_command_0100 INPUT.
      CASE gd_okcode.
        WHEN 'BACK' OR
             'EXIT'  OR
             'CANC'.
          SET SCREEN 0. LEAVE SCREEN.
    "     NOTE: effect on screen '0200' -> return to '0100'
    "           effect on screen '0100' -> return to selscreen
        WHEN 'CALL_SCREEN_0200'.
          go_grid2->refresh_table_display( ).  " necessary
          CALL SCREEN '0200'.
        WHEN OTHERS.
      ENDCASE.
      CLEAR: gd_okcode.
    ENDMODULE.                 " USER_COMMAND_0100  INPUT
    Regards
      Uwe

  • Hotspot Click is not working !!

    Hi,
    I have sucessfully implemented hotspot click using OOALV.
    I still have an issue in one of the hotspot click feature.
    I have a OOALV report where i have implemented hotspot click for Contract # as
    when 'KONNR'.
            if w_listdata-konnr <> ''.
              lv_konn = w_listdata-konnr.
              set parameter id 'VRT' field lv_konn.
              CALL TRANSACTION 'ME33K' and skip first screen.      
            endif.
    since ME33K transaction takes input of type 'EVRTN' ,i have taken a
    temporary parameter called lv_konn declared it as type EVRTN.
    But still the hotspot click is not working.
    Can anyone suggest me how to reslove this issue.
    Appreciate all the help.

    Hi Madan,
                  I will send a syntax for that check it once then ur problem is solved ok..
    FORM usercommand USING ucomm LIKE sy-ucomm selfield TYPE slis_selfield.
      CASE selfield-sel_tab_field.
        WHEN 'GT_HEADERDAT-EBELN'.
              code
          endcase.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
       EXPORTING
      I_INTERFACE_CHECK              = ' '
      I_BYPASSING_BUFFER             =
      I_BUFFER_ACTIVE                = ' '
        i_callback_program             = sy-cprog
      I_CALLBACK_PF_STATUS_SET       = ' '
        i_callback_user_command        = 'USERCOMMAND'
      I_STRUCTURE_NAME               =
        is_layout                      = wa_layout
        it_fieldcat                    = gt_fieldcat
      IT_EXCLUDING                   =
      IT_SPECIAL_GROUPS              =
      IT_SORT                        =
      IT_FILTER                      =
      IS_SEL_HIDE                    =
      I_DEFAULT                      = 'X'
      I_SAVE                         = ' '
      IS_VARIANT                     =
        it_events                      = gt_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
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER        =
      ES_EXIT_CAUSED_BY_USER         =
        TABLES
        t_outtab                       = gt_headerdat
       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.
    Award points if helpful.
    Kiran Kumar.G.A
            Have a Nice Day..

  • Insert logo in alv

    hello experts....
    In alv reports how i insert logo into alv grid ?tell me procedure, in the same report how insert background logo?

    Hi,
    At first you have to upload the logo in the application server using transaction 'OAER'.
       1. Go to Transaction OAER,
       2. Give Class Name as PICTURES
       3. Class type as OT
       4. Object Key as the name of the Object u want to specify
       5. Upon execution you would be prompted to give the file path details. Just upload which ever logo u want to display
       6. Now you can use the same name in your ALV FM
    In your ALV program, you need to have event for TOP_OF_PAGE, and also this works only in case of Grid not in ALV LIST.
    Look at the sample code to display LOGO.
    call function 'REUSE_ALV_GRID_DISPLAY'
    exporting
      i_callback_program = i_repid
      it_fieldcat = header
      is_layout = gt_layout
      i_callback_top_of_page = 'TOP-OF-PAGE1'
      i_grid_title = xyz
      it_sort = gt_sort[]
      i_default = 'X'
      i_save = 'U'
      is_variant = gt_variant
      it_events = gt_events
    tables
      t_outtab = t_output.
    Form TOP-OF-PAGE1
    form top-of-page1.
    data: header type slis_t_listheader,
          wa     type slis_listheader.
    TITLE AREA
    wa-typ = 'S'.
    wa-info = text-h04.
    append wa to header.
    wa-typ = 'S'.
    write sy-datum to wa-info mm/dd/yyyy.
    concatenate text-h03 wa-info into wa-info separated by space.
    append wa to header.
    wa-typ = 'S'.
    concatenate text-h02 sy-uname into wa-info separated by space.
    append wa to header.
    wa-typ = 'S'.
    concatenate text-h01 sy-repid into wa-info separated by space.
    append wa to header.
    ********" LOGO
    call function 'REUSE_ALV_COMMENTARY_WRITE'
    exporting
    it_list_commentary = header
    i_logo = 'ENJOYSAP_LOGO'.
    *********" LOGO
    endform.
    Here in TOP-OF-PAGE form it will show you the Prog name,Date, User Name.

  • INSERTING LOGO IN ALV GRID

    hi experts,
    how can i insert logo in alv grid..can u send me some examples of alv that includes all the functionalities like user-command,commentary write n also logo insertion etc..
    regards,
    raman

    hi ,
        chk out this .....and  try this ..
    for getting the events ....
    FORM ZVRPSALV_EVENT_CAT  CHANGING RT_EVENT TYPE slis_t_event .
        DATA : s_event TYPE slis_alv_event.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
        EXPORTING
          i_list_type     = 0
        IMPORTING
          et_events       = RT_EVENT
       EXCEPTIONS
         list_type_wrong = 1
         OTHERS          = 2.
    CASE sy-subrc.
       WHEN 1.
         MESSAGE s000 WITH 'List type does not exist'(058).
         LEAVE LIST-PROCESSING.
       WHEN 2.
         MESSAGE s000 WITH 'Error with List Type'(059).
         LEAVE LIST-PROCESSING.
    ENDCASE.
      READ TABLE RT_EVENT WITH KEY NAME = slis_ev_top_of_page INTO s_event .
      IF sy-subrc = 0.
        MOVE 'TOP_OF_PAGE'(056) TO s_event-form.
        APPEND s_event TO rt_event.
        CLEAR s_event.
      ENDIF.
    ENDFORM.                    " EVENT_CAT
    *&      Form  ZVRPSALV_GRIDDISPLAY1
          text
    -->  p1        text
    <--  p2        text
    FORM ZVRPSALV_GRIDDISPLAY1 .
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
    EXPORTING
      I_INTERFACE_CHECK                 = ' '
      I_BYPASSING_BUFFER                = ' '
      I_BUFFER_ACTIVE                   = ' '
       I_CALLBACK_PROGRAM                = REPID
      I_CALLBACK_PF_STATUS_SET          = ' '
       I_CALLBACK_USER_COMMAND           = 'DISPLAY_DOCUMENT '
       I_CALLBACK_TOP_OF_PAGE            = ' TOP-OF-PAGE '
      I_CALLBACK_HTML_TOP_OF_PAGE       = ' '
      I_CALLBACK_HTML_END_OF_LIST       = ' '
      I_STRUCTURE_NAME                  =
      I_BACKGROUND_ID                   = ' '
       I_GRID_TITLE                      = 'BASIC LIST'
      I_GRID_SETTINGS                   =
      IS_LAYOUT                         =
       IT_FIELDCAT                       = T_FCAT
      IT_EXCLUDING                      =
      IT_SPECIAL_GROUPS                 =
      IT_SORT                           =
      IT_FILTER                         =
      IS_SEL_HIDE                       =
      I_DEFAULT                         = 'X'
      I_SAVE                            = ' '
      IS_VARIANT                        =
      IT_EVENTS                         = RT_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
      I_HTML_HEIGHT_TOP                 = 0
      I_HTML_HEIGHT_END                 = 0
      IT_ALV_GRAPHICS                   =
      IT_HYPERLINK                      =
      IT_ADD_FIELDCAT                   =
      IT_EXCEPT_QINFO                   =
      IR_SALV_FULLSCREEN_ADAPTER        =
    IMPORTING
      E_EXIT_CAUSED_BY_CALLER           =
      ES_EXIT_CAUSED_BY_USER            =
      TABLES
        T_OUTTAB                          = T_ITAB
    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.                    " ZVRPSALV_GRIDDISPLAY1
    SUBROTINE FOR DISPLAYING THE SECONDRY ALV GRID.
    FORM DISPLAY_DOCUMENT USING R_UCOMM  LIKE SY-UCOMM
                                RS_SELFIELD TYPE SLIS_SELFIELD.
    IF RS_SELFIELD-FIELDNAME = 'VBELN'.
      READ TABLE T_ITAB INDEX  RS_SELFIELD-TABINDEX .
    V_VBELN = T_ITAB-VBELN.
    LOOP AT T_ITAB WHERE VBELN = V_VBELN.
       Move: T_ITAB-POSNR to T_ITAB1-POSNR  ,
             T_ITAB-MATNR to T_ITAB1-MATNR ,
             T_ITAB-MATKL to T_ITAB1-MATKL,
             T_ITAB-ARKTX to T_ITAB1-ARKTX  ,
             T_ITAB-PSTYV to T_ITAB1-PSTYV  ,
             T_ITAB-SPART to T_ITAB1-SPART ,
             T_ITAB-GSBER to T_ITAB1-GSBER ,
             T_ITAB-KWMENG to T_ITAB1-KWMENG .
       Append T_ITAB1.
    ENDLOOP.
       ENDIF.
    *&      Form  ZVRPSALV_COMMENT
          text
         -->P_T_HEADER  text
    FORM ZVRPSALV_COMMENT  USING  P_T_HEADER type slis_t_listheader .
    DATA : LS_LINE TYPE SLIS_LISTHEADER.
    CLEAR LS_LINE .
    LS_LINE-TYP = 'H'.
    LS_LINE-INFO =  'HEADING LIST'.
    APPEND LS_LINE TO P_T_HEADER.
      CLEAR LS_LINE.
      LS_LINE-typ = 'S'.
      write sy-datum to LS_LINE-info MM/DD/YYYY.
      CONCATENATE text-041 LS_LINE-info INTO LS_LINE-info separated by space .
      APPEND LS_LINE TO P_T_HEADER.
    ENDFORM.                    " ZVRPSALV_COMMENT
    SUBROUINE FOR TOP OF PAGE.
    FORM TOP_OF_PAGE.
    clear t_header.
    DATA: LV_HEADER TYPE SLIS_LISTHEADER.
      LV_HEADER-TYP = 'S'.
      WRITE SY-DATUM TO LV_HEADER-INFO MM/DD/YYYY.
      CONCATENATE TEXT-041 LV_HEADER-INFO INTO LV_HEADER-INFO SEPARATED BY SPACE.
      APPEND LV_HEADER TO T_HEADER.
    CALL FUNCTION 'REUSE_ALV_COMMENTARY_WRITE'
       EXPORTING
         IT_LIST_COMMENTARY       = T_HEADER
        I_LOGO                   = ' ENJOYSAP_LOGO '
       I_END_OF_LIST_GRID       =
       I_ALV_FORM               =
    ENDFORM.
    *&      Form  ZVRPSALV_EVENTTAB
          text
         <--P_T_EVENT  text
    FORM ZVRPSALV_EVENTTAB  CHANGING P_T_EVENT TYPE SLIS_T_EVENT.
      DATA : LS_EVENT TYPE SLIS_ALV_EVENT.
      CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
       EXPORTING
         I_LIST_TYPE           = 0
       IMPORTING
         ET_EVENTS             = P_T_EVENT.
    SEARCH THE TOP OF PAGE EVENT.
      READ TABLE P_T_EVENT WITH KEY NAME = SLIS_EV_TOP_OF_PAGE INTO LS_EVENT .
      IF SY-SUBRC = 0 .
      MOVE 'TOP_OF_PAGE' TO LS_EVENT-FORM.
      APPEND LS_EVENT TO P_T_EVENT.
      ENDIF.
    ENDFORM.                    " ZVRPSALV_EVENTTAB
    thanks and regards
    Priyank Dixit

  • The follow functions initiate the sorter just after initializing the compon

    The follow functions initiate the sorter just after initializing the components in the file student.dialog
    void mySettings()
    //jTable1.rowSelectionAllowed();
    jTable1.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
    //jTable1.setFont(new Font("Helvetica", Font.PLAIN, 10));
    jTable1.setModel(new StudentTableModel(jTable1,jLabel25));
    // MyTableModel model = new MyTableModel(this.rw,this.cl);
    sorter = new TableRowSorter(jTable1.getModel());
    jTable1.setRowSorter(sorter);
    //jTable1.getValueAt(rw, cl);
    // System.out.println(jTable1.getColumnModel().getColumn(2));
    jTable1.getSelectionModel().addListSelectionListener(
    new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent event) {
    int viewRow = jTable1.getSelectedRowCount();
    //jLabel1.setText(String.valueOf(jTable1.getSelectedRowCount()));
    if (viewRow < 0) {
    //Selection got filtered away.
    // statusText.setText("");
    } else {
    //int modelRow =
    // jTable1.convertRowIndexToModel(viewRow);
    firstName.getDocument().addDocumentListener(
    new DocumentListener() {
    @Override
    public void changedUpdate(DocumentEvent e) {
    newFilter();
    @Override
    public void insertUpdate(DocumentEvent e) {
    newFilter();
    @Override
    public void removeUpdate(DocumentEvent e) {
    newFilter();
    lastName.getDocument().addDocumentListener(
    new DocumentListener() {
    @Override
    public void changedUpdate(DocumentEvent e) {
    newFilter();
    @Override
    public void insertUpdate(DocumentEvent e) {
    newFilter();
    @Override
    public void removeUpdate(DocumentEvent e) {
    newFilter();
    }After this when a user select a filter and table get sorted only 10 records appear there int the jtable from which a user select just one and press the remove button on that click i have written this
    int rowArr [] =jTable1.getSelectedRows();
    for(int rowId:rowArr)
    try
    // System.out.println(sorter.convertRowIndexToModel(rowId));
    sorter.getModel().fireTableRowsDeleted(jTable1.convertRowIndexToModel(rowId), jTable1.convertRowIndexToModel(rowId));
    //sorter.rowsDeleted(rowId, rowId);
    int stuId = Integer.valueOf(String.valueOf(jTable1.getValueAt(rowId, 0)));
    int sessId= Singleton.getInstance().session_id;
    conn = Singleton.getInstance().makeConnection();
    query="DELETE FROM student_class WHERE student_id =? AND admClass1 AND session_id=?"; // 7
    s=conn.prepareStatement(query);
    s.setInt(1,stuId);
    s.setInt(2,sessId);
    s.execute();
    }catch(Exception e)
    e.printStackTrace();
    }Do not think that i want multiple records to be delete i m selecting only one record but when i click on the remove button it gives me the following stack trace:
    java.lang.IndexOutOfBoundsException: Invalid range
    at javax.swing.DefaultRowSorter.checkAgainstModel(DefaultRowSorter.java:921)
    at javax.swing.DefaultRowSorter.rowsDeleted(DefaultRowSorter.java:878)
    at javax.swing.JTable.notifySorter(JTable.java:4277)
    at javax.swing.JTable.sortedTableChanged(JTable.java:4121)
    at javax.swing.JTable.tableChanged(JTable.java:4398)
    at javax.swing.table.AbstractTableModel.fireTableChanged(AbstractTableModel.java:296)
    at dps.StudentTableModel.fireTableChanged(StudentTableModel.java:465)
    at javax.swing.table.AbstractTableModel.fireTableRowsDeleted(AbstractTableModel.java:261)
    at dps.StudentTableModel.fireTableRowsDeleted(StudentTableModel.java:475)
    at dps.StudentDialog.jButton5ActionPerformed(StudentDialog.java:1360)
    at dps.StudentDialog.access$1600(StudentDialog.java:56)
    at dps.StudentDialog$18.actionPerformed(StudentDialog.java:441)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6504)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
    at java.awt.Component.processEvent(Component.java:6269)
    at java.awt.Container.processEvent(Container.java:2229)
    at java.awt.Component.dispatchEventImpl(Component.java:4860)
    at java.awt.Container.dispatchEventImpl(Container.java:2287)
    at java.awt.Component.dispatchEvent(Component.java:4686)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
    at java.awt.Container.dispatchEventImpl(Container.java:2273)
    at java.awt.Window.dispatchEventImpl(Window.java:2713)
    at java.awt.Component.dispatchEvent(Component.java:4686)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:707)
    at java.awt.EventQueue.access$000(EventQueue.java:101)
    at java.awt.EventQueue$3.run(EventQueue.java:666)
    at java.awt.EventQueue$3.run(EventQueue.java:664)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.awt.EventQueue$4.run(EventQueue.java:680)
    at java.awt.EventQueue$4.run(EventQueue.java:678)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:677)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:211)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:128)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:117)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:113)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

    Use your debugger and step though to actually see what is happening, also if you have N rows and one is removed you then only have N-1 rows and any attempt to address the container with N rows will fail.

  • ALV sort/group disfunction ?!

    Hi there,
    I'm a bit helpless because of the sort/group function my ALV should do. Current situation is that I'm using an CL_GUI_ALV_GRID.
    CALL METHOD gr_config_alv_1_2->set_table_for_first_display
        EXPORTING
          is_layout                     = ls_layout
        CHANGING
          it_sort                       = sort_table
          it_outtab                     = config_1_2_table
          it_fieldcatalog               = cat_config_fieldcat_alv
        EXCEPTIONS
          invalid_parameter_combination = 1
          program_error                 = 2
          too_many_lines                = 3.
      IF sy-subrc <> 0.
        EXIT.
      ENDIF.
    So you can see that I'm using it_sort to tell the ALV how to sort the it_outtab. [Result looks like this|http://fabianvogt.com/alv_1.jpg].
    What the it_sort does is sorting the it_outtab ASCENDING for the coloum "GRP" (display-name: "Bezugstyp"). So far so good...But I know that CL_GUI_ALV_GRID normally does some kind of grouping by merging cells with the same content. [This would look like that|http://fabianvogt.com/alv_2.jpg].
    In my case it does not work and I don't have any idea why. I searched the CLASS for a hint or maybe an attribute which has to be filled/flagged to do this kind of grouping.
    Looking forword to your help!

    Hi everyone!
    I've checked BCALV_TEST_GRID. Basically they do it the same way I'm trying. I found out that I have the possibility to set ls_layout-no_merging to control, whether cells with the same content are merged or not. By default no_merging is set SPACE, so the cells should be merged - NOT in my case.
    Even if I set no_merging  =  '  ' (SPACE) manually, the merging won't be done.
    Running out ouf ideas ...
    NEWS:
    I did some kind of a workaround, in my opinion even a nicer way to realize my purpose. So take a look at what I did right now:
    (take a look at the screenshots in my previous posts for your better understanding)
    - The old 'GRP' field (old content: 'B',' K', 'M') is now filled with 'Belegbezug', 'Kundenbezug', 'Materialbezug' and is set NO_OUT (fieldcatalogue).
    - I insterted a field called 'CNT' type I, which i use to create Totals/Subtotals.
    - NO_TOTLINE  = 'X' (Layout) --> total line is not shown; only subtotals
    - TOTALS_BEF (Layout) --> subtotals are placed on top
    [So this is what I got now|http://fabianvogt.com/alv3.jpg]. Much better than before!!!
    My only problem is now, that the 'CNT' coloum looks pretty ugly and has no function except doing the sum thing.
    I tried to make it invisible using the fieldcatalogue (NO_OUT / TECH), but then the total lines disappear :/
    Any suggestions?
    Edited by: Fabian Vogt on Oct 4, 2010 4:35 PM

  • How can I call functionality of ALV Grid by event of button outside grid?

    Hello,
    How can I call functionality of ALV Grid by event of button located outside ALV Grid? For example how to fire printing of this ALV Grid by button click elsewhere on the screen (not in toolbar of ALV Grid).
    Best regards,
    Josef Motl

    hi Motl,
    these are steps to create a button in ALV and trigger an event from it..
    1.Use the parameter i_callback_pf_status_set in the function module REUSE_ALV_GRID_DISPLAY
    i_callback_program = gd_repid
    i_callback_pf_status_set = 'SET_PF_STATUS'
    form set_pf_status using rt_extab type slis_t_extab.
    set pf-status 'NEWALVSTATUS'.
    endform.
    You have to copy the standard ALV pf stauts to 'NEWALVSTATUS' and add your button.
    2.You have to do the following to process the new button click.
    i_callback_user_command = 'USER_COMMAND'
    form user_command using i_ucomm like sy-ucomm
    is_selfield type slis_selfield.
    case i_ucomm.
    3. to copy the standard pf status to a new one.go to the ALV screen and take the menu System -> Status.  Then look for the standard pf status. Copy this to Z range and then add your new button.
    reward points if helpful
    regards
    satesh

  • Append, Insert controlling in ALV

    Hello,
    Currently I have to manually select the new line to that is appended or inserted. I want that when use press Append or Insert button in ALV it should pass the control and the new line to become the lead select row. My requirement is that when user make changes in the default fields and press append or insert, these default values should be replaced in the Item Detail section for that particular new row. I am able to capture the event when user press Append or Insert.
    Shall appreciate soonest response.
    Thks & Rgds,
    Hemal
    Edited by: Hemal Gandhi on May 12, 2010 4:45 PM

    it sounds like you want to used the Append/Insert functionality to just validate your inputs and re-wrote the whole row with the new changes; you don't really want to add a new row?
    if I understand correct I think you will need to create your own custom APPEND/INSERT BUTTON to disable standard functionality of Adding a new row to the ALV and run ON_DATA_CHECK to modify current entries behind your custom button.
    I will hide the APPEND/INSERT standard button and add a custom button at the same position with the same text calling ON_DATA_CHECK and binding new values to the row that has been change.
    Maybe someone else has a better approach but that's what I will do, and I know it works!
    thanks!
    Jason PV

  • Double click on the node,ALV tree, subscreen

    Hi,
    I have a small requirement in ALV Tree
    left side i get a tree and when i double click on one of it , i'm trying to display the subscreen. even though i am setting the paramaters to the screen but i'm unable to get those values in the subscreen.
    example
    Name        Description                                                subscreen 0101
    xyz           xyz desc (double click on this)                  name    = XYZ
    ABC         abs desc                                                      descrip = xyz desc
    This is what the requirement is:
    Please help me out with the solution.
    Bhavana

    Hi Bhavana,
    Register your double click event in the ALV Tree program. Then call the respective subscreen using sy-ucomm value.
    IF NOT r_ucomm IS INITIAL.
        CASE r_ucomm.
          WHEN '&F03'.
            SET SCREEN 100.
            LEAVE SCREEN.
    endif.
    Refer the below code for setting the registering the event.
      CALL METHOD tree->get_registered_events
        IMPORTING
          events = l_events_s.
      l_event-eventid = cl_gui_column_tree=>eventid_item_double_click.
      APPEND l_event TO l_events_s.
      CALL METHOD tree->set_registered_events
        EXPORTING
          events                    = l_events_s
        EXCEPTIONS
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      CREATE OBJECT l_events_receiver.
      SET HANDLER l_events_receiver->handle_item_click FOR tree.
    CLASS lcl_events_receiver DEFINITION.                       "#EC *
      PUBLIC SECTION.
        METHODS:
        handle_item_click FOR EVENT item_double_click OF cl_gui_alv_tree
            IMPORTING node_key fieldname.
    ENDCLASS.                    "lcl_handle_events DEFINITION
    CLASS lcl_events_receiver IMPLEMENTATION.
      METHOD handle_item_click.
        PERFORM employee_data USING node_key fieldname.
        CALL SCREEN 300.
      ENDMETHOD.                    "HANDLE_ITEM_DOUBLE_CLICK
    ENDCLASS.                    "lcl_events_receiver IMPLEMENTATION
    Thanks.
    Ganesh R K
    Edited by: Ganesh.rk83 on Jun 23, 2011 11:21 AM

  • I-photo:  I used 2 cameras to take pictures on a trip --- i have put the pictures from both cameras into an album --- when i click on view and then sort by date, the pictures do not sort by date --- any ideas on how to get the pics sorted by date?

    I-photo:  I used 2 cameras to take pictures on a trip --- i have put the pictures from both cameras into an album --- when i click on view and then sort by date, the pictures do not sort by date --- any ideas on how to get the pics sorted by date?

    Select all the photos that you need to change, then click the "Photos" menu and choose "Adjust Date and Time".
    If you add a year, it will adjust all the photos that you selected by adding a year (so if you accidentally select one of the photos that already has "2012", that will change to "2013"). 

Maybe you are looking for

  • Macbook Pro 13" Late 2013 Lagging

    Greetings! Two days ago I bought my new Macbook Pro 13" which is a late 2012 retina (MD212DK/A). My problem is that i feels very slow and unstable and laggy. I've tried reverting back to the "Best for retina" display setting which seems to improve it

  • Read a doc file and write back to a doc file

    How to read line by line from a doc file and then arrange it. Like--> amit sumit prem jeev these four names are present in the doc file. Now how to read by means of java program and sort these names and write back to a new doc file????? What packages

  • MBP 2008 is running very sluggish

    It seems every day I am having to restart my MBP at least 2 times a day. I am a web designer so I am running Dreamweaver and Photoshop daily. I have upgraded my ram and it still runs this way. Here are the spec. Processor - 2.6GHz incore 2 Duo Memory

  • Entries with Spl.GL Indicator

    Hi, I need to find out then transactions posted to a particular special GL indicator. any help is appreciated Thanks Babu

  • Pivot table and link to account record logs user out of OnDemand

    All, I have created a simple accounts report using a pivot table. I would like the user to be able to drill down on the detail account record. I followed the instructions in Doc ID 454434.1 that describes how to do this without using an action link.