Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to Achieve Hot Spot in ALV Grid without Underlining Cell Contents

Former Member
0 Kudos
1,307

Hello,

I think the subject says it all. I need my ALV Grid to support hot spots without displaying an underline.

Overall goal: Display an ALV grid from which the user selects a row and the data from the corresponding row appears in an entry screen beneath the ALV grid.

I do not want an editable ALV grid.

Thank you in advance for any help you could provide.

Best Regards,

Brett

1 ACCEPTED SOLUTION

Former Member
0 Kudos
455

Sorry, I am not using the FM. I am instantiating an ALV Grid object.

Do you know the equivalent technique with that method?

Thank you for your help.

Brett

P.S.

Where is the interface to award points?? Used to be in each post right next to the user name. I don't see it. I wish to award points to Ashok.

Message was edited by: Brett Conrad

7 REPLIES 7

Former Member
0 Kudos
455

If use REUSE_ALV_GRID fm then u can find parameter for hot spot the rows in the display with wich u can achive that.* IT_HYPERLINK

I think it will solve your problem, try it

Do'nt forget to give points

ash

Former Member
0 Kudos
456

Sorry, I am not using the FM. I am instantiating an ALV Grid object.

Do you know the equivalent technique with that method?

Thank you for your help.

Brett

P.S.

Where is the interface to award points?? Used to be in each post right next to the user name. I don't see it. I wish to award points to Ashok.

Message was edited by: Brett Conrad

0 Kudos
455

Here is a solution.



***  Create screen  100.  Add a custom control container to the screen,
** call it alv_container.  add two input fields, one called xalv-matnr
** and the called xalv-maktx.

report zrich_0002.

tables: mara.

data: begin of i_alv occurs 0,
      matnr type mara-matnr,
      maktx type makt-maktx,
      end of i_alv.

data: xalv like line of i_alv.
data: tmp_alv like line of i_alv.

***********************************************************************
*       CLASS cl_event_receiver DEFINITION      Handles Double Click
***********************************************************************
class cl_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 CL_EVENT_RECEIVER IMPLEMENTATION    Handles Double Click
***********************************************************************
class cl_event_receiver implementation.
  method handle_double_click.

    clear  tmp_alv.
    read table i_alv into  tmp_alv index e_row-index.
    if sy-subrc = 0.
      move-corresponding  tmp_alv to xalv.
    endif.

* cause PAI
    call method cl_gui_cfw=>set_new_ok_code
            exporting
                new_code = 'FIRE'.

  endmethod.
endclass.


data: alv_container  type ref to cl_gui_custom_container.
data: event_receiver type ref to cl_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 mara-matnr.
selection-screen end of block b1.

start-of-selection.

  perform get_data.
  call screen 100.

************************************************************************
*      Module  status_0100  OUTPUT
************************************************************************
module status_0100 output.
  set pf-status '0100'.
  set titlebar '0100'.

  data: lt_exclude type ui_functions.
  data: variant type  disvariant.

  variant-report = sy-repid.
  variant-username = sy-uname.

xalv = tmp_alv.

* 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
  perform get_fieldcatalog.


*   Optionally restrict generic functions to 'change only'.
*   (The user shall not be able to add new lines).
  perform exclude_tb_functions changing lt_exclude.

  call method alv_grid->set_table_for_first_display
      exporting
           is_layout              = layout
           is_variant             = variant
           i_save                 = 'U'
           i_structure_name       = 'I_ALV'
           it_toolbar_excluding   = lt_exclude
      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.

************************************************************************
* FORM GET_DATA
************************************************************************
form get_data.

  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.

endform.

************************************************************************
*      Form  Get_Fieldcatalog - Set Up Columns/Headers
************************************************************************
form get_fieldcatalog.

  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.

endform.


***********************************************************************
*      Form  EXCLUDE_TB_FUNCTIONS
***********************************************************************
form exclude_tb_functions changing pt_exclude type ui_functions.
* Only allow to change data not to create new entries (exclude
* generic functions).

  data ls_exclude type ui_func.

  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_copy_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_delete_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_append_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_insert_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_loc_move_row.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_sort_asc.
  append ls_exclude to pt_exclude.
  ls_exclude = cl_gui_alv_grid=>mc_fc_sort_dsc.
  append ls_exclude to pt_exclude.

**  This excludes all buttons
*  ls_exclude = '&EXCLALLFC'.
*  append ls_exclude to pt_exclude.

endform.


Regards,

Rich Heilman

0 Kudos
455

Rich,

Thank you for the thorough information. I learned quite a bit.

However, is the double-click the only way to fire an event if you do not want the underline?

The users are working in a guard shack and not computer literate. Single-click is much preferable to double-click.

Thank you for your help.

Brett

P.S. It appears I have no way to award points. I have no idea why I cannot.

0 Kudos
455

Brett, I see what you are saying. There is an event called CLICK_ROW_COL, but it is inherited and protected, so I can't access outside of the class. I've been trying to get around it for the pass couple of minutes, but it seems like a lot just to get rid of the underline. I would suggest to either "live with" the underline, or maybe have a little training session with your users, you can have a little "double-click" jam session.

By the way, the points system has been down for the past 24 hours or so. I don't know when it is coming back up. Maybe you could stop by sometime later to award points and close your post. Thanks.

Regards,

Rich Heilman

former_member182371
Active Contributor
0 Kudos
455

Hi,

I got all this from the pdf "

AnEasyReferenceforALVGridControl.pdf

" that you can dounload from the download area.

1.- set the value for the field “HOTSPOT” to ‘X’ while generating the field catalog

2.- After clicking, the event “hotspot_click” is triggered and for this you´ll need:
CLASS lcl_event_handler DEFINITION .
PUBLIC SECTION .
METHODS:
*Hotspot click control handle_hotspot_click FOR EVENT hotspot_click OF cl_gui_alv_grid IMPORTING e_row_id e_column_id es_row_no .
PRIVATE SECTION.
ENDCLASS.

CLASS lcl_event_handler IMPLEMENTATION .
*Handle Hotspot Click METHOD handle_hotspot_click . PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no . ENDMETHOD .
ENDCLASS.

DATA gr_event_handler TYPE REF TO lcl_event_handler . .. ..
*--Creating an instance for the event handler
CREATE OBJECT gr_event_handler .
*--Registering handler methods to handle ALV Grid events
SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .

Hope it helps,

Best regards

Former Member
0 Kudos
455

Thank you for all your help, Rich.

I think I will do the training thing. Implement double-click and create an alternate selection method ( Hilite row, then click a "Go to" button).

I'll check back when the points system is back up.

Regards,

Brett