Application Development and Automation 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: 
Read only

Can anyone troubleshoot this code??

sachin_soni
Active Participant
0 Likes
1,056

hi all !

lemme tell u that i'm tryin to pop up a screen when someone clicks on connid which is a hotspot.but it isnt wrkin. here is the code:

*&----


*

*& Report ZSS_OOP_ALV *

*& *

*&----


*

*& *

*& *

*&----


*

REPORT zss_oop_alv .

*********************DATA DECLARATION-GLOBAL DATA FIELDS*************

DATA: alv_grid TYPE REF TO cl_gui_alv_grid, "for screen 1

custom_container TYPE REF TO cl_gui_custom_container,

alv_grid1 TYPE REF TO cl_gui_alv_grid, "for screen 2

custom_container1 TYPE REF TO cl_gui_custom_container,

pt_fieldcat TYPE lvc_t_fcat,

pt_fieldcat1 TYPE lvc_t_fcat,

ok_code LIKE sy-ucomm,

save_ok LIKE sy-ucomm,

layout1 TYPE lvc_s_layo.

*********************DATA DECLARATION-INTERNAL TABLE*****************

DATA: BEGIN OF i_list OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA: END OF i_list.

DATA: BEGIN OF i_list1 OCCURS 0.

INCLUDE STRUCTURE sflight.

DATA: END OF i_list1.

********************DATA DECLARATION-INTERNAL TABLE*****************

DATA: BEGIN OF g_list OCCURS 0.

INCLUDE STRUCTURE sticket.

DATA: END OF g_list.

**********************EVENT HANDLER CLASS****************

CLASS lcl_event_handler 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.

ENDCLASS. "lcl_event_handler DEFINITION

**********************EVENT HANDLER CLASS*************

CLASS lcl_event_handler IMPLEMENTATION.

METHOD handle_hotspot_click .

PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .

ENDMETHOD . "handle_hotspot_click

ENDCLASS. "lcl_event_handler IMPLEMENTATION

***************CREATE AN INSTANCE OF THE CLASS***********************

DATA: gr_event_handler TYPE REF TO lcl_event_handler .

*--Creating an instance for the event handler

**********************START-OF-SELECTION*****************************

START-OF-SELECTION.

SELECT * FROM sflight INTO TABLE i_list.

SELECT * FROM sticket INTO TABLE g_list.

CALL SCREEN 0100.

END-OF-SELECTION.

*----


*

  • MODULE display PBO

*----


*

*

*----


*

MODULE display_alv OUTPUT.

SET PF-STATUS 'MAIN101'.

SET TITLEBAR 'MAIN100'.

PERFORM prepare_field_catalog .

PERFORM DISPLAY_ALV.

ENDMODULE. "display_alv OUTPUT

*&----


*

*& Form display_alv

*&----


*

  • text

*----


*

FORM display_alv.

IF alv_grid IS INITIAL. "CHK IF GRID ALREADY EXISTS

CREATE OBJECT custom_container "IF NOT CREATE ONE CUSTOM CONTAINER FOR IT !

EXPORTING

  • PARENT =

container_name = 'CC_ALV'

  • 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 alv_grid "NOW CREATE A GRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

i_parent = custom_container

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • 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.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD alv_grid->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE

EXPORTING

i_ready_for_input = 1.

CALL METHOD alv_grid->set_table_for_first_display "SET THE DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME = 'SFLIGHT'

  • IS_VARIANT =

i_save = 'A'

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

it_outtab = i_list[]

it_fieldcatalog = pt_fieldcat

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

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.

ELSE.

ENDIF.

ENDFORM. " alv_display

*&----


*

*& Module STATUS_0100 OUTPUT

*&----


*

  • text

*----


*

*&----


*

*& Module USER_COMMAND_0100 INPUT

*&----


*

  • text

*----


*

MODULE user_command_0100 INPUT. "FOR THE EXIT BACK AND UP FUNCTIONS

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'EXIT'.

PERFORM exit_program.

WHEN 'BACK' .

