<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Set handler Questions in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540331#M1072644</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks u are Great!.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Sep 2008 12:56:02 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-23T12:56:02Z</dc:date>
    <item>
      <title>Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540324#M1072637</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i try to follow this code and i miss something,&lt;/P&gt;&lt;P&gt;why after the commend :  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SET HANDLER: list-&amp;gt; fcode_handler,&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; see below&lt;/P&gt;&lt;P&gt;the go to the class status and not fcode handler ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;            &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT  zztest_events.
TYPE-POOLS: icon.
*****************************************************************
* Interface and Class declarations
*****************************************************************
INTERFACE i_vehicle.
  DATA     max_speed TYPE i.
  EVENTS speed_change EXPORTING value(new_speed) TYPE i.
  METHODS: drive,
           stop.
ENDINTERFACE.                    "I_VEHICLE
*----------------------------------------------------------------
CLASS c_ship DEFINITION.
  PUBLIC SECTION.
    METHODS constructor.
    INTERFACES i_vehicle.
  PRIVATE SECTION.
    ALIASES max FOR i_vehicle~max_speed.
    DATA ship_speed TYPE i.
ENDCLASS.                    "C_SHIP DEFINITION
*----------------------------------------------------------------
CLASS c_truck DEFINITION.
  PUBLIC SECTION.
    METHODS constructor.
    INTERFACES i_vehicle.
  PRIVATE SECTION.
    ALIASES max FOR i_vehicle~max_speed.
    DATA truck_speed TYPE i.
ENDCLASS.                    "C_TRUCK DEFINITION
*----------------------------------------------------------------
CLASS status DEFINITION.
  PUBLIC SECTION.
    CLASS-EVENTS button_clicked EXPORTING value(fcode) LIKE sy-ucomm.
    CLASS-METHODS: class_constructor,
                  user_action.
ENDCLASS.                    "STATUS DEFINITION
*----------------------------------------------------------------
CLASS c_list DEFINITION.
  PUBLIC SECTION.
    METHODS: fcode_handler FOR EVENT button_clicked OF status
                               IMPORTING fcode,
             list_change   FOR EVENT speed_change OF i_vehicle
                               IMPORTING new_speed,
             list_output.
  PRIVATE SECTION.
    DATA: id TYPE i,
          ref_ship  TYPE REF TO c_ship,
          ref_truck TYPE REF TO c_truck,
          BEGIN OF line,
            id TYPE i,
            flag,
            iref  TYPE REF TO i_vehicle,
            speed TYPE i,
          END OF line,
          list LIKE SORTED TABLE OF line WITH UNIQUE KEY id.
ENDCLASS.                    "C_LIST DEFINITION
*****************************************************************

*****************************************************************
* Implementations
*****************************************************************
CLASS c_ship IMPLEMENTATION.
  METHOD constructor.
    max = 30.
  ENDMETHOD.                    "CONSTRUCTOR
  METHOD i_vehicle~drive.
    CHECK ship_speed &amp;lt; max.
    ship_speed = ship_speed + 10.
    RAISE EVENT i_vehicle~speed_change
                EXPORTING new_speed = ship_speed.
  ENDMETHOD.                    "I_VEHICLE~DRIVE
  METHOD i_vehicle~stop.
    CHECK ship_speed &amp;gt; 0.
    ship_speed = 0.
    RAISE EVENT i_vehicle~speed_change
                EXPORTING new_speed = ship_speed.
  ENDMETHOD.                    "I_VEHICLE~STOP
ENDCLASS.                    "C_SHIP IMPLEMENTATION
*----------------------------------------------------------------
CLASS c_truck IMPLEMENTATION.
  METHOD constructor.
    max = 150.
  ENDMETHOD.                    "CONSTRUCTOR
  METHOD i_vehicle~drive.
    CHECK truck_speed &amp;lt; max.
    truck_speed = truck_speed + 50.
    RAISE EVENT i_vehicle~speed_change
                EXPORTING new_speed = truck_speed.
  ENDMETHOD.                    "I_VEHICLE~DRIVE
  METHOD i_vehicle~stop.
    CHECK truck_speed &amp;gt; 0.
    truck_speed = 0.
    RAISE EVENT i_vehicle~speed_change
                EXPORTING new_speed = truck_speed.
  ENDMETHOD.                    "I_VEHICLE~STOP
