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: 

ALV - Hotspot disappears after edit mode

naveen1241
Participant
0 Kudos

Hi All,

I have an ALV report which has hotspot activated for certain cells. Initially, the hotspot is present and working.

Once the ALV is made editable using SET_READY_FOR_INPUT = 'X', the hotspot goes off and doesn't appear even after switching back to display mode using 'SET_READY_FOR_INPUT' = ''.

Welcoming suggestions/inputs.

Thanks in advance.

Naveen

6 REPLIES 6

jyotsna_singam
Explorer
0 Kudos

Hi Naveen,

Please share your piece of code if possible.

0 Kudos

Hi Jyotsna,

Thanks for the response.

The problem in short is the ALV which is in display mode is made editable on click of a custom button added in the application tool bar.

On clicking the button, the below code gets executed.

CALL METHOD lr_grid->set_ready_for_input 

    EXPORTING    

    i_ready_for_input = 1.

On commenting this out, the hotspot is working fine. If I leave the code as it is and call the same method again with set_ready_for_input = '', still the problem is there.

This means, some attributes being set by the set_ready_for_input = '1' is not getting reset by calling the same method and passing null value . Hope this clarifies.

Thanks.

Naveen

0 Kudos

Hey Naveen,

I tried a sample pgm but was not to replicate your scenario. Please find my snippets below.

Before Edit mode - Hotspot on Material No.

After clicking on custom button, ALV goes editable and hotspot remains.

PFB code for the same. Anyhow, I dint add in the code for Event for Hotspot click.

REPORT  zzdemo_hotspot.

TYPES: BEGIN  OF  ty_final,

           matnr       TYPE    mara-matnr,

           ersda       TYPE    mara-ersda,

           ernam       TYPE    mara-ernam,

           mtart       TYPE    mara-mtart,

         END   OF  ty_final.

DATA : t_final TYPE ty_final OCCURS 1,

        w_final TYPE ty_final,

        i_modified TYPE ty_final OCCURS 1,

        w_modified TYPE ty_final,

        itfcat TYPE lvc_t_fcat.

DATA : gstring TYPE c.

DATA : stable TYPE lvc_s_stbl.

DATA : gs_layout TYPE lvc_s_layo.

DATA o_container TYPE REF TO cl_gui_custom_container,

         o_grid      TYPE REF TO cl_gui_alv_grid.

DATA ok_code TYPE sy-ucomm.

DATA pr_data_changed TYPE REF TO cl_alv_changed_data_protocol.

CALL SCREEN 100.

*----------------------------------------------------------------------*

*  MODULE STATUS_100 OUTPUT

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

MODULE status_0100 OUTPUT.

   SET PF-STATUS 'ZSTANDARD'.

   IF o_container IS INITIAL.

     CREATE OBJECT o_container

       EXPORTING

         container_name = 'CONTAINER'.

     IF sy-subrc = 0.

       CREATE OBJECT o_grid

         EXPORTING

           i_parent = o_container.

       IF sy-subrc = 0.

         PERFORM read_data.

         PERFORM alv_build_fieldcat.

         gs_layout-edit = 'X'.

         CALL METHOD o_grid->set_table_for_first_display

           EXPORTING

             is_layout        = gs_layout

           CHANGING

             it_fieldcatalog  = itfcat

             it_outtab        = t_final.

         CALL METHOD o_grid->set_ready_for_input

           EXPORTING

             i_ready_for_input = 0.

       ENDIF.

     ENDIF.

   ENDIF.

ENDMODULE.                    "STATUS_0100 OUTPUT

*----------------------------------------------------------------------*

*  MODULE READ_DATA OUTPUT

*----------------------------------------------------------------------*

*

*----------------------------------------------------------------------*

FORM read_data.

   SELECT * INTO CORRESPONDING FIELDS OF TABLE t_final FROM mara UP TO 10 ROWS.

ENDFORM.                 " READ_DATA  OUTPUT

*&---------------------------------------------------------------------*

*&      Module  USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

MODULE user_command_0100 INPUT.

   CASE ok_code.

     WHEN 'BACK'.

       CLEAR ok_code.

       LEAVE TO SCREEN 0.

     WHEN 'MYFUNCTION'.

       CLEAR : ok_code.

       CALL METHOD o_grid->register_edit_event

         EXPORTING

           i_event_id = cl_gui_alv_grid=>mc_evt_modified.

       CALL METHOD o_grid->set_ready_for_input

         EXPORTING

           i_ready_for_input = 1.

   ENDCASE.

ENDMODULE.                 " USER_COMMAND_0100  INPUT

*&---------------------------------------------------------------------*

*&      Form  alv_build_fieldcat

*&---------------------------------------------------------------------*

*       text

*----------------------------------------------------------------------*

