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: 

Hotspot unable to display screen

former_member670450
Participant
0 Kudos

Hi, im doing this hotspot in preparation for upcoming project, Ive successfully displayed a simple alv report but i was unable to click into the matnr which calls transaction. Sorry im still new here, your input would be appreciated

*&---------------------------------------------------------------------*
*& Report ZAS_PROGRAM_OOALV
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ZAS_PROGRAM_OOALV_V1.

TYPES: BEGIN OF TY_MAT,
         MATNR   TYPE MARA-MATNR,
         MTART   TYPE MARA-MTART,
         MATNR_1 TYPE MARC-MATNR,
         WERKS   TYPE MARC-WERKS,
         WERKS_1 TYPE T001W-WERKS,
         NAME1   TYPE T001W-NAME1,
       END OF TY_MAT.


DATA: IT_MAT TYPE TABLE OF TY_MAT,
      WA_MAT LIKE LINE OF IT_MAT.

DATA: it_fcat TYPE STANDARD TABLE OF lvc_s_fcat,
      wa_fcat TYPE lvc_s_fcat.

DATA: it_sort TYPE STANDARD TABLE OF lvc_s_sort,
      wa_sort TYPE lvc_s_sort.

DATA: container_r TYPE REF TO cl_gui_custom_container,
      grid_r TYPE REF TO CL_GUI_alv_grid.

**********
CLASS lcl_events_d0100 DEFINITION DEFERRED.
  DATA gr_events_d0100 TYPE REF TO lcl_events_d0100.
*********



INITIALIZATION.

SELECTION-SCREEN BEGIN OF BLOCK TEST1 WITH FRAME TITLE TEXT-001.
SELECT-OPTIONS S_MATNR FOR WA_MAT-MATNR OBLIGATORY no-EXTENSION.   ""obligatory - when only fill up upper limit will prompt error, if only fill up lower limit wont prompt
*  PARAMETERS: s_matnr LIKE lv_matnr.
SELECTION-SCREEN END OF BLOCK TEST1.



CLASS lcl_mat DEFINITION.
  PUBLIC SECTION.
  METHODs: get_mat,
           fld_cat.
  ENDCLASS.


******************
CLASS lcl_events_d0100 DEFINITION.

  PUBLIC SECTION.
      METHODS: handle_hotspot_click for event hotspot_click of cl_gui_alv_grid
          IMPORTING
             e_row_id
             e_column_id
             es_row_no
             sender.


  ENDCLASS.
*******************
*
******************
CLASS lcl_events_d0100 IMPLEMENTATION.


METHOD handle_hotspot_click.
  DATA ls_col_id TYPE lvc_s_col.
  READ TABLE it_mat INTO wa_mat INDEX e_row_id-index.

 set PARAMETER ID 'MATNR' FIELD wa_mat-matnr.

  IF sy-subrc = 0 .
*CHECK ( wa_mat-matnr is not initial ).

CASE e_column_id-fieldname.
  WHEN 'MATNR'.
    CALL TRANSACTION 'mm03'.
    WHEN OTHERS.
**      basically doing nothing.
        endcase.



  CALL METHOD grid_r->set_current_cell_via_id
  EXPORTING
    is_row_id = e_row_id
    is_column_id = ls_col_id.

  ENDIF.

  ENDMETHOD.


ENDCLASS.
*******************

      START-OF-SELECTION.

      DATA MAT TYPE REF TO lcl_mat.
      create OBJECT MAT.  ""instance
      CALL METHOD: mat->get_mat.

 class lcl_mat IMPLEMENTATION.

  METHOD: get_mat.
