Event handling in global class (abap object)

Hello friends
I have 1 problem regarding events in abap object... how to handel an event in global class in se24 .
Regards
Reema jain.
Message was edited by:
        Reema Jain

Hello Reema
The following sample report shows how to handle event in principle (see the § marks)..
The following sample report show customer data ("Header"; KNB1) in the first ALV list and sales areas ("Detail"; KNVV) for the selected customer (event double-click) in the second ALV list.
*& Report  ZUS_SDN_TWO_ALV_GRIDS
REPORT  zus_sdn_two_alv_grids.
DATA:
  gd_okcode        TYPE ui_func,
  go_docking       TYPE REF TO cl_gui_docking_container,
  go_splitter      TYPE REF TO cl_gui_splitter_container,
  go_cell_top      TYPE REF TO cl_gui_container,
  go_cell_bottom   TYPE REF TO cl_gui_container,
  go_grid1         TYPE REF TO cl_gui_alv_grid,
  go_grid2         TYPE REF TO cl_gui_alv_grid,
  gs_layout        TYPE lvc_s_layo.
DATA:
  gt_knb1          TYPE STANDARD TABLE OF knb1,
  gt_knvv          TYPE STANDARD TABLE OF knvv.
"§1. Define and implement event handler method
"     (Here: implemented as static methods of a local class)
*       CLASS lcl_eventhandler DEFINITION
CLASS lcl_eventhandler DEFINITION.
  PUBLIC SECTION.
    CLASS-METHODS:
      handle_double_click FOR EVENT double_click OF cl_gui_alv_grid
        IMPORTING
          e_row
          e_column
          es_row_no
          sender.
ENDCLASS.                    "lcl_eventhandler DEFINITION
*       CLASS lcl_eventhandler IMPLEMENTATION
CLASS lcl_eventhandler IMPLEMENTATION.
  METHOD handle_double_click.
*   define local data
    DATA:
      ls_knb1      TYPE knb1.
    CHECK ( sender = go_grid1 ).
    READ TABLE gt_knb1 INTO ls_knb1 INDEX e_row-index.
    CHECK ( ls_knb1-kunnr IS NOT INITIAL ).
    CALL METHOD go_grid1->set_current_cell_via_id
      EXPORTING
*        IS_ROW_ID    =
*        IS_COLUMN_ID =
        is_row_no    = es_row_no.
*   Triggers PAI of the dynpro with the specified ok-code
    CALL METHOD cl_gui_cfw=>set_new_ok_code( 'DETAIL' ).
  ENDMETHOD.                    "handle_double_click
ENDCLASS.                    "lcl_eventhandler IMPLEMENTATION
START-OF-SELECTION.
  SELECT        * FROM  knb1 INTO TABLE gt_knb1
         WHERE  bukrs  = '1000'.
* Create docking container
  CREATE OBJECT go_docking
    EXPORTING
      parent                      = cl_gui_container=>screen0
      ratio                       = 90
    EXCEPTIONS
      OTHERS                      = 6.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Create splitter container
  CREATE OBJECT go_splitter
    EXPORTING
      parent            = go_docking
      rows              = 2
      columns           = 1
*      NO_AUTODEF_PROGID_DYNNR =
*      NAME              =
    EXCEPTIONS
      cntl_error        = 1
      cntl_system_error = 2
      OTHERS            = 3.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Get cell container
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 1
      column    = 1
    RECEIVING
      container = go_cell_top.
  CALL METHOD go_splitter->get_container
    EXPORTING
      row       = 2
      column    = 1
    RECEIVING
      container = go_cell_bottom.
* Create ALV grids
  CREATE OBJECT go_grid1
    EXPORTING
      i_parent          = go_cell_top
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
"§2. Set event handler (after creating the ALV instance)
  SET HANDLER: lcl_eventhandler=>handle_double_click FOR go_grid1.  " Or:
" SET HANDLER: lcl_eventhandler=>handle_double_click FOR all instances.
  CREATE OBJECT go_grid2
    EXPORTING
      i_parent          = go_cell_bottom
    EXCEPTIONS
      OTHERS            = 5.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Display data
  gs_layout-grid_title = 'Customers'.
  CALL METHOD go_grid1->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNB1'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_knb1
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
  gs_layout-grid_title = 'Customers Details (Sales Areas)'.
  CALL METHOD go_grid2->set_table_for_first_display
    EXPORTING
      i_structure_name = 'KNVV'
      is_layout        = gs_layout
    CHANGING
      it_outtab        = gt_knvv  " empty !!!
    EXCEPTIONS
      OTHERS           = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* Link the docking container to the target dynpro
  CALL METHOD go_docking->link
    EXPORTING
      repid                       = syst-repid
      dynnr                       = '0100'
*      CONTAINER                   =
    EXCEPTIONS
      OTHERS                      = 4.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
* NOTE: dynpro does not contain any elements
  CALL SCREEN '0100'.
* Flow logic of dynpro (does not contain any dynpro elements):
*PROCESS BEFORE OUTPUT.
*  MODULE STATUS_0100.
*PROCESS AFTER INPUT.
*  MODULE USER_COMMAND_0100.
END-OF-SELECTION.
*&      Module  STATUS_0100  OUTPUT
*       text
MODULE status_0100 OUTPUT.
  SET PF-STATUS 'STATUS_0100'.  " contains push button "DETAIL"
*  SET TITLEBAR 'xxx'.
* Refresh display of detail ALV list
  CALL METHOD go_grid2->refresh_table_display
*    EXPORTING
*      IS_STABLE      =
*      I_SOFT_REFRESH =
    EXCEPTIONS
      OTHERS         = 2.
  IF sy-subrc <> 0.
*   MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*              WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
  ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&      Module  USER_COMMAND_0100  INPUT
*       text
MODULE user_command_0100 INPUT.
  CASE gd_okcode.
    WHEN 'BACK' OR
         'END'  OR
         'CANC'.
      SET SCREEN 0. LEAVE SCREEN.