FORM alv_build_fieldcat.

   DATA : lv_fldcat TYPE lvc_s_fcat.

   CLEAR lv_fldcat.

   lv_fldcat-col_pos = 1.

   lv_fldcat-fieldname = 'MATNR'.

   lv_fldcat-seltext = 'Material Value'.

   lv_fldcat-key = 'X'.

   lv_fldcat-hotspot = 'X'.

   lv_fldcat-scrtext_m = 'Material No'.

   APPEND lv_fldcat TO itfcat.

   CLEAR lv_fldcat.

   lv_fldcat-col_pos = 2.

   lv_fldcat-fieldname = 'ERSDA'.

   lv_fldcat-seltext = 'Created On'.

   lv_fldcat-scrtext_m = 'Created On'.

   APPEND lv_fldcat TO itfcat.

   CLEAR lv_fldcat.

   lv_fldcat-col_pos = 3.

   lv_fldcat-fieldname = 'ERNAM'.

   lv_fldcat-seltext = 'Created by'.

   lv_fldcat-scrtext_m = 'Created by'.

   APPEND lv_fldcat TO itfcat.

   CLEAR lv_fldcat.

   lv_fldcat-col_pos = 4.

   lv_fldcat-fieldname = 'MTART'.

   lv_fldcat-seltext = 'Material Type'.

   lv_fldcat-scrtext_m = 'Mat Type'.

   APPEND lv_fldcat TO itfcat.

   CLEAR lv_fldcat.

ENDFORM.                    "ALV_BUILD_FIELDCAT

Hope this helps.

Regards,

Jyotsna Singam

0 Kudos

Hi Jyotsna,

Thank you so much for taking time out and putting in so much of effort . From, what you have done, I understand that the problem is related to something else. Actually, the catch here should be the usage of SALV. I'm using the SALV and making it editable. In normal cases, this shouldn't be happening as you have demonstrated well enough. Sorry for not sharing the entire codebase here in public due to confidentiality and hence put in only the part which I thought was relevant.

Once again thanks and highly appreciate having taken your time out.

I'm not sure if I mark this as helpful answer, I would be able to mark the same again as Correct answer in case you guided me in the proper direction. I've not been using the forum for quite long.

Warm Regards,

Naveen

0 Kudos

Hey Naveen,

Happy to help

I dint come accross usage of 'SET_READY_FOR_INPUT' in SALV. Use SET_CELL_TYPE method to set hotspot for entire column in SALV. Hotspot works for me in both display and edit modes!! I referred couple of blogs to build in the below logic.



REPORT  zzdemo_salv_edit_hotspot.

*----------------------------------------------------------------------*

*  Define the Local class inheriting from the CL_SALV_MODEL_LIST

*  to get an access of the model, controller and adapter which inturn

*  provides the Grid Object

*----------------------------------------------------------------------*

CLASS lcl_salv_model DEFINITION INHERITING FROM cl_salv_model_list.

   PUBLIC SECTION.

     DATA: o_control TYPE REF TO cl_salv_controller_model,

           o_adapter TYPE REF TO cl_salv_adapter.

     METHODS:

       grabe_model

         IMPORTING

           io_model TYPE REF TO cl_salv_model,

        grabe_controller,

        grabe_adapter.

   PRIVATE SECTION.

     DATA: lo_model TYPE REF TO cl_salv_model.

ENDCLASS.                    "LCL_SALV_MODEL DEFINITION

*----------------------------------------------------------------------*

* Event handler for the added buttons

*----------------------------------------------------------------------*

CLASS lcl_event_handler DEFINITION.

   PUBLIC SECTION.

     METHODS:

       on_user_command FOR EVENT added_function OF cl_salv_events

         IMPORTING e_salv_function.

ENDCLASS.                    "lcl_event_handler DEFINITION

*----------------------------------------------------------------------*

* Local Report class - Definition

*----------------------------------------------------------------------*

CLASS lcl_report DEFINITION.

   PUBLIC SECTION.

     TYPES: ty_t_sflights TYPE STANDARD TABLE OF sflights.

*    TYPES : BEGIN OF ty_t_sflights.

*            INCLUDE TYPE sflights.

*    TYPES : i_celltype TYPE salv_t_int4_column,

*   END OF ty_t_sflights.

     DATA: t_data TYPE ty_t_sflights.

     DATA: o_salv       TYPE REF TO cl_salv_table.

     DATA: o_salv_model TYPE REF TO lcl_salv_model.

     METHODS:

       get_data,

       generate_output.

ENDCLASS.                    "lcl_report DEFINITION

*----------------------------------------------------------------------*

* Global data

*----------------------------------------------------------------------*

DATA: lo_report TYPE REF TO lcl_report.

*----------------------------------------------------------------------*

* Start of selection

*----------------------------------------------------------------------*

START-OF-SELECTION.

   CREATE OBJECT lo_report.

   lo_report->get_data( ).

   lo_report->generate_output( ).

*----------------------------------------------------------------------*

* Local Report class - Implementation

*----------------------------------------------------------------------*

CLASS lcl_report IMPLEMENTATION.

   METHOD get_data.

*   test data

     SELECT * FROM sflights

            INTO TABLE me->t_data

            UP TO 30 ROWS.

    ENDMETHOD.                    "get_data

  METHOD generate_output.