PERFORM exit_program.

WHEN 'UP' .

PERFORM exit_program.

WHEN 'SWITCH'.

PERFORM switch_edit_mode.

WHEN OTHERS.

  • do nothing

ENDCASE.

SET HANDLER gr_event_handler->handle_hotspot_click FOR alv_grid1 .

CREATE OBJECT gr_event_handler .

ENDMODULE. " USER_COMMAND_0100 INPUT

*----


*

  • FORM EXIT_PROGRAM *

*----


*

FORM exit_program.

LEAVE PROGRAM.

ENDFORM. "exit_program

*&----


*

*& Form switch_edit_mode

*&----


*

  • text

*----


*

FORM switch_edit_mode.

*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.

IF alv_grid->is_ready_for_input( ) EQ 0.

*§4.Use SET_READY_FOR_INPUT to switch between the substates.

CALL METHOD alv_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 1.

ELSE.

CALL METHOD alv_grid->set_ready_for_input

EXPORTING

i_ready_for_input = 0.

ENDIF.

ENDFORM. " SWITCH_EDIT_MODE

*&----


*

*& Form prepare_field_catalog

*&----


*

  • text

*----


*

FORM prepare_field_catalog .

DATA ls_fcat TYPE lvc_s_fcat .

ls_fcat-fieldname = 'CARRID' .

ls_fcat-inttype = 'C' .

ls_fcat-outputlen = '9' .

ls_fcat-coltext = 'Carrier ID' .

ls_fcat-seltext = 'Carrier ID' .

ls_fcat-col_pos = '2' .

APPEND ls_fcat TO pt_fieldcat .

CLEAR ls_fcat .

ls_fcat-fieldname = 'CONNID' .

ls_fcat-ref_table = 'SFLIGHT' .

ls_fcat-ref_field = 'CONNID' .

ls_fcat-hotspot = 'X'.

  • ls_fcat-outputlen = '9' .

ls_fcat-col_pos = '1' .

  • ls_fcat-coltext = 'Connection ID' .

  • ls_fcat-seltext = 'Connection ID' .

APPEND ls_fcat TO pt_fieldcat .

ENDFORM . "prepare_field_catalog

*&----


*

*& Form handle_hotspot_click

*&----


*

  • text

*----


*

  • -->P_E_ROW_ID text

  • -->P_E_COLUMN_ID text

  • -->P_ES_ROW_NO text

*----


*

FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row

i_column_id TYPE lvc_s_col

is_row_no TYPE lvc_s_roid.

READ TABLE i_list INDEX is_row_no-row_id .

READ TABLE g_list with key CONNID = i_list-connid .

CALL SCREEN 200 STARTING AT 10 5. "Details about passenger-seat matching

IF sy-subrc = 0 AND i_column_id-fieldname = 'CONNID' .

ENDIF .

ENDFORM .

*&----


*

*& Module STATUS_0200 OUTPUT

*&----


*

  • text

*----


*

module STATUS_0200 output. "PBO for 200

PERFORM build_cat .

PERFORM display_alv1.

endmodule. " STATUS_0200 OUTPUT

*************************************************************************

FORM display_alv1.

IF alv_grid1 IS INITIAL. "CHK IF GRID ALREADY EXISTS

CREATE OBJECT custom_container "IF NOT CREATE ONE CUSTOM CONTAINER FOR IT !

EXPORTING

  • PARENT =

container_name = 'CC_ALV1'

  • 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 alv_grid1 "NOW CREATE A GRID

EXPORTING

  • I_SHELLSTYLE = 0

  • I_LIFETIME =

i_parent = custom_container1

  • I_APPL_EVENTS = space

  • I_PARENTDBG =

  • I_APPLOGPARENT =

  • I_GRAPHICSPARENT =

  • 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.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

CALL METHOD alv_grid1->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE

EXPORTING

i_ready_for_input = 1.

CALL METHOD alv_grid1->set_table_for_first_display "SET THE DISPLAY