ENDCLASS.                    "C_TRUCK IMPLEMENTATION
*----------------------------------------------------------------
CLASS status IMPLEMENTATION.
  METHOD class_constructor.
    SET PF-STATUS 'VEHICLE'.
    WRITE 'Click a button!'.

  ENDMETHOD.                    "CLASS_CONSTRUCTOR
  METHOD user_action.
    RAISE EVENT button_clicked EXPORTING fcode = sy-ucomm.
  ENDMETHOD.                    "USER_ACTION
ENDCLASS.                    "STATUS IMPLEMENTATION
*----------------------------------------------------------------
CLASS c_list IMPLEMENTATION.
  METHOD fcode_handler .
    CLEAR line.
    REPLACE ALL OCCURRENCES OF  '/' in fcode with ''.
    CASE fcode.
      WHEN 'CREA_SHIP'.
        id = id + 1.
        CREATE OBJECT ref_ship.
        line-id = id.
        line-flag = 'C'.
        line-iref = ref_ship.
        APPEND line TO list.
      WHEN 'CREA_TRUCK'.
        id = id + 1.
        CREATE OBJECT ref_truck.
        line-id = id.
        line-flag = 'T'.
        line-iref = ref_truck.
        APPEND line TO list.
      WHEN 'DRIVE'.
        CHECK sy-lilli &amp;gt; 0.
        READ TABLE list INDEX sy-lilli INTO line.
        CALL METHOD line-iref-&amp;gt;drive.
      WHEN 'STOP'.
        LOOP AT list INTO line.
          CALL METHOD line-iref-&amp;gt;stop.
        ENDLOOP.
      WHEN 'CANCEL'.
        LEAVE PROGRAM.
    ENDCASE.
    CALL METHOD list_output.
  ENDMETHOD.                    "FCODE_HANDLER
  METHOD list_change .
    line-speed = new_speed.
    MODIFY TABLE list FROM line.
  ENDMETHOD.                    "LIST_CHANGE
  METHOD list_output.
    sy-lsind = 0.
    SET TITLEBAR 'TIT'.
    LOOP AT list INTO line.
      IF line-flag = 'C'.
        WRITE / icon_ws_ship AS ICON.
      ELSEIF line-flag = 'T'.
        WRITE / icon_ws_truck AS ICON.
      ENDIF.
      WRITE: 'Speed = ', line-speed.
    ENDLOOP.
  ENDMETHOD.                    "LIST_OUTPUT
ENDCLASS.                    "C_LIST IMPLEMENTATION
*****************************************************************

*****************************************************************
* Global data of program
*****************************************************************
DATA list TYPE REF TO c_list.
*****************************************************************
* Program Events
*****************************************************************
START-OF-SELECTION.
  CREATE OBJECT list.
  SET HANDLER: list-&amp;gt;fcode_handler,
              list-&amp;gt;list_change FOR ALL INSTANCES.
