Skip to Content
author's profile photo Former Member
Former Member

handle events in global class

Hi all,

I am working on handling events in global classes.

but my event is not triggererd,i m not able to find where it's going wrong.

Below is my code.

Global Class:ZCL_TEST_EVENT

events :EXCEEDEDRANGE

methods:CHECKRANGE,DISPLAYVENDOR.

Checkrange is event handler for exceededrange.

below is the code for methods.

method checkrange.

write:/ 'Vendor not within the range'(001).

exit.

endmethod.

method displayvendor.

DATA : exlfa1 TYPE lfa1.

IF imlifnr NOT BETWEEN 1000 AND 2000.

RAISE EVENT exceededrange.

ENDIF.

SELECT SINGLE * FROM lfa1

INTO exlfa1

WHERE lifnr = imlifnr

.

IF sy-subrc = 0.

WRITE : / exlfa1-lifnr,exlfa1-name1.

ELSE.

WRITE : / 'No vendor found'(002).

ENDIF.

endmethod.

-


below is the report I developed.

REPORT ztest_113.

parameters :plifnr type lfa1-lifnr obligatory.

data : obj type ref to ZCL_TEST_EVENT.

START-OF-SELECTION.

CREATE OBJECT obj.

CALL METHOD obj->displayvendor

EXPORTING

imlifnr = plifnr

.

Please help

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Best Answer
    Posted on Feb 08, 2010 at 02:09 PM

    Yes, you do need to write the SET HANDLER statement. As per your current design, you can set the event handler in your method CONSTRUCTOR. Like:

    method constructor.
      SET HANDLER me->CHECKRANGE FOR me.
    endmethod.
    

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Feb 08, 2010 at 12:05 PM

    Do I need to write SET HANDLER statement anywhere or should it work automatically to trigger event?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.