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: 

Leave scren while Hotspot click

Former Member
0 Kudos

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.

4 REPLIES 4

naimesh_patel
Active Contributor
0 Kudos

Try to check this section.

module USER_COMMAND_0200 input.


case sy-ucomm.
when 'BACK'.
*leave to screen 100.
leave to screen 0.  " <<  change
endcase.
endmodule.

Regards,

Naimesh Patel

uwe_schieferstein
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi uwe,

When you are calling the screen 200 through Hotspot click, then what is the need of triggering the event through User command.

I copied the program from BCALV_GRID_03, problem is i dint find the problem in the program.

will help me in resolving the issue with in the program.

regards,

Madhavi

0 Kudos

Hello Madhavi

Basically you can call the screen within the event handler method like in BCALV_GRID_03. However, please note that there is a difference to my report: in the SAP report the second screen is called as modal popup. Thus, we stay on the same screen ('0100') and display on top of it the second screen '0101'.

When you display a second full screen then you should use my approach. Why?

Because of the logic of event handling.

When you trigger an ALV event (e.g. double_click, hotspot_click, button_click) PAI of the dynpro holding the ALV list is <b>NOT </b>passed. The event (which happend at the control frontend) allows you to communicate with your backend (i.e. the event handler method in your ABAP program).

After finishing event handling we are still at the <b>same </b>position of the dynpro flow logic as before raising the event.

Now if the event should cause display of a second full screen we should do it like in the normal processing of dynpros:

- pass PAI (using method cl_gui_cfw=>set_new_ok_code in the event handler method)
- decide which screen to show
- display new full screen

There is a second advantage of my approach:

When you leave the second full screen we pass again PBO of the first screen. This is the normal behaviour we expect when we go from one screen back to the previous one.

This will NOT happen if you call the second full screen within the event handler method because neither PAI nor PBO (of first screen) is passed.

<b>Conclusion:</b> Calling a second full screen within an event handler method (and not like the usual dynpro flow logic which you have to trigger) may collide with the expectations of the user about the flow logic of the screens.

Regards

Uwe