*----------------------------------------------------------------------------------*

  SELECT A~MATNR
         A~MTART
         B~WERKS
         C~NAME1
    INTO CORRESPONDING FIELDS OF TABLE IT_MAT FROM MARA AS A INNER JOIN MARC AS B ON A~MATNR = B~MATNR
    INNER JOIN T001W AS C ON B~WERKS = C~WERKS
    WHERE A~MATNR IN S_MATNR.

    call METHOD: fld_cat.

     call screen 900.

    endmethod.


    METHOD: fld_cat.

      CLEAR wa_fcat.
      refresh it_fcat.
      DATA: NO TYPE i value 0.

    no = no + 1.
    wa_fcat-col_pos = NO.
    wa_fcat-fieldname = 'matnr'.
    wa_fcat-tabname = 'it_mat'.
    wa_fcat-reptext = 'Material Number'.
    wa_fcat-col_opt = 'X'.     """column optimization
    wa_fcat-no_zero = 'X'.
    wa_fcat-hotspot = 'X'.
    append wa_fcat to it_fcat.
    CLEAR wa_fcat.

    no = no + 1.
    wa_fcat-col_pos = NO.
    wa_fcat-fieldname = 'mtart'.
    wa_fcat-tabname = 'it_mat'.
    wa_fcat-reptext = 'Material Type'.
    wa_fcat-col_opt = 'X'.     """column optimization
    append wa_fcat to it_fcat.
    CLEAR wa_fcat.

    no = no + 1.
    wa_fcat-col_pos = NO.
    wa_fcat-fieldname = 'werks'.
    wa_fcat-tabname = 'it_mat'.
    wa_fcat-reptext = 'Plant'.
    wa_fcat-col_opt = 'X'.     """column optimization
    append wa_fcat to it_fcat.
    CLEAR wa_fcat.

        no = no + 1.
    wa_fcat-col_pos = NO.
    wa_fcat-fieldname = 'name1'.
    wa_fcat-tabname = 'it_mat'.
    wa_fcat-reptext = 'Plant Description'.
    wa_fcat-col_opt = 'X'.     """column optimization
    append wa_fcat to it_fcat.
    CLEAR wa_fcat.

    no = no + 1.
    wa_sort-SPOS = NO.
    wa_sort-fieldname = 'matnr'.
    wa_sort-down = 'X'.
    APPEND wa_sort TO it_sort.
    CLEAR wa_sort.

        no = no + 1.
    wa_sort-SPOS = NO.
    wa_sort-fieldname = 'mtart'.
    wa_sort-down = 'X'.
    APPEND wa_sort TO it_sort.
    CLEAR wa_sort.


      ENDMETHOD.


ENDCLASS.

*&---------------------------------------------------------------------*
*& Module STATUS_0900 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_0900 OUTPUT.
 SET PF-STATUS 'SCREEN_900'.
 SET TITLEBAR 'SCREEN_900'.


 CREATE OBJECT CONTAINER_R
   EXPORTING
*     PARENT                      =
     CONTAINER_NAME              = 'CONTAINER'
*     STYLE                       =
*     LIFETIME                    = lifetime_default
*     REPID                       =
*     DYNNR                       =
*     NO_AUTODEF_PROGID_DYNNR     =
*   EXCEPTIONS
*     CNTL_ERROR                  = 1
*     CNTL_SYSTEM_ERROR           = 2
*     CREATE_ERROR                = 3
*     LIFETIME_ERROR              = 4
*     LIFETIME_DYNPRO_DYNPRO_LINK = 5
*     OTHERS                      = 6
     .
* IF SY-SUBRC <> 0.
**  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.

 CREATE OBJECT GRID_R
   EXPORTING
*     I_SHELLSTYLE      = 0
*     I_LIFETIME        =
     I_PARENT          = container_r        ""container object name
*     I_APPL_EVENTS     = SPACE
*     I_PARENTDBG       =
*     I_APPLOGPARENT    =
*     I_GRAPHICSPARENT  =
*     I_NAME            =
*     I_FCAT_COMPLETE   = SPACE
*     O_PREVIOUS_SRAL_HANDLER =
*   EXCEPTIONS
*     ERROR_CNTL_CREATE = 1
*     ERROR_CNTL_INIT   = 2
*     ERROR_CNTL_LINK   = 3
*     ERROR_DP_CREATE   = 4
*     OTHERS            = 5
     .
* IF SY-SUBRC <> 0.
**  MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
**             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
* ENDIF.

 CALL METHOD GRID_R->SET_TABLE_FOR_FIRST_DISPLAY
   EXPORTING
*     I_BUFFER_ACTIVE               =
*     I_BYPASSING_BUFFER            =
*     I_CONSISTENCY_CHECK           =
     I_STRUCTURE_NAME              = 'it_mat'
*     IS_VARIANT                    =
*     I_SAVE                        =
*     I_DEFAULT                     = 'X'
*     IS_LAYOUT                     =
*     IS_PRINT                      =
*     IT_SPECIAL_GROUPS             =
*     IT_TOOLBAR_EXCLUDING          =
*     IT_HYPERLINK                  =
*     IT_ALV_GRAPHICS               =
*     IT_EXCEPT_QINFO               =
*     IR_SALV_ADAPTER               =
   CHANGING
     IT_OUTTAB                     = it_mat
     IT_FIELDCATALOG               = it_fcat
     IT_SORT                       = it_sort
