‎2007 Feb 16 10:45 AM
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
‎2007 Feb 16 12:57 PM
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
‎2007 Feb 16 11:04 AM
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
‎2007 Feb 16 12:57 PM
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
‎2007 Feb 16 12:59 PM
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.
‎2007 Feb 16 1:03 PM