EXPORTING

  • I_BUFFER_ACTIVE =

  • I_BYPASSING_BUFFER =

  • I_CONSISTENCY_CHECK =

  • I_STRUCTURE_NAME = 'STICKET'

  • IS_VARIANT =

i_save = 'A'

  • I_DEFAULT = 'X'

  • IS_LAYOUT =

  • IS_PRINT =

  • IT_SPECIAL_GROUPS =

  • IT_TOOLBAR_EXCLUDING =

  • IT_HYPERLINK =

  • IT_ALV_GRAPHICS =

  • IT_EXCEPT_QINFO =

CHANGING

it_outtab = g_list[]

it_fieldcatalog = pt_fieldcat1

  • IT_SORT =

  • IT_FILTER =

EXCEPTIONS

invalid_parameter_combination = 1

program_error = 2

too_many_lines = 3

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.

ELSE.

ENDIF.

ENDFORM. " alv_display1

*&----


*

*& Form build_cat

*&----


*

  • text

*----


*

  • --> p1 text

  • <-- p2 text

*----


*

form build_cat .

DATA ls_fcat TYPE lvc_s_fcat .

ls_fcat-fieldname = 'CONNID' .

ls_fcat-inttype = 'C' .

ls_fcat-outputlen = '9' .

ls_fcat-coltext = 'CONNECTION ID' .

ls_fcat-seltext = 'CONNECTION ID' .

ls_fcat-col_pos = '2' .

ls_fcat-hotspot = 'X' .

APPEND ls_fcat TO pt_fieldcat1 .

CLEAR ls_fcat .

ls_fcat-fieldname = 'BOOKID' .

ls_fcat-ref_table = 'STICKET' .

ls_fcat-ref_field = 'BOOKID' .

  • ls_fcat-outputlen = '9' .

ls_fcat-col_pos = '1' .

  • ls_fcat-coltext = 'Connection ID' .

  • ls_fcat-seltext = 'Connection ID' .

APPEND ls_fcat TO pt_fieldcat1 .

endform. " build_cat

waitin for some help

sachin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,027

Hi Sachin,

The Event for hotspot was not registered properly. You should add the code SET HANDLER before displaying the ALV grid.

I have changed the code. It should work now.

Please reward helpful posts.

Regards

Wenceslaus.

**********************DATA DECLARATION-GLOBAL DATA FIELDS**************
DATA: alv_grid TYPE REF TO cl_gui_alv_grid, "for screen 1
custom_container TYPE REF TO cl_gui_custom_container,

alv_grid1 TYPE REF TO cl_gui_alv_grid, "for screen 2
custom_container1 TYPE REF TO cl_gui_custom_container,

pt_fieldcat TYPE lvc_t_fcat,
pt_fieldcat1 TYPE lvc_t_fcat,
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
layout1 TYPE lvc_s_layo.

**********************DATA DECLARATION-INTERNAL TABLE******************

DATA: BEGIN OF i_list OCCURS 0.
        INCLUDE STRUCTURE sflight.
DATA: END OF i_list.

DATA: BEGIN OF i_list1 OCCURS 0.
        INCLUDE STRUCTURE sflight.
DATA: END OF i_list1.

*********************DATA DECLARATION-INTERNAL TABLE******************

DATA: BEGIN OF g_list OCCURS 0.
        INCLUDE STRUCTURE sticket.
DATA: END OF g_list.

***********************EVENT HANDLER CLASS*[DEFINITION]****************

CLASS lcl_event_handler 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.

ENDCLASS. "lcl_event_handler DEFINITION

***********************EVENT HANDLER CLASS*[IMPLEMENTATION]*************
CLASS lcl_event_handler IMPLEMENTATION.

  METHOD handle_hotspot_click .
    PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
  ENDMETHOD . "handle_hotspot_click

ENDCLASS. "lcl_event_handler IMPLEMENTATION


****************CREATE AN INSTANCE OF THE CLASS************************
DATA: gr_event_handler TYPE REF TO lcl_event_handler .


*--Creating an instance for the event handler


***********************START-OF-SELECTION******************************