*   User has pushed button "Display Details"
    WHEN 'DETAIL'.
      PERFORM entry_show_details.
    WHEN OTHERS.
  ENDCASE.
  CLEAR: gd_okcode.
ENDMODULE.                 " USER_COMMAND_0100  INPUT
*&      Form  ENTRY_SHOW_DETAILS
*       text
*  -->  p1        text
*  <--  p2        text
FORM entry_show_details .
* define local data
  DATA:
    ld_row      TYPE i,
    ls_knb1     TYPE knb1.
  CALL METHOD go_grid1->get_current_cell
    IMPORTING
      e_row = ld_row.
  READ TABLE gt_knb1 INTO ls_knb1 INDEX ld_row.
  CHECK ( syst-subrc = 0 ).
  SELECT        * FROM  knvv INTO TABLE gt_knvv
         WHERE  kunnr  = ls_knb1-kunnr.
ENDFORM.                    " ENTRY_SHOW_DETAILS
Regards
Uwe

Similar Messages

  • Event handling and inner classes

    Hi everyone,
    When assigning an actionlistener object to a swing component, is making the encapsulating component implement actionlistener better performance-wise than using inner classes? I ask this because my application is pretty slow to start-up, and I'm using lots of inner classes.
    I don't want to go ahead and change the event-handling unless I'm sure it will do any good, because the time restriction is too tight for wasting. Does using addActionListener(this) just pass a reference to itself or is an object generated for each call?
    Thanks in advance,
    Richard

    Passing this only passes a reference. But you won't get a big improvement over inner classes. (If you use one listener object instance and pass that instance to the event sources. Do you?)
    Kurta

  • Event handling in seperate class

    hello... i have a gui w/ a series of combo boxes, text fields, etc. (call this the GUI file)
    upon pressing a button, i need to run a series of event handling that will use info from many of these components
    i would like to create a separate java file for the button event handling, but need this file to have access to many componets in the GUI file - does anyone know a nice way to do this?

    i'm not quite sure how to do that... in my GUI class,
    I construct the actuall gui within the constructor..
    then i have a simple driver that creates an instance
    of class GUI and calls the constructor... how can I
    pass a reference of the GUI to the handler in that
    scenario??it would be better if you post your code. Some people like me can't just imagine.

  • Event handling without new class

    I'm new to Java, so please bear with me.
    I'm working with a file management software called Intralink which allows automating tasks by recording keystrokes or writing instructions in Java. A typical recorded script would look like:
    // Start Macro Recording
    import com.ptc.intralink.client.script.*;*
    *import com.ptc.intralink.script.*;
    public class newpn2 extends ILIntralinkScript {
    ILIntralinkScriptInterface IL = (ILIntralinkScriptInterface)getScriptInterface();
    private void run0 () throws Exception {
    IL.deselectAll( "WSPI" ); // recorded step: 1
    IL.select( "WSPI", "New_Generic/template_sm.prt" ); // recorded step: 2
    } // End of run0
    public void run () throws Exception {
    run0 (); // recorded
    } // End of function
    } // End Macro RecordingI don't know why but the run0() function has to be called from the run() function. (to clarify that, the run0() can be called from anywhere but all the statements beginning with "IL." are ignored unless it was called from the run() function) I'm trying to write something that uses a dialog box created with JFrame, contains a few combo boxes, and has a JButton to then start the run0() function. This fails because the run0() ends up being called from the actionPerformed class, similar to below.
    public void actionPerformed(ActionEvent e)
    try
    run0();
    catch (Exception ex)
    System.out.println("Error..." + ex);
    }I've tried doing it with an anonymous inner class but the result is the same. Is there any way to detect a button click and act on it within the same function that creates the button?

    Vmtr wrote:
    I understand what you're suggesting but this would still require me to call the run0() function from within the listener class and (for whatever reason) the "IL." commands are ignored if they are not in a run0() function called directly from a run() function. I'm assuming that this is a quirk built in by the makers of Intralink and I am just trying to find a way around it.Something is happening behind the scenes, something that I don't see evidenced by your current code. Since Intralink is not your class, I guess it is impossible to create a true SSCCE. When I created an SSCCE based on your code, there were no problems:
    //import com.ptc.intralink.client.script.*;
    //import com.ptc.intralink.script.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import javax.swing.border.*;
    //import java.util.*;
    //import java.text.*;
    //import java.io.*;
    //import java.sql.*;
    //import com.ptc.intralink.ila.*;
    public class forum extends ILIntralinkScript
      ILIntralinkScriptInterface IL = (ILIntralinkScriptInterface) getScriptInterface();
      private void run0() throws Exception
        JOptionPane.showMessageDialog(null, "In the run0 function!");
        IL.openWindow("Workspace", null, null); // recorded step: 1
        IL.selectTree("FTLOCALDB", "Local Database"); // recorded step: 2
      } // End of run0
      public void run() //throws Exception
        JButton button1 = new JButton("Done");
        button1.setPreferredSize(new java.awt.Dimension(310, 18));
        JFrame f = new JFrame("New Part Number");
        // add this so it exits nice:
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setSize(360, 300);
        f.setResizable(false);
        Container content = f.getContentPane();
        content.add(button1);
        button1.addActionListener(new ActionListener()
          public void actionPerformed(ActionEvent ee)
            try
              run0();
            catch (Exception ex)
              System.out.println("Error..." + ex);
              ex.printStackTrace();
        f.setVisible(true);
      // get this all to run
      public static void main(String[] args)
        SwingUtilities.invokeLater(new forum());
    // dummy classes to allow for compilation
    abstract class ILIntralinkScript implements Runnable
      public ILIntralinkScriptInterface getScriptInterface()
        return new ILIntralinkScriptInterface();
    class ILIntralinkScriptInterface
      public void openWindow(String string, Object object, Object object2)
        JOptionPane.showMessageDialog(null, "in method openWindow(" + string + ", " + object + ", "
            + object2 + ")");
      public void selectTree(String string, String string2)
        JOptionPane.showMessageDialog(null, "in method selectTree(" + string + " ," + string2 + ")");
    }

  • Event handling across unrelated classes

    I have a widget type of package that holds some classes that are basically JPanels with appropriate components on them. Specifically, JCheckBox, JComboBox, that kind of thing. These JPanels are used by multiple applications that describe some graphics, so one JPanel allows a user to set properties on Lines, one JPanel allows a user to set properties on Areas, that kind of thing. Several of these are put together in a JTabbedPane, which is another class in this package (this thing can be customized for what is needed).
    The applications themselves use what they need for their particular thing. Here's the question. I designed this thinking that I can have these pre-created panels of what I need, and add the listeners in the application. For example, something like this:
    tabbedPanePanel.getLinePanel().getColorCombo().addItemListener(new ItemListener......);
    When I do this as described in the application, when the colorCombo box is changed, it doesn't trip the event (I was in debug tracing through). Obviously my design is flawed, but I don't know how to change it to make it work. There are two things I need help with improvement.
    First, how can I use these re-usable widgets, when the actions are different depending on the application, and the items that the actions would affect are specific to the applications?
    Second, what would a better design paradigm be for better encapsulation, and performance for these actions (item listeners and such) and the widgets themselves?
    Thank you,
    Valeri

    Think in terms of gathering data instead of actions. That is, each panel gets some user input. Put all the user input in some sort of data object, and provide a method that returns the data object. E.g. Imagine a color panel that lets the user enter R, G, and B:
    public class ColorPanel extends JPanel {
             // TextFields....
            public Color getColor() {
                     // returns a color based on the values in the text fields
    }It is important not to put any OK or Cancel buttons in the panels. You save the OK and Cancel buttons for another main panel that is application specific. When the OK button is pressed, you collect the data and apply it.

  • Event-Handling  Between 2 Classes

    Trying to learn where did I make a mistake!
    Here is a very simple sample code:
    2 classes (each has 1 (awt-style)Panel & 1 (awt-style) Button. By clicking on one of the buttons how do I change the Background (color) of the Panel in the other class?
    //***********Sample Code **********************
    import java.awt.*;
    import java.awt.event.*;
    //=====================================================
    public class App extends Frame
    Panel_1 ap1; //ap1 --> additional panel #1
    Panel_2 ap2;
    public App()
    setLayout(null);
    setBounds(100,100,300,200);
    setBackground(Color.yellow);
    //re: Panel_1
    //=============
    ap1=new Panel_1();
    add(ap1);
    //re: Panel_2
    //===========
    ap2=new Panel_2();
    add(ap2);
    public static void main(String[] args)
    App app=new App();
    app.setVisible(true);
    //==============================================================
    class Panel_1 extends Panel implements ActionListener
    Panel_2 p2;
    Button ap1b=new Button();
    Panel_1()
    setBounds(50,120,100,50);
    setBackground(Color.green);
    ap1b.setBackground(Color.red);
    ap1b.addActionListener(p2);
    add(ap1b);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==p2.ap2b)
    System.out.println("Test Panel 1");
    //=================================
    class Panel_2 extends Panel implements ActionListener
    Panel_1 p1;
    Button ap2b=new Button();
    Panel_2()
    setBounds(50,30,200,50);
    setBackground(Color.orange);
    ap2b.setBackground(Color.red);
    ap2b.addActionListener(p1);
    add(ap2b);
    public void actionPerformed(ActionEvent ae)
    if (ae.getSource()==p1.ap1b)
    System.out.println("Test Panel 2");
    }

    There are several ways to do this. Without going into all of them, let's narrow them down by thinking in terms of design. Why should the panels know anything about each other? Each panel is its own deal. The component which has both of the panels should be the one listening to the buttons.
    Really there is no reason to have separate classes for the panels, but if you must, then write a listener as an inner class of the frame class, then pass that listener to the constructor of each panel as you instantiate it. Then you can have the listener work with both panels directly.
    Drake

  • Set Context From Event Handler in Web Dynpro ABAP

    Hi,
    I am passing some parameters when navigating from one view to another. Now I would like to set the context of the second view. How can I achieve that in Web Dynpro ABAP?
    Thanks.
    / Elvez

    I figured out ...
    element->set_attribute(
           exporting name = `NAME`      
                     value = value ).

  • Problem in event handling using oo abap code

    Hi,
    My requirement is i need to disply 3 blocks in ALV format.I have done that.Now my problem is if i double click on aufnr of the first block, it should call the transaction code. I have written the code in oo abap but i have used function modules for ALV.Now my doubt is 'How to write an event  once the user double click on the particular field of the first block, it should call the tcode " using object oriented code.
    How to populate the heading for each block using oo abap code.
    Thanks & Regards
    Anus

    hi.....
    Use Double_click event handler method of class cl_gui_alv_grid of first block....
    if not solved .
    Send me Your program lines ...........
    Best Regards
    Prabhakar

  • 2 Displayable objects, 1 event handler object

    Hi there,
    I'm working on an application using J2ME and the MIDP profile. I was wondering, is it possible to use 1 event handler object for 2 Displayable objects? Lets say I have a list on one screen and a form on another, can I use 1 event handler object to handle the events for these two elements? I am implementing my event handler in another class, and I am trying to use the same event handler for all my screens, but it does not seem to be functioning. Any hints?
    Also, is it advisable to implement the event handler in a separate class for a J2ME application? Does it really make any difference design-wise and efficiency-wise?
    I would appreciate the insight..
    Thanks

    ...I would start with adding debug messages in commandAction and in nextScreen:
    // debug messages are within System.out.println, do not forget to remove after fix
      public void commandAction(Command s, Displayable x) {
        System.out.println("command: [" + s.getLabel() + "] screen: [" + x.getTitle() + "]" );
        // ...here starts your code...
      public void nextScreen(int x) {
        System.out.println("index: [" + x + "]);
        System.out.println("screen[0] is not null: [" + (screen[0] != null) + "]" );
        System.out.println("screen[0] title: [" + (screen[0].getTitle()) + "]" );
        System.out.println("screen[1] is not null: [" + (screen[1] != null) + "]" );
        System.out.println("screen[1] title: [" + (screen[1].getTitle()) + "]" );
        // ...here starts your code...
    {code}
    then retry run and check messages shown in WTK console...                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Abap Objects doubts.

    Hi Experts.
    Plz give me some details for the following questions.
    1. what is abstract class.
    2. give me some example program using inheritance.
    3. Some sample programs using events.
    4. Narrow casting & wide casting.. And describe the use of it.
    5. How to declare internal table in ABAP OOPS.
    6. What is the use of table type.?
    7. What is instance.?
    8. Explain friend class.
    Thank in advance.
    Points will be given for the answers.
    regards,
    J.Joe

    HI
    <b>1. what is abstract class.</b>
    Abstract classes are normally used as an incomplete blueprint for concrete (that is, non-abstract) subclasses, for example to define a uniform interface.
    Classes with at least one abstract method are themselves abstract.
    Static methods and constructors cannot be abstract.
    You can specify the class of the instance to be created explicitly: CREATE OBJECT <RefToAbstractClass> TYPE <NonAbstractSubclassName>.
    Abstarct classes themselves can’t be instantiated ( althrough their subclasses can)
    Reference to abstract classes can refer to instance of subclass
    Abstract (instance) methods are difined in the class , but not implemented
    They must be redefined in subclasses
    CLASS LC1 DEFINAITION ABSTARCT
    PUBLIC SECTION
    METHODS ESTIMATE ABSTARCT IMPORTING…
    ENDCLASS.
    <b>2. give me some example program using inheritance.</b>
    The following simple example shows the principle of inheritance within ABAP Objects. It is based on the Simple Introduction to Classes. A new class counter_ten inherits from the existing class counter.
    REPORT demo_inheritance.
    CLASS counter DEFINITION.
      PUBLIC SECTION.
        METHODS: set IMPORTING value(set_value) TYPE i,
                 increment,
                 get EXPORTING value(get_value) TYPE i.
       PROTECTED SECTION .
        DATA count TYPE i.
    ENDCLASS.
    CLASS counter IMPLEMENTATION.
      METHOD set.
        count = set_value.
      ENDMETHOD.
      METHOD increment.
        ADD 1 TO count.
      ENDMETHOD.
      METHOD get.
        get_value = count.
      ENDMETHOD.
    ENDCLASS.
    CLASS counter_ten DEFINITION INHERITING FROM counter.
      PUBLIC SECTION.
        METHODS increment REDEFINITION .
        DATA count_ten.
    ENDCLASS.
    CLASS counter_ten IMPLEMENTATION.
      METHOD increment.
        DATA modulo TYPE I.
         CALL METHOD super->increment .
        write / count.
        modulo = count mod 10.
        IF modulo = 0.
          count_ten = count_ten + 1.
          write count_ten.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    DATA: count TYPE REF TO counter,
          number TYPE i VALUE 5.
    START-OF-SELECTION.
       CREATE OBJECT count TYPE counter_ten .
      CALL METHOD count->set EXPORTING set_value = number.
      DO 20 TIMES.
        CALL METHOD count->increment.
      ENDDO.
    The class COUNTER_TEN is derived from COUNTER. It redefines the method INCREMENT. To do this, you must change the visibility of the COUNT attribute from PRIVATE to PROTECTED. The redefined method calls the obscured method of the superclass using the pseudoreference SUPER->. The redefined method is a specialization of the inherited method.
    The example instantiates the subclass. The reference variable pointing to it has the type of the superclass. When the INCREMENT method is called using the superclass reference, the system executes the redefined method from the subclass.
    <b>3. Some sample programs using events.</b>
    Events in ABAP Objects - Example
    The following example shows how to declare, call, and handle events in ABAP Objects.
    Overview
    This object works with the interactive list displayed below. Each user interaction triggers an event in ABAP Objects. The list and its data is created in the class C_LIST. There is a class STATUS for processing user actions. It triggers an event BUTTON_CLICKED in the AT USER-COMMAND event. The event is handled in the class C_LIST. It contains an object of the class C_SHIP or C_TRUCK for each line of the list. Both of these classes implement the interface I_VEHICLE. Whenever the speed of one of these objects changes, the event SPEED_CHANGE is triggered. The class C_LIST reacts to this and updates the list.
    Constraints
    The ABAP statements used for list processing are not yet fully available in ABAP Objects. However, to produce a simple test output, you can use the following statements:
    WRITE [AT] /<offset>(<length>) <f>
    ULINE
    SKIP
    NEW-LINE
    Note: The behavior of formatting and interactive list functions in their current state are not guaranteed. Incompatible changes could occur in a future release.
    Declarations
    This example is implemented using local interfaces and classes. Below are the declarations of the interfaces and classes:
    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.
    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.
    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.
    CLASS STATUS DEFINITION.
      PUBLIC SECTION.
       CLASS-EVENTS BUTTON_CLICKED EXPORTING VALUE(FCODE) LIKE SY-UCOMM.
      CLASS-METHODS: CLASS_CONSTRUCTOR,
                    USER_ACTION.
    ENDCLASS.
    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.
    The following events are declared in the example:
    The instance event SPEED_CHANGE in the interface I_VEHICLE
    The static event BUTTON_CLICKED in the class STATUS.
    The class C_LIST contains event handler methods for both events.
    Note that the class STATUS does not have any attributes, and therefore only works with static methods and events.
    Implementations
    Below are the implementations of the methods of the above classes:
    Implementations
    CLASS C_SHIP IMPLEMENTATION.
      METHOD CONSTRUCTOR.
        MAX = 30.
      ENDMETHOD.
      METHOD I_VEHICLE~DRIVE.
        CHECK SHIP_SPEED < MAX.
        SHIP_SPEED = SHIP_SPEED + 10.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = SHIP_SPEED.
      ENDMETHOD.
      METHOD I_VEHICLE~STOP.
        CHECK SHIP_SPEED > 0.
        SHIP_SPEED = 0.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = SHIP_SPEED.
      ENDMETHOD.
    ENDCLASS.
    CLASS C_TRUCK IMPLEMENTATION.
      METHOD CONSTRUCTOR.
        MAX = 150.
      ENDMETHOD.
      METHOD I_VEHICLE~DRIVE.
        CHECK TRUCK_SPEED < MAX.
        TRUCK_SPEED = TRUCK_SPEED + 50.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = TRUCK_SPEED.
      ENDMETHOD.
      METHOD I_VEHICLE~STOP.
        CHECK TRUCK_SPEED > 0.
        TRUCK_SPEED = 0.
        RAISE EVENT I_VEHICLE~SPEED_CHANGE
                    EXPORTING NEW_SPEED = TRUCK_SPEED.
      ENDMETHOD.
    ENDCLASS.
    CLASS STATUS IMPLEMENTATION.
      METHOD CLASS_CONSTRUCTOR.
        SET PF-STATUS 'VEHICLE'.
        WRITE 'Click a button!'.
      ENDMETHOD.
      METHOD USER_ACTION.
        RAISE EVENT BUTTON_CLICKED EXPORTING FCODE = SY-UCOMM.
      ENDMETHOD.
    ENDCLASS.
    CLASS C_LIST IMPLEMENTATION.
      METHOD FCODE_HANDLER .
        CLEAR LINE.
        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 > 0.
            READ TABLE LIST INDEX SY-LILLI INTO LINE.
            CALL METHOD LINE-IREF->DRIVE.
          WHEN 'STOP'.
            LOOP AT LIST INTO LINE.
              CALL METHOD LINE-IREF->STOP.
            ENDLOOP.
          WHEN 'CANCEL'.
            LEAVE PROGRAM.
        ENDCASE.
        CALL METHOD LIST_OUTPUT.
      ENDMETHOD.
      METHOD LIST_CHANGE .
        LINE-SPEED = NEW_SPEED.
        MODIFY TABLE LIST FROM LINE.
      ENDMETHOD.
      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.
    ENDCLASS.
    The static method USER_ACTION of the class STATUS triggers the static event BUTTON_CLICKED. The instance methods I_VEHICLEDRIVE and I_VEHICLESTOP trigger the instance event I_VEHICLE~SPEED_CHANGE in the classes C_SHIP and C_TRUCK.
    Using the Classes in a Program
    The following program uses the above classes:
    REPORT OO_EVENTS_DEMO NO STANDARD PAGE HEADING.
    Global data of program
    DATA LIST TYPE REF TO C_LIST.
    Program events
    START-OF-SELECTION.
      CREATE OBJECT LIST.
      SET HANDLER: LIST->FCODE_HANDLER,
                  LIST->LIST_CHANGE FOR ALL INSTANCES.
    AT USER-COMMAND.
      CALL METHOD STATUS=>USER_ACTION.
    The program creates an object of the class C_LIST and registers the event handler method FCODE_HANDLER of the object for the class event BUTTON_CLICKED, and the event handler method LIST_CHANGE for the event SPEED_CHANGE of all instances that implement the interface I_VEHICLE.
    <b>4. Narrow casting & wide casting.. And describe the use of it.</b>
    <b>Narrowing Cast</b>
    The assignment of a subclass instance to a reference variable of the type "reference to superclass" is described as a narrowing cast, because you are switching from a more detailed view to a one with less detail.
    Description up-cast is also used.
    <b>use</b>
    A user who is not interested in the finer points of cars, trucks, and busses (but only, for example, in the fuel consumption and tank gauge) does not need to know about them. This user only wants and needs to work with (references to) the lcl_vehicle class. However, in order to allow the user to work with cars, busses, or trucks, you generally need a narrowing cast.
    <b>Widening cast</b>
    The widening cast logically represents the opposite of the narrowing cast. The widening cast cannot be checked statically, only at runtime. The Cast Operator ?= (or the equivalent MOVE ... ?TO … ) must be used to make this visible.
    It changes from a less detailed view to one with more detail.
    <b>use</b>
    The client, the car rental company  wants to execute a function for specific vehicles form the list (vehicle_list).  For example, the client wants to ascertain the truck with the largest cargo capacity.  However, not all vehicles are in the trucks list, it also includes references to cars and busses.
    <b>5. How to declare internal table in ABAP OOPS.</b>
    BEGIN OF LINE,
              ID TYPE I,
              FLAG,
              IREF  TYPE REF TO I_VEHICLE,
              SPEED TYPE I,
            END OF LINE,
    <b>6. What is the use of table type.?</b>
    Please check the SAP help , as all these things are provided in detail in it .
    In case you find it difficult to find it or search for it here is the link
    http://help.sap.com/saphelp_nw04/helpdata/en/90/8d7304b1af11d194f600a0c929b3c3/frameset.htm
    <b>7. What is instance.?</b>
    Instance methods are called using CALL METHOD <reference>-><instance_method>.
    Static methods (also referred to as class methods) are called using CALL METHOD <classname>=><class_method>.
    If you are calling a static method from within the class, you can omit the class name.
    You access instance attributes using <instance>-><instance_attribute>
    <b>8. Explain friend class.</b>
    In rare cases, classes have to work together so closely that they need access to their protected and private components. To avoid making these components available to all users, there is the concept of friendship between classes.
    To do this you use the FRIENDS additions to the CLASS statement, in which all classes and interfaces that are to be provided friendship are listed
    In principle, providing friendship is one-sided: A class providing friendship is not automatically a friend of its friends. If a class providing friendship wants to access the non-public components of a friend, this friend has to explicitly provide friendship to it.
    Classes that inherit from friends and interfaces that contain a friend as a component interface also become friends. However, providing friendship, unlike the attribute of being a friend, is not inherited. A friend of a superclass is therefore not automatically a friend of its subclasses.
    <b>Reward if usefull</b>

  • Event handler method

    Hi all,
    I want to know the significance of creating event handler method in Class builder.
    and how it can be used at the time of event trigger.( Is it called automatically or programmer need to call it explicitly in the program.)
    Thanks,
    Sushant singh

    Hi Sushant,
    1. In ABAP Objects, triggering and handling an event means that certain methods act as triggers and trigger events, to which other methods - the handlers - react. This means that the handler methods are executed when the event occurs.
    2.To trigger an event, a class must
      Declare the event in its declaration part
      Trigger the event in one of its methods
    3.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]..
    4. 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 ...
    5. Events are handled using special methods. To handle an event, a method must
          be defined as an event handler method for that event
          be registered at runtime for the event.
    Declaring Event Handler Methods
    Any class can contain event handler methods for events from other classes. You can, of course, also define event handler methods in the same class as the event itself. To declare an event handler method, use the following statement:
    METHODS meth FOR EVENT evt OF cif IMPORTING e1 e2 ...
    6. Registering Event Handler Methods
    To allow an event handler method to react to an event, you must determine at runtime the trigger to which it is to react. You can do this with the following statement:
    SET HANDLER h1 h2 ... [FOR]...
    It links a list of handler methods with corresponding trigger methods. There are four different types of event.
    7. Timing of Event Handling
    After the RAISE EVENTstatement, all registered handler methods are executed before the next statement is processed (synchronous event handling). If a handler method itself triggers events, its handler methods are executed before the original handler method continues. To avoid the possibility of endless recursion, events may currently only be nested 64 deep.
    Handler methods are executed in the order in which they were registered. Since event handlers are registered dynamically, you should not assume that they will be processed in a particular order. Instead, you should program as though all event handlers will be executed simultaneously.
    Reward if useful.

  • ALV Tree Report without using ABAP Objects

    Hi all,
    I want to know the name of a function module to create ALV Tree in SE38 as a report. I am required to create this ALV Tree Report without using ABAP OBJECTS. Can u pls help me as early as possible.

    Hi
    see this link
    http://www.sapdev.co.uk/reporting/alv/alvtree.htm
    *& Report  ZBCALV_TREE
    REPORT  ZBCALV_TREE.
    class cl_gui_column_tree definition load.
    class cl_gui_cfw definition load.
    data tree1  type ref to cl_gui_alv_tree.
    data mr_toolbar type ref to cl_gui_toolbar.
    include <icon>.
    include bcalv_toolbar_event_receiver.
    include bcalv_tree_event_receiver.
    data: toolbar_event_receiver type ref to lcl_toolbar_event_receiver.
    data: gt_VBAK  type VBAK occurs 0,      "Output-Table
          gt_fieldcatalog type lvc_t_fcat, "Fieldcatalog
          ok_code like sy-ucomm.           "OK-Code
    start-of-selection.
    end-of-selection.
      call screen 100.
    *&      Module  STATUS_0100  OUTPUT
          text
    module STATUS_0100 output.
      SET PF-STATUS 'MAIN'.
    if tree1 is initial.
        perform Zinit_tree.
      endif.
      call method cl_gui_cfw=>flush.
    endmodule.                 " STATUS_0100  OUTPUT
    *&      Form  Zinit_tree
          text
    -->  p1        text
    <--  p2        text
    form Zinit_tree .
    perform Zbuild_fieldcatalog.
    create container for alv-tree
    data: l_tree_container_name(30) type c,
            l_custom_container type ref to cl_gui_custom_container.
      l_tree_container_name = 'TREE1'.
    if sy-batch is initial.
        create object l_custom_container
          exporting
                container_name = l_tree_container_name
          exceptions
                cntl_error                  = 1
                cntl_system_error           = 2
                create_error                = 3
                lifetime_error              = 4
                lifetime_dynpro_dynpro_link = 5.
        if sy-subrc <> 0.
          message x208(00) with 'ERROR'.                        "#EC NOTEXT
        endif.
      endif.
    create tree control
      create object tree1
        exporting
            parent              = l_custom_container
            node_selection_mode = cl_gui_column_tree=>node_sel_mode_single
            item_selection      = 'X'
            no_html_header      = ''
            no_toolbar          = ''
        exceptions
            cntl_error                   = 1
            cntl_system_error            = 2
            create_error                 = 3
            lifetime_error               = 4
            illegal_node_selection_mode  = 5
            failed                       = 6
            illegal_column_name          = 7.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    create Hierarchy-header
      data l_hierarchy_header type treev_hhdr.
      perform zbuild_hierarchy_header changing l_hierarchy_header.
    create info-table for html-header
      data: lt_list_commentary type slis_t_listheader,
            l_logo             type sdydo_value.
      perform Zbuild_comment using
                     lt_list_commentary
                     l_logo.
    repid for saving variants
      data: ls_variant type disvariant.
      ls_variant-report = sy-repid.
    create emty tree-control
      call method tree1->set_table_for_first_display
        exporting
          is_hierarchy_header = l_hierarchy_header
          it_list_commentary  = lt_list_commentary
          i_logo              = l_logo
          i_background_id     = 'ALV_BACKGROUND'
          i_save              = 'A'
          is_variant          = ls_variant
        changing
          it_outtab           = gt_VBAK "table must be emty !!
          it_fieldcatalog     = gt_fieldcatalog.
    create hierarchy
      perform Zcreate_hierarchy.
    add own functioncodes to the toolbar
      perform zchange_toolbar.
    register events
      perform zregister_events.
    endform.                    " Zinit_tree
    *&      Form  Zbuild_fieldcatalog
          text
    -->  p1        text
    <--  p2        text
    form Zbuild_fieldcatalog .
    get fieldcatalog
      call function 'LVC_FIELDCATALOG_MERGE'
        exporting
          i_structure_name = 'VBAK'
        changing
          ct_fieldcat      = gt_fieldcatalog.
      sort gt_fieldcatalog by scrtext_l.
    change fieldcatalog
      data: ls_fieldcatalog type lvc_s_fcat.
      loop at gt_fieldcatalog into ls_fieldcatalog.
        case ls_fieldcatalog-fieldname.
          when 'AUART' .
            ls_fieldcatalog-no_out = 'X'.
            ls_fieldcatalog-key    = ''.
        endcase.
        modify gt_fieldcatalog from ls_fieldcatalog.
      endloop.
    endform.                    " Zbuild_fieldcatalog
    *&      Form  zbuild_hierarchy_header
          text
         <--P_L_HIERARCHY_HEADER  text
    form zbuild_hierarchy_header changing
                                   p_hierarchy_header type treev_hhdr.
      p_hierarchy_header-heading = 'Hierarchy Header'.          "#EC NOTEXT
      p_hierarchy_header-tooltip =
                             'This is the Hierarchy Header !'.  "#EC NOTEXT
      p_hierarchy_header-width = 30.
      p_hierarchy_header-width_pix = ''.
    endform.                    " zbuild_hierarchy_header
    *&      Form  Zbuild_comment
          text
         -->P_LT_LIST_COMMENTARY  text
         -->P_L_LOGO  text
    form Zbuild_comment   using
                           pt_list_commentary type slis_t_listheader
                           p_logo             type sdydo_value.
    data: ls_line type slis_listheader.
    LIST HEADING LINE: TYPE H
      clear ls_line.
      ls_line-typ  = 'H'.
    LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'ALV-tree-demo: flight-overview'.          "#EC NOTEXT
      append ls_line to pt_list_commentary.
    STATUS LINE: TYPE S
      clear ls_line.
      ls_line-typ  = 'S'.
      ls_line-key  = 'valid until'.                             "#EC NOTEXT
      ls_line-info = 'January 29 1999'.                         "#EC NOTEXT
      append ls_line to pt_list_commentary.
      ls_line-key  = 'time'.
      ls_line-info = '2.00 pm'.                                 "#EC NOTEXT
      append ls_line to pt_list_commentary.
    ACTION LINE: TYPE A
      clear ls_line.
      ls_line-typ  = 'A'.
    LS_LINE-KEY:  NOT USED FOR THIS TYPE
      ls_line-info = 'actual data'.                             "#EC NOTEXT
      append ls_line to pt_list_commentary.
      p_logo = 'ENJOYSAP_LOGO'.
    endform.                    " Zbuild_comment
    *&      Form  Zcreate_hierarchy
          text
    -->  p1        text
    <--  p2        text
    form Zcreate_hierarchy .
    data: ls_vbak type vbak,
          lt_vbak  type vbak occurs 0.
    get data
      select * from vbak into table lt_vbak
                            up to 200 rows .                "#EC CI_NOWHERE
      sort lt_vbak by AUART.
    add data to tree
      data: l_AUART_key type lvc_nkey.
    loop at lt_vbak into ls_vbak.
        on change of ls_vbak-AUART.
          perform Zadd_AUART_line using   ls_vbak
                                  changing l_AUART_key.
        endon.
      endloop.
    calculate totals
      call method tree1->update_calculations.
    this method must be called to send the data to the frontend
      call method tree1->frontend_update.
    endform.                    " Zcreate_hierarchy
    *&      Form  Zadd_AUART_line
          text
         -->P_LS_vbak  text
         -->P_0379   text
         <--P_L_AUART_KEY  text
    form Zadd_AUART_line  using    p_ls_vbak type vbak
                                   p_relat_key type lvc_nkey
                         changing  p_node_key type lvc_nkey.
      data: l_node_text type lvc_value,
            ls_vbak type vbak.
    set item-layout
      data: lt_item_layout type lvc_t_layi,
            ls_item_layout type lvc_s_layi.
      ls_item_layout-t_image = '@3P@'.
      ls_item_layout-fieldname = tree1->c_hierarchy_column_name.
      ls_item_layout-style   =
                            cl_gui_column_tree=>style_intensifd_critical.
      append ls_item_layout to lt_item_layout.
    add node
      l_node_text =  p_ls_vbak-AUART.
      data: ls_node type lvc_s_layn.
      ls_node-n_image   = space.
      ls_node-exp_image = space.
      call method tree1->add_node
        exporting
          i_relat_node_key = p_relat_key
          i_relationship   = cl_gui_column_tree=>relat_last_child
          i_node_text      = l_node_text
          is_outtab_line   = ls_vbak
          is_node_layout   = ls_node
          it_item_layout   = lt_item_layout
        importing
          e_new_node_key   = p_node_key .
    endform.                    " Zadd_AUART_line
    *&      Form  zchange_toolbar
          text
    -->  p1        text
    <--  p2        text
    form zchange_toolbar .
    get toolbar control
      call method tree1->get_toolbar_object
        importing
          er_toolbar = mr_toolbar.
      check not mr_toolbar is initial.
    add seperator to toolbar
      call method mr_toolbar->add_button
        exporting
          fcode     = ''
          icon      = ''
          butn_type = cntb_btype_sep
          text      = ''
          quickinfo = 'This is a Seperator'.                    "#EC NOTEXT
    add Standard Button to toolbar (for Delete Subtree)
      call method mr_toolbar->add_button
        exporting
          fcode     = 'DELETE'
          icon      = '@18@'
          butn_type = cntb_btype_button
          text      = ''
          quickinfo = 'Delete subtree'.                         "#EC NOTEXT
    add Dropdown Button to toolbar (for Insert Line)
      call method mr_toolbar->add_button
        exporting
          fcode     = 'INSERT_LC'
          icon      = '@17@'
          butn_type = cntb_btype_dropdown
          text      = ''
          quickinfo = 'Insert Line'.                            "#EC NOTEXT
    set event-handler for toolbar-control
      create object toolbar_event_receiver.
      set handler toolbar_event_receiver->on_function_selected
                                                          for mr_toolbar.
      set handler toolbar_event_receiver->on_toolbar_dropdown
                                                          for mr_toolbar.
    endform.                    " zchange_toolbar
    *&      Form  zregister_events
          text
    -->  p1        text
    <--  p2        text
    form zregister_events .
    define the events which will be passed to the backend
      data: lt_events type cntl_simple_events,
              l_event type cntl_simple_event.
    define the events which will be passed to the backend
      l_event-eventid = cl_gui_column_tree=>eventid_expand_no_children.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_checkbox_change.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_context_men_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_node_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_context_menu_req.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_header_click.
      append l_event to lt_events.
      l_event-eventid = cl_gui_column_tree=>eventid_item_keypress.
      append l_event to lt_events.
      call method tree1->set_registered_events
        exporting
          events                    = lt_events
        exceptions
          cntl_error                = 1
          cntl_system_error         = 2
          illegal_event_combination = 3.
      if sy-subrc <> 0.
        message x208(00) with 'ERROR'.                          "#EC NOTEXT
      endif.
    set Handler
      data: l_event_receiver type ref to lcl_tree_event_receiver.
      create object l_event_receiver.
      set handler l_event_receiver->handle_node_ctmenu_request
                                                            for tree1.
      set handler l_event_receiver->handle_node_ctmenu_selected
                                                            for tree1.
      set handler l_event_receiver->handle_item_ctmenu_request
                                                            for tree1.
      set handler l_event_receiver->handle_item_ctmenu_selected
                                                            for tree1.
    endform.                    " zregister_events
    *&      Module  USER_COMMAND_0100  INPUT
          text
    module USER_COMMAND_0100 input.
    ok_code  = sy-ucomm.
    clear sy-ucomm.
    case ok_code.
        when 'EXIT' or 'BACK' or 'CANC'.
          perform Zexit_program.
        when others.
          call method cl_gui_cfw=>dispatch.
      endcase.
      clear ok_code.
      call method cl_gui_cfw=>flush.
    endmodule.                 " USER_COMMAND_0100  INPUT
    *&      Form  Zexit_program
          text
    -->  p1        text
    <--  p2        text
    form Zexit_program .
      call method tree1->free.
      leave program.
    endform.                    " Zexit_program
    <b>Reward if usefull</b>

  • What is an event handler..?

    I'm trying to learn how to make responsiveness UI. I've read that I can not use SwingUtilities.invokeLater() method if I am in a event handler. The question can seems stupid but I'm only a beginner: what is a event handler? From what I know it might be the actionPerformed method..is it right? Could somebody give me an example? thanks!

    Basically an event handler is a class that performs code.
    It can be any class (even the same that fires the event), but it has to implement the proper interface for the event you want to catch. If you want to perform special code when someone clicks on a button you want to catch an Action, therefor you need an ActionListener, a class that either implements the ActionListener interface (and therefor the method actionPerformed) or your class has to extend AbstractAction (and therefor has an actionPerformed, too).
    It you want to perform special code when someone chooses an element from a list, you want to be informed about a ListSelectionEvent and therefor need a class that implements the ListSelectionListener Interface (and provides the method selectionChanged).
    The class that should react on the event has to be declared as being a listener to the object that fires the events. So an actionListener on a Button would be added by
    button.addActionListener(listener);or
    button.setAction(action);(Note that all variables used are just for clarifiing the type you need and have to be exchanged by the names of your declared objects)
    There are many more events ... really, read the tutorial!

  • Can  DISABLE preProcess Event Handler add to the Orchestration parameters?

    I have a DISABLE pre-process event handler defined on the User object. I need to set the current date on a USR UDF attribute whenever the user is disabled or enabled or created. The CREATE handler works and the date value shows up on the user profile. However, when I try to set this attribute on the pre-process DISABLE or ENABLE event handlers, the new date does not show up. Here is the code I am using in my DISABLE/ENABLE event handler:
    Date currentTime = new Date(System.currentTimeMillis());
    orchestration.addParameter(USER_STATUS_DATETIME_ATTR_NAME, currentTime);
    Where the orchestration object is from the execute() parameter list.
    Any ideas as to why this is not working? Is adding to the orchestration not allowed for DISABLE or ENABLE event handlers? I know my handler is getting calls as I am logging the orchestration.getOperation() value.
    Thanks for any suggestions.
    -Dave
    Edited by: user552098 on Nov 12, 2012 1:56 PM

    When you update the field, make sure you are using the field label name, and not the UDF value.
    -Kevin

  • Declaring the internal table in ABAP objects

    Hi every1,
    Please any one let me know how to declare an internal table in class (ABAP objects). Bcos i am new to this classes.
    help me out.
    Regards,
    Madhavi

    Hi,
    Check this example..
    TYPES: BEGIN OF TYPE_DATA,
                   MATNR TYPE MATNR,
                   WERKS TYPE WERKS_D,
                 END OF TYPE_DATA.
    DATA: T_DATA TYPE STANDARD TABLE OF TYPE_DATA.
    DATA: WA_DATA TYPE TYPE_DATA.
    Adding rows to the internal table.
    WA_DATA-MATNR = 'AA'.
    APPEND WA_DATA TO T_DATA.
    Processing the interna table
    LOOP AT T_DATA INTO WA_DATA.
    ENDLOOP.
    Thanks,
    Naren

Maybe you are looking for

  • MacBook Pro freezes overnight

    Every once in awhile, I will forget to put my MacBook Pro to sleep before I go to bed. Without fail, in the morning when I try to wake it from sleep, it's frozen. The machine is still on and the screen is black, but no matter what you press on the ke

  • How long should Adobe Photoshop Elements 10 take to install?

    I have a MacBook Pro and currently the installation for Photoshop on my computer has taken over 2 hours and it's barely half-way through installation with 296 minutes left until completion. When I tried to cancel the installation to start again, noth

  • Skype unlimited subscription option not available

    I subscribed to Skype unlimited minutes subscription to +91 destination (mobile & landline). Later, after a week or so, when I visited Skype to suggest same offer to one of my friend; I didn't find it. My question is 'how to I renew my subscription n

  • How to compute field value in SIM

    I have a form with 3 fields and 1 button. The user will populate the firstname and lastname field. When they press a button (i.e. button consists of an expression), the button script should concatenate the firstname and lastname, the result should th

  • Syslog message CCX-3-AP_NOT_FOUND

    My customer is using AIR-WLC4402-25-K9 with 22 AIR-LAP1242AG-E-K9 AP. After WLC software upgrade to version 5.0.148.0 the syslog is full of messages: 2008-04-22 00:00:20 Local0.Error 10.156.93.66 Apr 21 23:01:20.300 ccx_rm.c:2771 CCX-3-AP_NOT_FOUND: