Working with events in a Global Class

...Previous

Now select the method.

And also copy the parameters of the event method. 

 

By pressing this copy event parameter we can get the parameters. 

 

Save and go back to the earlier screen..

Then double click on the method name.

Then provide the following logic for triggering the event. 

METHOD METHOD_EVENT .

*check the condition

IF S_LIFNR_LOW < 1000 AND S_LIFNR_HIGH > 2000.

   MESSAGE I000(0) WITH 'enter the values between 1000 and 2000'.

   RAISE EVENT ZEVENT_METHOD.

ENDIF.

*provide select statement

SELECT *

FROM LFA1

INTO TABLE IT_LFA1

WHERE LIFNR BETWEEN S_LIFNR_LOW AND S_LIFNR_HIGH.

*transfer the values to another internal table

IT_LFA11 = IT_LFA1.

ENDMETHOD. 

After that provide the logic in se38.

REPORT  ZCL_EVENT_OPERATION .

*provide data objects

DATA: LFA1 TYPE LFA1,

      OBJ TYPE REF TO ZCL_EVENT_OPERATION,

      IT_LFA1 TYPE Z_LFA1,

      IT_LFA11 TYPE Z_LFA1,

      WA_LFA1 TYPE LFA1.

*provide select statement

SELECT-OPTIONS: S_LIFNR FOR LFA1-LIFNR.

*provide create object

START-OF-SELECTION.

  CREATE OBJECT OBJ.

*call the method

  CALL METHOD OBJ->METHOD_EVENT

    EXPORTING

      S_LIFNR_LOW  = S_LIFNR-LOW

      S_LIFNR_HIGH = S_LIFNR-HIGH

      IT_LFA1      = IT_LFA1.

*provide attribute value

  IT_LFA11 = OBJ->IT_LFA11.

*display the data

  LOOP AT IT_LFA11 INTO WA_LFA1.

    WRITE:/ WA_LFA1-LIFNR,

            WA_LFA1-LAND1,

            WA_LFA1-NAME1,

            WA_LFA1-ORT01.

  ENDLOOP.

 Save it, check it, activate it and execute it.

Then the output is like this. 

 

If lifnr value is <1000 and >2000.

Then press execute it.

The output is like this. 

 

Then press enter.

The output is like this. 

Please send us your feedback/suggestions at webmaster@SAPTechnical.COM 

HomeContribute About Us Privacy Terms Of Use • Disclaimer • SafeCompanies: Advertise on SAPTechnical.COM | Post JobContact Us  

Graphic Design by Round the Bend Wizards

footer image footer image