START-OF-SELECTION.

  CREATE OBJECT gr_event_handler .

  SELECT * FROM sflight INTO TABLE i_list.
  SELECT * FROM sticket INTO TABLE g_list.

  CALL SCREEN 0100.


END-OF-SELECTION.

*---------------------------------------------------------------------*
* MODULE display PBO
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE display_alv OUTPUT.

  SET PF-STATUS 'MAIN101'.
  SET TITLEBAR 'MAIN100'.
  PERFORM prepare_field_catalog .
  PERFORM display_alv.



ENDMODULE. "display_alv OUTPUT

*&--------------------------------------------------------------------*
*& Form display_alv
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM display_alv.

  IF alv_grid IS INITIAL. "CHK IF GRID ALREADY EXISTS
    CREATE OBJECT custom_container
      EXPORTING
*    PARENT                      =
        container_name              = 'CC_ALV'
        .


    CREATE OBJECT alv_grid
      EXPORTING
        i_parent          = custom_container
        .
    CALL METHOD alv_grid->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE
EXPORTING
i_ready_for_input = 1.

    SET HANDLER gr_event_handler->handle_hotspot_click FOR alv_grid .

    CALL METHOD alv_grid->set_table_for_first_display "SET THE DISPLAY
    EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'SFLIGHT'
* IS_VARIANT =
    i_save = 'A'
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = i_list[]
    it_fieldcatalog = pt_fieldcat
* IT_SORT =
* IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    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.

  ELSE.


  ENDIF.


ENDFORM. " alv_display
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT. "FOR THE EXIT BACK AND UP FUNCTIONS


  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN 'BACK' .
      PERFORM exit_program.
    WHEN 'UP' .
      PERFORM exit_program.
    WHEN 'SWITCH'.
      PERFORM switch_edit_mode.

    WHEN OTHERS.
* do nothing
  ENDCASE.

*SET HANDLER gr_event_handler->handle_hotspot_click FOR alv_grid1 .

ENDMODULE. " USER_COMMAND_0100 INPUT

*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
  LEAVE PROGRAM.
ENDFORM. "exit_program

*&--------------------------------------------------------------------*
*& Form switch_edit_mode
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM switch_edit_mode.
*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
  IF alv_grid->is_ready_for_input( ) EQ 0.
*§4.Use SET_READY_FOR_INPUT to switch between the substates.
    CALL METHOD alv_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
  ELSE.
    CALL METHOD alv_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
  ENDIF.
ENDFORM. " SWITCH_EDIT_MODE

*&--------------------------------------------------------------------*
*& Form prepare_field_catalog
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM prepare_field_catalog .

  DATA ls_fcat TYPE lvc_s_fcat .
  ls_fcat-fieldname = 'CARRID' .
  ls_fcat-inttype = 'C' .
  ls_fcat-outputlen = '9' .
  ls_fcat-coltext = 'Carrier ID' .
  ls_fcat-seltext = 'Carrier ID' .
  ls_fcat-col_pos = '2' .


  APPEND ls_fcat TO pt_fieldcat .

  CLEAR ls_fcat .

  ls_fcat-fieldname = 'CONNID' .
  ls_fcat-ref_table = 'SFLIGHT' .
  ls_fcat-ref_field = 'CONNID' .
  ls_fcat-hotspot = 'X'.
* ls_fcat-outputlen = '9' .
  ls_fcat-col_pos = '1' .
* ls_fcat-coltext = 'Connection ID' .
* ls_fcat-seltext = 'Connection ID' .

  APPEND ls_fcat TO pt_fieldcat .
ENDFORM . "prepare_field_catalog
*&---------------------------------------------------------------------*
*& Form handle_hotspot_click
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_ROW_ID text
* -->P_E_COLUMN_ID text
* -->P_ES_ROW_NO text
*----------------------------------------------------------------------*
FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row
i_column_id TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.


  READ TABLE i_list INDEX is_row_no-row_id .
  READ TABLE g_list WITH KEY connid = i_list-connid .

  CALL SCREEN 200 STARTING AT 10 5. "Details about passenger-seat matching

  IF sy-subrc = 0 AND i_column_id-fieldname = 'CONNID' .

  ENDIF .