*     IT_FILTER                     =
*   EXCEPTIONS
*     INVALID_PARAMETER_COMBINATION = 1
*     PROGRAM_ERROR                 = 2
*     TOO_MANY_LINES                = 3
*     OTHERS                        = 4
         .
* IF SY-SUBRC <> 0.
**  Implement suitable error handling here
* ENDIF.


DATA : ty_toolbar      TYPE stb_button.
DATA : e_object        TYPE REF TO cl_alv_event_toolbar_set,
       io_alv_toolbar  TYPE REF TO cl_alv_event_toolbar_set.
"Alv toolbar
DATA: event_handler  TYPE REF TO lcl_events_d0100.

  CREATE OBJECT event_handler.
  SET HANDLER event_handler->handle_hotspot_click FOR grid_r.



ENDMODULE.




*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0900  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE USER_COMMAND_0900 INPUT.

IF sy-ucomm = 'EXIT'.
  SET SCREEN 0.
  MESSAGE 'You left the screen without saving' TYPE 'S'.

 ELSEIF sy-ucomm = 'BACK'.
  SET SCREEN 0.
  MESSAGE 'You left the screen without saving' TYPE 'S'.

   ELSEIF sy-ucomm = 'SAVE'.
  SET SCREEN 0.
  MESSAGE 'Changes Saved' TYPE 'S'.

   ELSEIF sy-ucomm = 'EXECUTE'.
  CALL SCREEN 900.

ENDIF.


ENDMODULE.
1 ACCEPTED SOLUTION

Florian
Active Contributor
0 Kudos

Hi, didn't recognize that you are using

CL_GUI_alv_grid

To answer your qustion, did you debug the problem? I looked into it, because I didn't see a mistake on a second view.

But.. if you compare matnr with MATNR it will never run into your case.. btw using literals is not good. Use a constant 🙂

and you will also not be happy that the system won't find mm03... remember the case sensitive thing ...

9 REPLIES 9

Florian
Active Contributor

NEw is not a problem. We're a community and helping each other.

Here is a link with the same question:

https://answers.sap.com/questions/7832265/alv-hotspot-and-on-click-event.html

Maybe you make yourself familiar with the search.

Have a look here, the optic has changed a little bit, but the result remains the same:

https://blogs.sap.com/2015/11/30/how-to-use-the-new-search-on-scn/

0 Kudos

Hi Florian, thanks for your reply, here it is using salv but for mine, I am using the older oo alv, does this mean I have to redo again?

My code is there any problem structurally so that I can look into it?

Florian
Active Contributor
0 Kudos

Hi, didn't recognize that you are using

CL_GUI_alv_grid

To answer your qustion, did you debug the problem? I looked into it, because I didn't see a mistake on a second view.

But.. if you compare matnr with MATNR it will never run into your case.. btw using literals is not good. Use a constant 🙂

and you will also not be happy that the system won't find mm03... remember the case sensitive thing ...

0 Kudos

Thank you for your answer, i was able to click into it but it is not showing the relevant material in the transaction mm03.

Im still learning to debug and inserted skip first screen CALL TRANSACTION 'MM03' AND SKIP FIRST SCREEN. by right it should skip the mm03 selection screen and show the relevant material, still looking into it

"literals is not good. Use a constant :-)"

Do you mind elaborate on this statement?

venkateswaran_k
Active Contributor
0 Kudos

Hi,

In order to find out the issue, Please put the breakpoint at following positions in your code.

CASE e_column_id-fieldname.
  WHEN 'MATNR'.
    CALL TRANSACTION 'mm03'.
    WHEN OTHERS.
break-point.

and

MODULE USER_COMMAND_0900 INPUT.
  break-point

Once reached there, find out where your control is coming? secondly what is the sy-ucomm value and e_column_id

and update me what is your findings.

Regards,

Venkat

0 Kudos

You shouldn't use hard break-point.. and yes.. isn't that exactly that what I have recommended?

0 Kudos

Hi Florian

Yes, it is same. Just my intention is to narrow down to the problem.

A temporary step ..

Apologies if inconvenience.

Regards,

Venkat

0 Kudos

Hi Venkateswaran,

CASE e_column_id-fieldname.
  WHEN 'MATNR'.
    CALL TRANSACTION 'mm03'.
    WHEN OTHERS.

In regards to this it was lowercase/upper case issue.

Correct me if im wrong, sy-ucomm is a system variable, an ok code, for navigation, programmed by assigning function keys for navigation between screens whereas e_column_id is used for hotspot click by index.

0 Kudos

Hi

Oh it was typo error. It should be MM03.

I am aware of what is sy-comm.. What I meant was, I want you to check what value is coming inside those variables in debug..