*...New ALV Instance ...............................................

     TRY.

         cl_salv_table=>factory(

            EXPORTING

*             r_container    = w_alv1

              list_display = abap_false

            IMPORTING

              r_salv_table = o_salv

            CHANGING

              t_table      = t_data ).

       CATCH cx_salv_msg.                                "#EC NO_HANDLER

     ENDTRY.

*...PF Status.......................................................

*   Add MYFUNCTION from the report SALV_DEMO_TABLE_EVENTS

     o_salv->set_screen_status(

       pfstatus      'SALV_STANDARD'

       report        'SALV_DEMO_TABLE_EVENTS'

       set_functions = o_salv->c_functions_all ).

*...Event handler for the button.....................................

     DATA: lo_events TYPE REF TO cl_salv_events_table,

           lo_event_h TYPE REF TO lcl_event_handler.

* event object

     lo_events = o_salv->get_event( ).

* event handler

     CREATE OBJECT lo_event_h.

* setting up the event handler

     SET HANDLER lo_event_h->on_user_command FOR lo_events.

*...Get Model Object ...............................................

     DATA: lo_alv_mod TYPE REF TO cl_salv_model.

*   Narrow casting

     lo_alv_mod ?= o_salv.

*   object for the local inherited class from the CL_SALV_MODEL_LIST

     CREATE OBJECT o_salv_model.

*   grabe model to use it later

     CALL METHOD o_salv_model->grabe_model

       EXPORTING

         io_model = lo_alv_mod.

  *...HotSpot

     DATA: lo_cols_tab TYPE REF TO cl_salv_columns_table,

           lo_col_tab  TYPE REF TO cl_salv_column_table.

*

*   get Columns object

     lo_cols_tab = o_salv->get_columns( ).

*

*   Get CARRID column

     TRY.

         lo_col_tab ?= lo_cols_tab->get_column( 'CARRID' ).

       CATCH cx_salv_not_found.

     ENDTRY.

*

*   Set the HotSpot for CARRID Column

     TRY.

         CALL METHOD lo_col_tab->set_cell_type

           EXPORTING

             value = if_salv_c_cell_type=>hotspot.

         .

       CATCH cx_salv_data_error .

     ENDTRY.

*...Events -- set your event handlers

*...Generate ALV output ...............................................

     o_salv->display( ).

   ENDMETHOD.                    "generate_output

ENDCLASS.                    "lcl_report IMPLEMENTATION

*----------------------------------------------------------------------*

* LCL_SALV_MODEL implementation

*----------------------------------------------------------------------*

CLASS lcl_salv_model IMPLEMENTATION.

   METHOD grabe_model.

*   save the model

     lo_model = io_model.

   ENDMETHOD.                    "grabe_model

   METHOD grabe_controller.

*   save the controller

     o_control = lo_model->r_controller.

   ENDMETHOD.                    "grabe_controller

   METHOD grabe_adapter.

*   save the adapter from controller

     o_adapter ?= lo_model->r_controller->r_adapter.

   ENDMETHOD.                    "grabe_adapter

ENDCLASS.                    "LCL_SALV_MODEL IMPLEMENTATION

*----------------------------------------------------------------------*

* Event Handler for the SALV

*----------------------------------------------------------------------*

CLASS lcl_event_handler IMPLEMENTATION.

   METHOD on_user_command.

     DATA: lo_grid TYPE REF TO cl_gui_alv_grid,

     lo_full_adap TYPE REF TO cl_salv_fullscreen_adapter.

     DATA: ls_layout TYPE lvc_s_layo.

     CASE e_salv_function.

*     Make ALV as Editable ALV

       WHEN 'MYFUNCTION'.

*       Contorller

         CALL METHOD lo_report->o_salv_model->grabe_controller.

*       Adapter

         CALL METHOD lo_report->o_salv_model->grabe_adapter.

*       Fullscreen Adapter (Down Casting)

         lo_full_adap ?= lo_report->o_salv_model->o_adapter.

*       Get the Grid

         lo_grid = lo_full_adap->get_grid( ).

*       Got the Grid .. ?

         IF lo_grid IS BOUND.

*         Editable ALV

           ls_layout-edit = 'X'.

*         Set the front layout of ALV

           CALL METHOD lo_grid->set_frontend_layout

             EXPORTING

               is_layout = ls_layout.

*         refresh the table

           CALL METHOD lo_grid->refresh_table_display.

         ENDIF.

     ENDCASE.

   ENDMETHOD.                    "on_user_command

ENDCLASS.                    "lcl_event_handler IMPLEMENTATION


Refer below blogs/posts for further details

http://zevolving.com/2008/09/salv-table-8-add-handle-hotspot/

Hope this helps.

0 Kudos

As SAP does not "want" SALV to allow input (*), this kind of behavior is not surprising, you tricked the system to allow input, and The System Strikes Back...

Regards,

Raymond

(*) International Editable SALV Day 2015