ENDFORM .                    "handle_hotspot_click
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0200 OUTPUT. "PBO for 200
  PERFORM build_cat .
  PERFORM display_alv1.


ENDMODULE. " STATUS_0200 OUTPUT

*************************************************************************

FORM display_alv1.

  IF alv_grid1 IS INITIAL. "CHK IF GRID ALREADY EXISTS

    CREATE OBJECT custom_container "IF NOT CREATE ONE CUSTOM CONTAINER FOR IT !
    EXPORTING
* PARENT =
    container_name = 'CC_ALV1'
* 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 alv_grid1 "NOW CREATE A GRID
    EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
    i_parent = custom_container1
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* 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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    CALL METHOD alv_grid1->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE
    EXPORTING
    i_ready_for_input = 1.

    CALL METHOD alv_grid1->set_table_for_first_display "SET THE DISPLAY
    EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'STICKET'
* IS_VARIANT =
    i_save = 'A'
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = g_list[]
    it_fieldcatalog = pt_fieldcat1
* IT_SORT =
* IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    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.

  ELSE.


  ENDIF.


ENDFORM. " alv_display1
*&---------------------------------------------------------------------*
*& Form build_cat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_cat .

  DATA ls_fcat TYPE lvc_s_fcat .

  ls_fcat-fieldname = 'CONNID' .
  ls_fcat-inttype = 'C' .
  ls_fcat-outputlen = '9' .
  ls_fcat-coltext = 'CONNECTION ID' .
  ls_fcat-seltext = 'CONNECTION ID' .
  ls_fcat-col_pos = '2' .
  ls_fcat-hotspot = 'X' .

  APPEND ls_fcat TO pt_fieldcat1 .

  CLEAR ls_fcat .

  ls_fcat-fieldname = 'BOOKID' .
  ls_fcat-ref_table = 'STICKET' .
  ls_fcat-ref_field = 'BOOKID' .
* ls_fcat-outputlen = '9' .
  ls_fcat-col_pos = '1' .
* ls_fcat-coltext = 'Connection ID' .
* ls_fcat-seltext = 'Connection ID' .

  APPEND ls_fcat TO pt_fieldcat1 .

ENDFORM. " build_cat

8 REPLIES 8
Read only

Former Member
0 Likes
1,028

Hi Sachin,

The Event for hotspot was not registered properly. You should add the code SET HANDLER before displaying the ALV grid.

I have changed the code. It should work now.

Please reward helpful posts.

Regards

Wenceslaus.

**********************DATA DECLARATION-GLOBAL DATA FIELDS**************
DATA: alv_grid TYPE REF TO cl_gui_alv_grid, "for screen 1
custom_container TYPE REF TO cl_gui_custom_container,

alv_grid1 TYPE REF TO cl_gui_alv_grid, "for screen 2
custom_container1 TYPE REF TO cl_gui_custom_container,

pt_fieldcat TYPE lvc_t_fcat,
pt_fieldcat1 TYPE lvc_t_fcat,
ok_code LIKE sy-ucomm,
save_ok LIKE sy-ucomm,
layout1 TYPE lvc_s_layo.

**********************DATA DECLARATION-INTERNAL TABLE******************

DATA: BEGIN OF i_list OCCURS 0.
        INCLUDE STRUCTURE sflight.
DATA: END OF i_list.

DATA: BEGIN OF i_list1 OCCURS 0.
        INCLUDE STRUCTURE sflight.
DATA: END OF i_list1.

*********************DATA DECLARATION-INTERNAL TABLE******************

DATA: BEGIN OF g_list OCCURS 0.
        INCLUDE STRUCTURE sticket.
DATA: END OF g_list.

***********************EVENT HANDLER CLASS*[DEFINITION]****************

CLASS lcl_event_handler 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.

ENDCLASS. "lcl_event_handler DEFINITION

