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

Do we write classes in abap seperately from the main program

Former Member
0 Likes
387

For instance following class is designed to capture the click of hotspot and double clicks from a screen layout. immediately I need it.Thanks everyone.

Where should I put such a code?

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 ,

*--Double-click control

handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column 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 .

*--Handle Double Click

METHOD handle_double_click .

PERFORM handle_double_click USING e_row e_column es_row_no .

ENDMETHOD .

ENDCLASS .

FORM CREATEOBJECT.

DATA gr_event_handler TYPE REF TO lcl_event_handler .

*--Creating an instance for the event handler

CREATE OBJECT gr_event_handler .

SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .

SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .

ENDFORM.

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 zbficheentry_list2 INDEX is_row_no-row_id .

IF sy-subrc = 0." AND i_column_id-fieldname = 'SEATSOCC'.

CALL SCREEN 200 . "Details about passenger-seat matching

ENDIF .

ENDFORM .

FORM handle_double_click USING i_row TYPE lvc_s_row

i_column TYPE lvc_s_col

is_row_no TYPE lvc_s_roid.

READ TABLE zbficheentry_list2 INDEX is_row_no-row_id .

IF sy-subrc = 0." AND i_column-fieldname = 'SEATSOCC' .

CALL SCREEN 120 . "Details about passenger-seat matching

ENDIF .

ENDFORM .

For instance following class is designed to capture the click of hotspot and double clicks from a screen layout. immediately I need it.Thanks everyone.

Where should I put such a code?

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 ,

*--Double-click control

handle_double_click

FOR EVENT double_click OF cl_gui_alv_grid

IMPORTING e_row e_column 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 .

*--Handle Double Click

METHOD handle_double_click .

PERFORM handle_double_click USING e_row e_column es_row_no .

ENDMETHOD .

ENDCLASS .

FORM CREATEOBJECT.

DATA gr_event_handler TYPE REF TO lcl_event_handler .

*--Creating an instance for the event handler

CREATE OBJECT gr_event_handler .

SET HANDLER gr_event_handler->handle_double_click FOR gr_alvgrid .

SET HANDLER gr_event_handler->handle_hotspot_click FOR gr_alvgrid .

ENDFORM.

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 zbficheentry_list2 INDEX is_row_no-row_id .

IF sy-subrc = 0." AND i_column_id-fieldname = 'SEATSOCC'.

CALL SCREEN 200 . "Details about passenger-seat matching

ENDIF .

ENDFORM .

FORM handle_double_click USING i_row TYPE lvc_s_row

i_column TYPE lvc_s_col

is_row_no TYPE lvc_s_roid.

READ TABLE zbficheentry_list2 INDEX is_row_no-row_id .

IF sy-subrc = 0." AND i_column-fieldname = 'SEATSOCC' .

CALL SCREEN 120 . "Details about passenger-seat matching

ENDIF .

ENDFORM .

2 REPLIES 2
Read only

oliver
Active Contributor
0 Likes
355

Hi Deniz,

I would put local classes into separate includes. Easy to exchange between different programs and all in one place.

Best regards,

ok

Read only

Former Member
0 Likes
355

Hi,

Check the link,

Regards,

Azaz Ali.