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

System Variable to capture triggered events.

Former Member
0 Likes
1,114

Hi Experts,

Is there any system variable to catch the triggered event Like Initialisation, Start of Selection etc.

I have a form which can be called in different events. And i want to display different msgs based on the based on the Event in which the form is called.

The code for this display msg will be written inside the Form.

Could you please advice on how to capture the triggered event.

1 ACCEPTED SOLUTION
Read only

Pawan_Kesari
Active Contributor
0 Likes
919

Add a additional paramater in form for event. And while calling pass the event name from where its being called.

CONSTANTS : BEGIN OF event ,
               init TYPE char01 VALUE 'A' ,
               strt TYPE char01 VALUE 'B' ,
               ends TYPE char01 VALUE 'C' ,
               topf TYPE char01 VALUE 'D' ,
            END OF event .

INITIALIZATION.

  PERFORM add_please USING 1 1 event-init .

START-OF-SELECTION .

  PERFORM add_please USING 2 2 event-strt .

END-OF-SELECTION .
  PERFORM add_please USING 3 4 event-ends .

TOP-OF-PAGE .

  PERFORM add_please USING 4 4 event-topf .

*&---------------------------------------------------------------------*
*&      Form  ADD_PLEASE
*&---------------------------------------------------------------------*
FORM add_please USING lv_a       TYPE i
                      lv_b       TYPE i
                      from_event TYPE char01 .

  DATA :lv_sum TYPE i .
  lv_sum = lv_a + lv_b .
  CASE from_event.
    WHEN event-init .
      WRITE : / 'Initialization' , lv_sum .
    WHEN event-strt .
      WRITE : / 'Start of Selection' , lv_sum .
    WHEN event-ends .
      WRITE : / 'End of Selection' , lv_sum .
    WHEN event-topf .
      WRITE : / 'Top of Page' , lv_sum .
  ENDCASE .

ENDFORM.                    "ADD_PLEASE

Hi Experts,

Is there any system variable to catch the triggered event Like Initialisation, Start of Selection etc.

I have a form which can be called in different events. And i want to display different msgs based on the based on the Event in which the form is called.

The code for this display msg will be written inside the Form.

Could you please advice on how to capture the triggered event.

4 REPLIES 4
Read only

Former Member
0 Likes
919

Why do you want to know the Events, when you know yourself that in which event you are calling your subroutine.

You can hardCode your message.

Read only

0 Likes
919

Hi,

I would not like to harcode teh events in my prg.

However i would like to dynamically allocate the event triggered into teh variable in the Form.

Or say its a Function Module. It can be used in any prg and in any event. Then in that case to dynamically allocate the event in which this is called wht can be a probable way.

Read only

Pawan_Kesari
Active Contributor
0 Likes
920

Add a additional paramater in form for event. And while calling pass the event name from where its being called.

CONSTANTS : BEGIN OF event ,
               init TYPE char01 VALUE 'A' ,
               strt TYPE char01 VALUE 'B' ,
               ends TYPE char01 VALUE 'C' ,
               topf TYPE char01 VALUE 'D' ,
            END OF event .

INITIALIZATION.

  PERFORM add_please USING 1 1 event-init .

START-OF-SELECTION .

  PERFORM add_please USING 2 2 event-strt .

END-OF-SELECTION .
  PERFORM add_please USING 3 4 event-ends .

TOP-OF-PAGE .

  PERFORM add_please USING 4 4 event-topf .

*&---------------------------------------------------------------------*
*&      Form  ADD_PLEASE
*&---------------------------------------------------------------------*
FORM add_please USING lv_a       TYPE i
                      lv_b       TYPE i
                      from_event TYPE char01 .

  DATA :lv_sum TYPE i .
  lv_sum = lv_a + lv_b .
  CASE from_event.
    WHEN event-init .
      WRITE : / 'Initialization' , lv_sum .
    WHEN event-strt .
      WRITE : / 'Start of Selection' , lv_sum .
    WHEN event-ends .
      WRITE : / 'End of Selection' , lv_sum .
    WHEN event-topf .
      WRITE : / 'Top of Page' , lv_sum .
  ENDCASE .

ENDFORM.                    "ADD_PLEASE

Read only

0 Likes
919

Hi,

Thanks for the code. However my requirement is this function module or form can be called inside any prg. Hence i will not have access to code in the calling program.

Anyways, I just found out there is a FM SYSTEM_CALLSTACK that returns the event in which this form of function module is called.

Thanks anyways.