***********************EVENT HANDLER CLASS*[IMPLEMENTATION]*************
CLASS lcl_event_handler IMPLEMENTATION.

  METHOD handle_hotspot_click .
    PERFORM handle_hotspot_click USING e_row_id e_column_id es_row_no .
  ENDMETHOD . "handle_hotspot_click

ENDCLASS. "lcl_event_handler IMPLEMENTATION


****************CREATE AN INSTANCE OF THE CLASS************************
DATA: gr_event_handler TYPE REF TO lcl_event_handler .


*--Creating an instance for the event handler


***********************START-OF-SELECTION******************************

START-OF-SELECTION.

  CREATE OBJECT gr_event_handler .

  SELECT * FROM sflight INTO TABLE i_list.
  SELECT * FROM sticket INTO TABLE g_list.

  CALL SCREEN 0100.


END-OF-SELECTION.

*---------------------------------------------------------------------*
* MODULE display PBO
*---------------------------------------------------------------------*
*
*---------------------------------------------------------------------*
MODULE display_alv OUTPUT.

  SET PF-STATUS 'MAIN101'.
  SET TITLEBAR 'MAIN100'.
  PERFORM prepare_field_catalog .
  PERFORM display_alv.



ENDMODULE. "display_alv OUTPUT

*&--------------------------------------------------------------------*
*& Form display_alv
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM display_alv.

  IF alv_grid IS INITIAL. "CHK IF GRID ALREADY EXISTS
    CREATE OBJECT custom_container
      EXPORTING
*    PARENT                      =
        container_name              = 'CC_ALV'
        .


    CREATE OBJECT alv_grid
      EXPORTING
        i_parent          = custom_container
        .
    CALL METHOD alv_grid->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE
EXPORTING
i_ready_for_input = 1.

    SET HANDLER gr_event_handler->handle_hotspot_click FOR alv_grid .

    CALL METHOD alv_grid->set_table_for_first_display "SET THE DISPLAY
    EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'SFLIGHT'
* IS_VARIANT =
    i_save = 'A'
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = i_list[]
    it_fieldcatalog = pt_fieldcat
* IT_SORT =
* IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    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.

  ELSE.


  ENDIF.


ENDFORM. " alv_display
*&---------------------------------------------------------------------*
*& Module STATUS_0100 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*& Module USER_COMMAND_0100 INPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT. "FOR THE EXIT BACK AND UP FUNCTIONS


  save_ok = ok_code.
  CLEAR ok_code.
  CASE save_ok.
    WHEN 'EXIT'.
      PERFORM exit_program.
    WHEN 'BACK' .
      PERFORM exit_program.
    WHEN 'UP' .
      PERFORM exit_program.
    WHEN 'SWITCH'.
      PERFORM switch_edit_mode.

    WHEN OTHERS.
* do nothing
  ENDCASE.

*SET HANDLER gr_event_handler->handle_hotspot_click FOR alv_grid1 .

ENDMODULE. " USER_COMMAND_0100 INPUT

*---------------------------------------------------------------------*
* FORM EXIT_PROGRAM *
*---------------------------------------------------------------------*
FORM exit_program.
  LEAVE PROGRAM.
ENDFORM. "exit_program

*&--------------------------------------------------------------------*
*& Form switch_edit_mode
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM switch_edit_mode.
*§3.Use IS_READY_FOR_INPUT to fetch current substate of editable cells.
  IF alv_grid->is_ready_for_input( ) EQ 0.
*§4.Use SET_READY_FOR_INPUT to switch between the substates.
    CALL METHOD alv_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 1.
  ELSE.
    CALL METHOD alv_grid->set_ready_for_input
      EXPORTING
        i_ready_for_input = 0.
  ENDIF.
ENDFORM. " SWITCH_EDIT_MODE

