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

**********Trigger an Event***********

Former Member
0 Likes
1,356

Hi,

Can anyuone please tell me how to trigger an event ? Kindly send me a small code .

regards,

Vijay

********REPLIES TO BE DEFINETELY REWARDED********

9 REPLIES 9
Read only

Former Member
0 Likes
930

Are you referring to events in ALV's or.. anything else? Can you please be specific?

Regards,

Sankar.

Read only

Former Member
0 Likes
930

Hello,

Check these Demo Programs:

demo_program_initialization

demo_program_start_of_selectio.

demo_program_end_of_selection

demo_program_stop

demo_program_exit_1

Vasanth

Read only

Former Member
0 Likes
930

hi,

report ztest.

SELECTION-SCREEN BEGIN OF BLOCK block1 WITH FRAME TITLE text-001.
PARAMETERS: p_emp   LIKE rlgrap-filename,
            p_empt  LIKE rlgrap-filename,
            p_cont LIKE rlgrap-filename.
SELECTION-SCREEN END OF BLOCK block1.


*at selection-screen
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_emp.

  REFRESH: it_tabemp.
  CALL METHOD cl_gui_frontend_services=>file_open_dialog
    EXPORTING
      window_title      = 'Select File'
      default_filename  = '*.xls'
      initial_directory = 'C:'
      multiselection    = ' '  "No multiple selection
    CHANGING
      file_table        = it_tabemp
      rc                = gd_subrcemp.

  LOOP AT it_tabemp INTO p_emp.

in the above code when you click the button on p_emp parameter

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_emp. gets triggered

Regards,

Santosh

Read only

LeonardoAraujo
SAP Mentor
SAP Mentor
0 Likes
930

Check Transaction SM64, it calls the function module 'BP_EVENT_RAISE'.

 
     call function 'BP_EVENT_RAISE'
        exporting
          eventid                = btch1250-eventid
          eventparm              = btch1250-parameter
        exceptions
          bad_eventid            = 1
          eventid_does_not_exist = 2
          eventid_missing        = 3
          raise_failed           = 4
          others                 = 99.

      case sy-subrc.
        when 0.
          message s250 with btch1250-eventid.
        when 1.
          message e042 with btch1250-eventid.
        when 2.
          message e042 with btch1250-eventid.
        when 3.
          message e038.
        when 4.
          message e249 with btch1250-eventid.
      endcase.

Good luck,

Leonardo De Araujo

Read only

0 Likes
930

Assuming you are talking about job events... if it is class related it is another story.

Leo

Read only

0 Likes
930

Hi,

Thanks a lot for your reply. I have a small clarification.Please reply.

I am calling the event from a BADI. The object is ZBUS20001 and the event I want to trigger is ZTESTCREATE.

Please tell me how to write the code. Kindly help.

Thanks a lot once again for your reply.

Regards,

Vijay

***I Shall definetely reward you*****

Read only

0 Likes
930

Call this way.

CALL FUNCTION 'SWE_EVENT_CREATE'

EXPORTING

OBJTYPE = 'ZBUS20001'

OBJKEY = <Object key >

EVENT = 'ZTESTCREATE'

TABLES

EVENT_CONTAINER = IT_CONTAINER "Fill the it_container using macros

EXCEPTIONS

OBJTYPE_NOT_FOUND = 1

OTHERS = 2.

REgards,

Ravi

Read only

Former Member
0 Likes
930

Hi,

Normally we trigger the Events using <b>RAISE EVENT</b> ..

<b>Declaring Events</b>

You declare events in the declaration part of a class or in an interface. To declare instance events, use the following statement:

EVENTS evt EXPORTING... VALUE(e1 e2 ...) TYPE type [OPTIONAL]..

To declare static events, use the following statement:

CLASS-EVENTS evt...

Both statements have the same syntax.

When you declare an event, you can use the EXPORTINGaddition to specify parameters that are passed to the event handler. The parameters are always passed by value. Instance events always contain the implicit parameter SENDER, which has the type of a reference to the type or the interface in which the event is declared.

<b>Triggering Events</b>

An instance event in a class can be triggered by any instance method in the class. Static events can be triggered by any method. However, static methods can only trigger static events. To trigger an event in a method, use the following statement:

RAISE EVENT evt EXPORTING e1 = f1 e2 = f2 ...

For each formal parameter e1 that is not defined as optional, you must pass a corresponding actual parameter f1 in the EXPORTING addition. The self-reference me is automatically passed to the implicit parameter sender.

Regards

Sudheer

Read only

Former Member
0 Likes
930

Hi,

INIT_EVENT_RAISE for Triggering the INIT event

BP_EVENT_RAISE for Trigger Background Event

RFC_RAISE_ERROR for RFC Event.

In the above function modules pass OBJTYPE = 'ZBUS20001' and EVENT = 'ZTESTCREATE'

Regards

Sudheer