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

Problem in Events (Program)

Former Member
0 Likes
559

Hi,

Pls look at the code below.

I have created a pushbutton and written a triggering event for that.

but then in output if i press the button the event is not triggered and

so i dont get output at all.

REPORT zexample.

*button to be clicked after which the event should get triggered

SELECTION-SCREEN: PUSHBUTTON /10(20) button USER-COMMAND 'BUT1'.

INITIALIZATION.

button = 'LISTS'.

----


  • CLASS cl_names DEFINITION

----


*

----


CLASS cl_names DEFINITION. " declare the events in this method

PUBLIC SECTION.

CLASS-EVENTS: get_event EXPORTING value(fcode) TYPE sy-ucomm.

CLASS-METHODS: user_action.

ENDCLASS. "cl_names DEFINITION

----


  • CLASS fcode_handler_class DEFINITION

----


*

----


CLASS fcode_handler_class DEFINITION. " definition for handler events

PUBLIC SECTION.

METHODS: fcode_handler FOR EVENT get_event

OF cl_names IMPORTING fcode.

ENDCLASS. "fcode_handler_class DEFINITION

----


  • CLASS cl_names IMPLEMENTATION

----


*

----


CLASS cl_names IMPLEMENTATION. "Raise the event

METHOD user_action.

RAISE EVENT get_event EXPORTING fcode = sy-ucomm.

ENDMETHOD. "USER_ACTION

ENDCLASS. "cl_names IMPLEMENTATION

----


  • CLASS fcode_handler_class IMPLEMENTATION

----


*

----


CLASS fcode_handler_class IMPLEMENTATION. "implement the handler event

METHOD fcode_handler.

CASE fcode.

WHEN 'BUT1'.

WRITE: 'Hello Program !!'.

ENDCASE.

ENDMETHOD. "fcode_handler

ENDCLASS. "fcode_handler_class IMPLEMENTATION

AT USER-COMMAND.

CALL METHOD: cl_names=>user_action.

pls give me a solution.

Deepak

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
535

Hi Ravi,

Its not working.

Actually u commented the pushbutton (which is on the top)

but i need that, bcos only by clicking that button i need the event to be

triggered.

Deepak

4 REPLIES 4
Read only

Former Member
0 Likes
535

Just copy paste:

REPORT zexample.

*button to be clicked after which the event should get triggered

*SELECTION-SCREEN: PUSHBUTTON /10(20) button USER-COMMAND BUT1.

INITIALIZATION.

*button = 'LISTS'.

----


  • CLASS cl_names DEFINITION

----


*

----


CLASS cl_names DEFINITION. " declare the events in this method

PUBLIC SECTION.

class-EVENTS: get_event EXPORTING value(fcode) TYPE sy-ucomm.

CLASS-METHODS: user_action.

ENDCLASS. "cl_names DEFINITION

----


  • CLASS fcode_handler_class DEFINITION

----


*

----


CLASS fcode_handler_class DEFINITION. " definition for handler events

PUBLIC SECTION.

METHODS: fcode_handler FOR EVENT get_event

OF cl_names IMPORTING fcode.

ENDCLASS. "fcode_handler_class DEFINITION

----


  • CLASS cl_names IMPLEMENTATION

----


*

----


CLASS cl_names IMPLEMENTATION. "Raise the event

METHOD user_action.

RAISE EVENT get_event EXPORTING fcode = sy-ucomm.

ENDMETHOD. "USER_ACTION

ENDCLASS. "cl_names IMPLEMENTATION

----


  • CLASS fcode_handler_class IMPLEMENTATION

----


*

----


CLASS fcode_handler_class IMPLEMENTATION. "implement the handler event

METHOD fcode_handler.

*CASE fcode.

*WHEN 'BUT1'.

WRITE: 'Hello Program !!'.

*ENDCASE.

ENDMETHOD. "fcode_handler

ENDCLASS. "fcode_handler_class IMPLEMENTATION

DATA: h1 TYPE REF TO fcode_handler_class.

start-of-selection.

*at selection-screen.

CREATE OBJECT h1.

SET HANDLER h1->fcode_handler." FOR ALL INSTANCES.

CALL METHOD: cl_names=>user_action.

This works for me.

Regards,

Ravi

Read only

Former Member
0 Likes
536

Hi Ravi,

Its not working.

Actually u commented the pushbutton (which is on the top)

but i need that, bcos only by clicking that button i need the event to be

triggered.

Deepak

Read only

0 Likes
535

Hi Deepak,

try this REPORT zexample.

*button to be clicked after which the event should get triggered

SELECTION-SCREEN: PUSHBUTTON /10(20) button USER-COMMAND BUT1.

INITIALIZATION.

button = 'LISTS'.

----


  • CLASS cl_names DEFINITION

----


*

----


CLASS cl_names DEFINITION. " declare the events in this method

PUBLIC SECTION.

class-EVENTS: get_event EXPORTING value(fcode) TYPE sy-ucomm.

CLASS-METHODS: user_action.

ENDCLASS. "cl_names DEFINITION

----


  • CLASS fcode_handler_class DEFINITION

----


*

----


CLASS fcode_handler_class DEFINITION. " definition for handler events

PUBLIC SECTION.

METHODS: fcode_handler FOR EVENT get_event

OF cl_names IMPORTING fcode.

ENDCLASS. "fcode_handler_class DEFINITION

----


  • CLASS cl_names IMPLEMENTATION

----


*

----


CLASS cl_names IMPLEMENTATION. "Raise the event

METHOD user_action.

RAISE EVENT get_event EXPORTING fcode = sy-ucomm.

ENDMETHOD. "USER_ACTION

ENDCLASS. "cl_names IMPLEMENTATION

----


  • CLASS fcode_handler_class IMPLEMENTATION

----


*

----


CLASS fcode_handler_class IMPLEMENTATION. "implement the handler event

METHOD fcode_handler.

CASE fcode.

WHEN 'BUT1'.

*WRITE: 'Hello Program !!'.

message i001(zz) with 'Test'.

ENDCASE.

ENDMETHOD. "fcode_handler

ENDCLASS. "fcode_handler_class IMPLEMENTATION

DATA: h1 TYPE REF TO fcode_handler_class.

*start-of-selection.

at selection-screen.

CREATE OBJECT h1.

SET HANDLER h1->fcode_handler." FOR ALL INSTANCES.

CALL METHOD: cl_names=>user_action.

Read only

0 Likes
535

Thanks a lot ravi this program is working