*&--------------------------------------------------------------------*
*& Form prepare_field_catalog
*&--------------------------------------------------------------------*
* text
*---------------------------------------------------------------------*
FORM prepare_field_catalog .

  DATA ls_fcat TYPE lvc_s_fcat .
  ls_fcat-fieldname = 'CARRID' .
  ls_fcat-inttype = 'C' .
  ls_fcat-outputlen = '9' .
  ls_fcat-coltext = 'Carrier ID' .
  ls_fcat-seltext = 'Carrier ID' .
  ls_fcat-col_pos = '2' .


  APPEND ls_fcat TO pt_fieldcat .

  CLEAR ls_fcat .

  ls_fcat-fieldname = 'CONNID' .
  ls_fcat-ref_table = 'SFLIGHT' .
  ls_fcat-ref_field = 'CONNID' .
  ls_fcat-hotspot = 'X'.
* ls_fcat-outputlen = '9' .
  ls_fcat-col_pos = '1' .
* ls_fcat-coltext = 'Connection ID' .
* ls_fcat-seltext = 'Connection ID' .

  APPEND ls_fcat TO pt_fieldcat .
ENDFORM . "prepare_field_catalog
*&---------------------------------------------------------------------*
*& Form handle_hotspot_click
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* -->P_E_ROW_ID text
* -->P_E_COLUMN_ID text
* -->P_ES_ROW_NO text
*----------------------------------------------------------------------*
FORM handle_hotspot_click USING i_row_id TYPE lvc_s_row
i_column_id TYPE lvc_s_col
is_row_no TYPE lvc_s_roid.


  READ TABLE i_list INDEX is_row_no-row_id .
  READ TABLE g_list WITH KEY connid = i_list-connid .

  CALL SCREEN 200 STARTING AT 10 5. "Details about passenger-seat matching

  IF sy-subrc = 0 AND i_column_id-fieldname = 'CONNID' .

  ENDIF .
ENDFORM .                    "handle_hotspot_click
*&---------------------------------------------------------------------*
*& Module STATUS_0200 OUTPUT
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
MODULE status_0200 OUTPUT. "PBO for 200
  PERFORM build_cat .
  PERFORM display_alv1.


ENDMODULE. " STATUS_0200 OUTPUT

*************************************************************************

FORM display_alv1.

  IF alv_grid1 IS INITIAL. "CHK IF GRID ALREADY EXISTS

    CREATE OBJECT custom_container "IF NOT CREATE ONE CUSTOM CONTAINER FOR IT !
    EXPORTING
* PARENT =
    container_name = 'CC_ALV1'
* 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 alv_grid1 "NOW CREATE A GRID
    EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
    i_parent = custom_container1
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* 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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.

    CALL METHOD alv_grid1->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE
    EXPORTING
    i_ready_for_input = 1.

    CALL METHOD alv_grid1->set_table_for_first_display "SET THE DISPLAY
    EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'STICKET'
* IS_VARIANT =
    i_save = 'A'
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = g_list[]
    it_fieldcatalog = pt_fieldcat1
* IT_SORT =
* IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    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.

  ELSE.


  ENDIF.


ENDFORM. " alv_display1
*&---------------------------------------------------------------------*
*& Form build_cat
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
* --> p1 text
* <-- p2 text
*----------------------------------------------------------------------*
FORM build_cat .

  DATA ls_fcat TYPE lvc_s_fcat .

  ls_fcat-fieldname = 'CONNID' .
  ls_fcat-inttype = 'C' .
  ls_fcat-outputlen = '9' .
  ls_fcat-coltext = 'CONNECTION ID' .
  ls_fcat-seltext = 'CONNECTION ID' .
  ls_fcat-col_pos = '2' .
  ls_fcat-hotspot = 'X' .

  APPEND ls_fcat TO pt_fieldcat1 .

  CLEAR ls_fcat .

  ls_fcat-fieldname = 'BOOKID' .
  ls_fcat-ref_table = 'STICKET' .
  ls_fcat-ref_field = 'BOOKID' .
* ls_fcat-outputlen = '9' .
  ls_fcat-col_pos = '1' .
* ls_fcat-coltext = 'Connection ID' .
* ls_fcat-seltext = 'Connection ID' .

  APPEND ls_fcat TO pt_fieldcat1 .