*----------------------------------------------------------------
AT USER-COMMAND.
  CALL METHOD status=&amp;gt;user_action.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Sep 2008 15:10:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540324#M1072637</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-21T15:10:04Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540325#M1072638</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ricardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I assume you are mixing up &lt;STRONG&gt;application toolbar buttons&lt;/STRONG&gt; (defined with the &lt;STRONG&gt;GUI-status&lt;/STRONG&gt; ) and buttons on the ALV grid.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When you click an application button then you trigger PAI of the screen.&lt;/P&gt;&lt;P&gt;When you click a button on the ALV grid (i.e. the cells of one column are displayed as buttons) this triggers event BUTTON_CLICKED which will then be handled by FCODE_HANDLER.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 21 Sep 2008 18:06:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540325#M1072638</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-09-21T18:06:24Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540326#M1072639</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i think u miss understood me ,&lt;/P&gt;&lt;P&gt;i wont to ask why in the program the code :&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;SET HANDLER: list-&amp;gt; fcode_handler,&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;go to class status and not fcode handler like u call to method(e.g. if i have method fcode_handler in class list)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 09:16:44 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540326#M1072639</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-22T09:16:44Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540327#M1072640</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ricardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is meant by "class status"?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 10:40:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540327#M1072640</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-09-22T10:40:47Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540328#M1072641</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sorry if i dont explain my self well,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i want to learn about events in oo and i copy this code and follow in the debugger ,&lt;/P&gt;&lt;P&gt;what i dont understand is that when i push f5 on commend:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;list-&amp;gt; fcode_handler&lt;/P&gt;&lt;P&gt;the debugger jump to class status and not to fcode_handler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 11:55:14 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540328#M1072641</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-22T11:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540329#M1072642</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Ricardo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In Class STATUS you had  CLASS-EVENTS button_clicked (mentioned static Event) which would be the &lt;/P&gt;&lt;P&gt;first one to  get triggered first. As CLASS METHOD or the CLASS EVENTS are the one which gets &lt;/P&gt;&lt;P&gt;triggered first. So the control is pointed to STATUS class.. Try commenting that class and you will end up&lt;/P&gt;&lt;P&gt;triggering the c_list where the fcode_handler.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope this would help you.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Good luck&lt;/P&gt;&lt;P&gt;Narin&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 22 Sep 2008 13:05:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540329#M1072642</guid>
      <dc:creator>narin_nandivada3</dc:creator>
      <dc:date>2008-09-22T13:05:02Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540330#M1072643</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Ricardo&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have to excuse for not studying your coding carefully enough. I assume it is a sample report from the ABAP Objects book (by Horst Keller).&lt;/P&gt;&lt;P&gt;To be honest I believe this sample report will confuse you more than it will help you to understand event handling in ABAP-OO.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;All ok-codes (like CREA_SHIP, DRIVE, etc.) trigger the list-processing event AT USER-COMMAND. Here the static  method&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;AT USER-COMMAND.
  CALL METHOD status=&amp;gt;user_action.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;is called.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Within USER_ACTION the class-event BUTTON_CLICKED is triggered:&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD user_action.
    RAISE EVENT button_clicked EXPORTING fcode = sy-ucomm.
  ENDMETHOD.                    "USER_ACTION&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This static event is handled by the instance method FCODE_HANDLER of class C_LIST.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now let us assume the ok-code = 'DRIVE' has been executed. Within FCODE_HANDLER the corresponding action is executed:&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD fcode_handler .
    CLEAR line.
    REPLACE ALL OCCURRENCES OF  '/' IN fcode WITH ''.
    CASE fcode.
      WHEN 'CREA_SHIP'.
        ...
      WHEN 'DRIVE'.
        CHECK sy-lilli &amp;gt; 0.
        READ TABLE list INDEX sy-lilli INTO line.
        CALL METHOD line-iref-&amp;gt;drive.
      WHEN 'STOP'.
      ...
    ENDCASE.
    CALL METHOD list_output.
  ENDMETHOD.                    "FCODE_HANDLER&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ok-code = 'DRIVE' eventually causes that the DRIVE method of instance LINE-IREF is called.&lt;/P&gt;&lt;P&gt;The instance "knows" whether it is a truck or a ship and calls the corresponding method, i.e. i_vehicle~drive:&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD i_vehicle~drive.
    CHECK ship_speed &amp;lt; max.
    ship_speed = ship_speed + 10.
    RAISE EVENT i_vehicle~speed_change
                EXPORTING new_speed = ship_speed.  " 'true' event raising / handling
  ENDMETHOD.                    "I_VEHICLE~DRIVE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now within the DRIVE method I see for the first time the "normal" event raising / handling that I am used to. The method has increased the speed thereby raising event SPEED_CHANGE.&lt;/P&gt;&lt;P&gt;Is there anybody "interested" in this event (i.e. do we have a listener for it)?&lt;/P&gt;&lt;P&gt;Answer: Yes, the C_LIST class needs to handle this event because it must change the list output.&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;METHOD list_change .
    line-speed = new_speed.
    MODIFY TABLE list FROM line.
  ENDMETHOD.                    "LIST_CHANGE&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In order to study "simple" examples of ALV grid event handling you may search the SDN for my sample reports (all of which begin with ZUS_SDN_...). In contrast to the BCALV_... sample reports I believe my reports are easier to understand.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;  Uwe&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Sep 2008 02:33:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540330#M1072643</guid>
      <dc:creator>uwe_schieferstein</dc:creator>
      <dc:date>2008-09-23T02:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Set handler Questions</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540331#M1072644</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Uwe,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks u are Great!.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best Regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Sep 2008 12:56:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/set-handler-questions/m-p/4540331#M1072644</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-23T12:56:02Z</dc:date>
    </item>
  </channel>
</rss>