ENDFORM. " build_cat

Read only

0 Likes
1,027

thanks Wenceslaus !

u were right i'm left with one more prob now that the hotspot is wrkin

but when i click on it it says :

"call screen (not modal) in modal dialog box not allowed

regards

sachin

Read only

0 Likes
1,027

Hi Sachin,

What is the screen type that you are using? See in the screen Attributes tab.

I have tried with "Modal Dialog Box" and it is working fine for me.

Regards

Wenceslaus

Read only

0 Likes
1,027

hi !

now that i've changed the screen its openin up but no data is being diplayed.

can u figure it out why??

thanks

sachin

Read only

0 Likes
1,027

Hi Sachin,

A small bug in the subroutine ALV_DISPLAY1, Change the line

CREATE OBJECT custom_container "IF NOT

to

<b>CREATE OBJECT custom_container1 "IF NOT </b>

It should be custom_container1. This should fix this.

Please reward helpful posts.

Regards

Wenceslaus


FORM display_alv1.
 
  IF alv_grid1 IS INITIAL. "CHK IF GRID ALREADY EXISTS
 
    CREATE OBJECT custom_container1 "IF NOT CREATE ONE CUSTOM CONTAINER FOR IT !
    EXPORTING
* PARENT =
    container_name = 'CC_ALV1'
* 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 alv_grid1 "NOW CREATE A GRID
    EXPORTING
* I_SHELLSTYLE = 0
* I_LIFETIME =
    i_parent = custom_container1
* I_APPL_EVENTS = space
* I_PARENTDBG =
* I_APPLOGPARENT =
* I_GRAPHICSPARENT =
* 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.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
 
    CALL METHOD alv_grid1->set_ready_for_input "INITIALLY SET IT AS NON-EDITABLE
    EXPORTING
    i_ready_for_input = 1.
 
    CALL METHOD alv_grid1->set_table_for_first_display "SET THE DISPLAY
    EXPORTING
* I_BUFFER_ACTIVE =
* I_BYPASSING_BUFFER =
* I_CONSISTENCY_CHECK =
* I_STRUCTURE_NAME = 'STICKET'
* IS_VARIANT =
    i_save = 'A'
* I_DEFAULT = 'X'
* IS_LAYOUT =
* IS_PRINT =
* IT_SPECIAL_GROUPS =
* IT_TOOLBAR_EXCLUDING =
* IT_HYPERLINK =
* IT_ALV_GRAPHICS =
* IT_EXCEPT_QINFO =
    CHANGING
    it_outtab = g_list[]
    it_fieldcatalog = pt_fieldcat1
* IT_SORT =
* IT_FILTER =
    EXCEPTIONS
    invalid_parameter_combination = 1
    program_error = 2
    too_many_lines = 3
    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.
 
  ELSE.
 
 
  ENDIF.
 
 
ENDFORM. " alv_display1

Read only

0 Likes
1,027

hi buddy!

thx a ton for all ur help that is now wrkin.

1 last ques is i've set a PF status to screen 200 "second screen and the F-keys i've set r not wrkin just displayed .i've implemented the functionalities in the code as u can see;

module USER_COMMAND_0200 input.

clear save_ok.

save_ok = ok_code.

CLEAR ok_code.

CASE save_ok.

WHEN 'ENTER'.

PERFORM exit_program.

WHEN 'CANCEL' .

PERFORM exit_program.

WHEN OTHERS.

  • do nothing

ENDCASE.

endmodule. " USER_COMMAND_0200 INPUT

FORM exit_program.

LEAVE PROGRAM.

ENDFORM. "exit_program

but its still nt wrkin

thanks

sachin

Read only

0 Likes
1,027

Hi Sachin,

You could set a GUI status at the PBO module of screen 200

SET PF-STATUS 'STAT'.

Your PAI module is ok. However I couldn't know how you have defined your screen elements. A little debugging should do good.

Regards

Wenceslaus

Read only

0 Likes
1,027

thanks wen, its done.