Why and how to use events in abap objects

Dear all,
  Please explain me why and how to use events in abap objects with real time example
regards
pankaj giri

Hi Pankaj,
I will try to explain why to use events... How to use is a different topic.. which others have already answered...
This is same from your prev. post...
Events :
Technically speaking :
" Events are notifications an object receives from, or transmits to, other objects or applications. Events allow objects to perform actions whenever a specific occurrence takes place. Microsoft Windows is an event-driven operating system, events can come from other objects, applications, or user input such as mouse clicks or key presses. "
Lets say you have an ALV - An editable one ...
Lats say - Once you press some button  you want some kind of validation to be done.
How to do this ?
Raise an Event - Which is handled by a method and write the validation code.
Now you might argue, that I can do it in this way : Capture the function code - and call the validate method.
Yes, in this case it can be done.. But lets say .. you change a field in the ALV and you want the validation to be done as soon as he is done with typing.
Where is the function code here ? No function code... But there is an event here - The data changed event.
So you can raise a data changed event that can be handled and will do the validation.
It is not user friendly that you ask the user to press a button (to get the function code) for validation each time he enters a data.
The events can be raised by a system, or by a program also. So in this case the data changed event is raised by a system that you can handle.
Also, Lets say on a particular action you want some code to trigger. (You can take the same example of validation code). In this case the code to trigger is in a separate class. The object of which is not available here at this moment. (This case happens very frequently).
Advantage with events : Event handlers can be in a separate class also.
e.g : In the middle of some business logic .. you encounter a error. You want to send this information to the UI (to user - in form of a pop up) and then continue with some processing.
In many cases - A direct method call to trigger the pop up is not done. Because (in ideal cases) the engine must not interact with UI directly - Because the UI could be some other application - like a windows UI but the error comes from some SAP program.
So - A event is raised from the engine that is handled in the UI and a pop up is triggered.
Here -- I would have different classes (lets say for different Operating Systems). And all these classes must register to the event ERROR raised in application.
And these different classes for different Operation systems will have different code to raise a pop-up.
Now you can imagine : If you coded a pop-up for Windows (in your application logic) .. it will not work for Mac or Linux. But of you raise a event.. that is handled separately by a different UI classes for Win, Linux or Mac  they will catch this event and process accordingly.
May be I complicated this explanation .... but I couldn't think of a simpler and concrete example.
Cheers.
Varun.

Similar Messages

  • Why and how we use Logical Database?

    Can anybody explain with example why and how we use logical database?
    Regards,
    Rajan

    Hello,
    SAP comes loaded with all the extras. Among the extras that are most helpful to IT managers are all the access routines needed to pull any business object that managers can think of out of SAP databases. However, SAP has not thought of everything where your particular applications are concerned. SAP organizes its standard database tables to service business units based on conventional business applications. Itu2019s likely your business requires something new, perhaps even something exotic. In that case, you will need to create a new database, using information from different places. Basically, you need a logical database. You need to create a virtual business data object repository consisting of a new kind of record or table that suits your purposes. In addition, the repository should be composed of information that is actually stored in a number of different locations, none of them necessarily logically associated with one another. Letu2019s take a closer look at creating logical databases.
    A case for a logical database
    Suppose my company manufactures widgets of the most obscure variety, and they are components of other widgets. I sell my widgets as raw material for the more sophisticated widgets built by others, but in some cases I actually partner with other manufacturers in creating yet another class of widget. Now, in my world, I consequently have customers who are also partners. I sell to them and I partner with them in manufacturing and distribution. Also, I need an application that uses both of these dual-use relationships.
    Essentially, I have a customer database and a partner database. Neither contains records that are structured to contain the identifying particulars of the other. Thus, I need a hybrid database that gives me tables detailing these hybrid relationships. What can I do? I can go the long way around and write a new database, pulling information from both and creating new objects with a customized program that I write by hand. However, this process is cumbersome and contains maintenance issues. On the other hand, I can use SAPu2019s logical database facility, create my logical database in a couple of minutes, and have no maintenance issues at all.
    Logical database structures
    There are three defining entities in an SAP logical database. You must be clear on all three in order to create and use one.
    u2022     Table structure: Your logical database includes data from specified tables in SAP. There is a hierarchy among these tables defined by their foreign keys (all known to SAP), and you are going to define a customized relationship between select tables. This structure is unique and must be defined and saved.
    u2022     Data selection: You may not want or need every item in the referenced tables that contributes to your customized database. There is a selection screen that permits you to pick and choose.
    u2022     Database access programming: Once youu2019ve defined your logical database, SAP will generate the access subroutines needed to pull the data in the way you want it pulled.
    Creating your own logical database
    ABAP/4 (Advanced Business Application Programming language, version 4) is the language created by SAP for implementation and customization of its R/3 system. ABAP/4 comes loaded with many predefined logical databases that can construct and table just about any conventional business objects you might need in any canned SAP application. However, you can also create your own logical databases to construct any custom objects you care to define, as your application requires in ABAP/4. Hereu2019s a step-by-step guide:
    1.     Call up transaction SLDB (or transaction SE36). The path you want is Tools | ABAP Workbench | Development | Programming Environment | Logical Databases. This screen is called Logical Database Builder.
    2.     Enter an appropriate name in the logical database name field. You have three options on this screen: Create, Display, and Change. Choose Create.
    3.     Youu2019ll be prompted for a short text description of your new logical database. Enter one. Youu2019ll then be prompted to specify a development class.
    4.     Now comes the fun part! You must specify a root node, or a parent table, as the basis of your logical database structure. You can now place subsequent tables under the root table as needed to assemble the data object you want. You can access this tree from this point forward, to add additional tables, by selecting that root node and following the path Edit | Node | Create. Once youu2019ve saved the structure you define in this step, the system will generate the programming necessary to access your logical database. The best part is you donu2019t have to write a single line of code.
    Regards
    Arindam

  • Why and how to use "inner class"

    When i am learning advanced java language features,
    i could not understand why and when to use the "inner class",
    who can give me some examples?
    Thanks!

    You would use an inner class when an object needs visibility of the outer class. This is akin to a C++ friend.
    An example of this is an iterator. An iterator over some collection is typically implemented as an inner class of the collection class. The API user asks for an Iterator (from the Collection) and gets one - in fact they receive an instance of an inner class, but doesn't care. The iterator needs to be inner, as the iterator needs to see the internal data structures of the outer (collection) class.
    This could also be done with an anonymous class, as mentioned by spenhoet above. However, in the case of a collection, the role of the iterator is clear - thus it deserves its own class. And often there is more than one place an iterator can be returned (e.g. see java.util.List, which has several methods that return Iterators/ListIterators), thus it must be put in its own class to allow reuse of the code by outer class.

  • This is a new notification coming up with iTunes, why and how do I fix it? The song "Penny Lane" could not be used because the original file could not be found. Would you like to locate it?

    This is a new notification coming up with iTunes, why and how do I fix it?
    The song “Penny Lane” could not be used because the original file could not be found. Would you like to locate it?
    Max

    Hey xxCreepyFiaxx,
    First, I would try the following suggested steps for when you don't see content in iTunes after updating:
    Quit iTunes.
    Download and install the latest version of iTunes.
    Use the Finder (Mac) or Windows Explorer (Windows) to go to the iTunes folder that contains the iTunes library files:
    Mac OS X
    /Users/username/Music/iTunes/
    Microsoft Windows Windows XP and Windows 2000
    \Documents and Settings\username\My Documents\My Music\iTunes\
    Microsoft Windows Windows Vista and Windows 7
    \Users\username\Music\iTunes\
    Drag the iTunes Library file from the above location to the Desktop.
    Open the Previous iTunes Libraries folder in the iTunes folder.
    Locate the file named iTunes Library YYYY-MM-DD where YYYY-MM-DD is the date you upgraded iTunes (Year-Month-Day).
    Drag this file to the iTunes folder (the enclosing folder).
    Rename this file to iTunes Library.
    Open iTunes.
    You should now see your missing content in iTunes.
    via: No content shows up in iTunes after updating
    http://support.apple.com/kb/TS1967
    If that doesn't resolve the issue, then I'd go through the steps in here:
    iTunes: Finding lost media and downloads
    http://support.apple.com/kb/TS1408
    Have a good one,
    Delgadoh

  • Firefox will only allow me to look at my bookmarks when I open the app using open as administrator. Why and how can I fix this?

    I can open my tools, bookmarks ect. only if I open the Firefox app using the run as administrator. Why and how can I fix this?

    On the profile folder in windows you can right click on the folder and uncheck the "run as an administrator"
    [[Profiles - Where Firefox stores your bookmarks, passwords and other user data]]

  • Why and how do we use CHAIN and ENDCHAIN

    Why and how do we use CHAIN and ENDCHAIN

    Hi,
    To ensure that one or more PAI modules are only called when several screen fields meet a particular condition, you must combine the calls in the flow logic to form a processing chain. You define processing chains as follows:
    CHAIN.
    ENDCHAIN.
    All flow logic statements between CHAIN and ENDCHAIN belong to a processing chain. The fields in the various FIELD statements are combined, and can be used in shared conditions.
    CHAIN.
      FIELD: <f1>, <f 2>,...
      MODULE <mod1> ON CHAIN-INPUT|CHAIN-REQUEST.
      FIELD: <g1>, <g 2>,...
      MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
    ENDCHAIN.
    The additions ON CHAIN-INPUT and ON CHAIN-REQUEST work like the additions ON INPUT and ON REQUEST that you use for individual fields. The exception is that the module is called whenever at least one of the fields listed in a preceding FIELD statement within the chain meets the condition. So <mod1> is called when one of the fields <fi> meets the condition. <mod2> is called when one of the fields <f i> or <g i> meets the condition.
    Within a processing chain, you can combine individual FIELD statements with a MODULE statement to set a condition for a single field within the chain:
    CHAIN.
      FIELD: <f1>, <f 2>,...
      FIELD  <f> MODULE <mod1> ON  INPUT|REQUEST|*-INPUT
                                  |CHAIN-INPUT|CHAIN-REQUEST.
      MODULE <mod2> ON CHAIN-INPUT|CHAIN-REQUEST.
    ENDCHAIN.
    The module <mod1> is called when screen field <f> meets the specified condition for individual fields. <mod2> is called when one of the fields <fi> or <f> meets the condition. If you use the addition ON CHAIN-INPUT or ON CHAIN-REQUEST with FIELD <f>, the condition also applies to the entire chain and module <mod1> and <mod2> are both called.
    In cases where you apply conditions to various combinations of screen fields, it is worth setting up a separate processing chain for each combination and calling different modules from within it.
    Regards,
    Ferry Lianto

  • On my iPad home screen, the mail app used to indicate the number of new emails I had with a number in a red circle.  This has vanished since I upgraded.  Does anyone know why, and how to restore this?

    On my IPad 2 home screen, the mail app used to indicate the number of new messages with a number in a red circle, next to the app.  This has vanished, I think about the same time as when I upgraded to the new OS.  Does anyone know why and how to restore this feature? 

    Thanks.  While you were replying to my question, I went into notifications and figured
    it out.  Appreciate the quick response!

  • I only see the phone numbers of my contacts when using iMessage on my MAC, whereas I see the names on my iPhone. Why, and how can I make it so I see the names (and pics) on my MAC?

    I only see the phone numbers of my contacts when using iMessage on my MAC, whereas I see the names on my iPhone. Why, and how can I make it so I see the names (and pics) on my MAC?

    Thanks Eric, but that was already turned on. I just now tried turning it off and on again, no change. Actually, I"m more interested in seeing the names than the pictures. I now only see the phone numbers and generic avatars where pics would be.

  • My i phone 4 as died after using facetime any ideas why and how to start it bak up???

    my i phone 4 as died after using facetime any ideas why and how to start it bak up???

    Connect iPhone to Wall Charger for 10 minutes, it may turn ON itself. If still nothing, keep on charger and Reset, hold both home and power buttons for about 20 seconds until the iPhone begins to start.

  • IPad bombs out returns to home page using Google Earth and other random Apps, why and how can I prevent it happening?

    iPad bombs out returns to home page using Google Earth and other random Apps, why and how can I prevent it happening?

    Quit/close all apps and restart the iPad.
    Go to the home screen first by tapping the home button. Quit/close open apps by double tapping the home button and the task bar will appear with all of you recent/open apps displayed at the bottom. Tap and hold down on any app icon until it begins to wiggle. Tap the minus sign in the upper left corner to close the apps. Restart the iPad.
    Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    You can try this as well.
    Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.

  • I've recently downloaded Lion and find my Microsoft excel, word, entourage and powerpoint do not function. It says these functions are not now supported. Why and how do I get to use them again?

    I've recently downloaded Lion and find my Microsoft excel, word, entourage and powerpoint do not function. It says these functions are not now supported. Why and how do I get to use them again?

    philippnoe wrote:
    What a "great" Program which is supporting many nice but not mandatory things but is not supporting a Program which is used day by day from many users ... and especially this Program is also sold officially by apple !!!
    Yeah!, Why, Lion won't even run my old DOS programs! 

  • I use to administrate my DSL modem via an ip-address. When I enter it into FF8 I am asked where to save the file. Why and how can I prevent FF8 from doing that?

    I use to administrate my DSL modem via an ip-address. When I enter it into FF8 I am asked where to save the file. Why and how can I prevent FF8 from doing that?
    And now anytime I am entering an ip-address I am asked if I want to download the file.

    It happens when the modem server doesn't send the file as text/html, but with another MIME type.<br />
    I tried the index.html addition in case the server might send that file as text/html.<br />
    If your DSL modem has a support website then you can try to ask there for advice about how to configure the modem server.

  • I use iPhone, iPad and MacPro, all works fine but the newly purchased iMac does not receive emails on time - always later than other devices. Why and how to fix?

    I use iPhone, iPad and MacPro, all works fine but the newly purchased iMac does not receive emails on time - always later than other devices. Why and how to fix?

    Go to Mail Preferences
    Click on the General tab
    Set  "Check for New Messages:"  to  "Every Minute"
    Hope this helps

  • Cannot access BTyahoo mail using safari or google chrome but can using Firefox. Any ideas why and how it is fixed

    I have recently signed up to BT but find that I cannot access BTyahoo mail using either safari or google chrome - the pages are just not available. But it works with Firefox. Any ideas why and how it can be fixed?

    Hi, this has worked for a few...
    Make a New Location, Using network locations in Mac OS X ...
    http://support.apple.com/kb/HT2712
    10.7 & 10.8…
    System Preferences>Network, top of window>Locations>Edit Locations, little plus icon, give it a name.
    10.5.x/10.6.x/10.7.x instructions...
    System Preferences>Network, click on the little gear at the bottom next to the + & - icons, (unlock lock first if locked), choose Set Service Order.
    The interface that connects to the Internet should be dragged to the top of the list.
    10.4 instructions...
    Is that Interface dragged to the top of Network>Show:>Network Port Configurations.
    If using Wifi/Airport...
    Instead of joining your Network from the list, click the WiFi icon at the top, and click join other network. Fill in everything as needed.
    For 10.5/10.6/10.7/10.8, System Preferences>Network, unlock the lock if need be, highlight the Interface you use to connect to Internet, click on the advanced button, click on the DNS tab, click on the little plus icon, then add these numbers...
    208.67.222.222
    208.67.220.220
    Click OK.

  • After updating to iTunes 5, I got an error message said the iPhone cannot be used because the Apple Moble Device service is not started. Any idea why and how to fix this? Thanks!

    After updating to iTunes 5, I got an error message said the iPhone cannot be used because the Apple Moble Device service is not started. Any idea why and how to fix this? Thanks!

    Please follow this article:
    http://support.apple.com/kb/TS1567
    it should help
    let me know

Maybe you are looking for

  • How to slave a Macbook pro with no OS

    Helping a friend who just got a (Macbook pro 2) secondhand without any OS installed (HD wiped clean). He is replacing his current MB Pro that is running 10.4.11. I hoped a USB to USB would allow the new computer to be recognized as a HD on the deskto

  • Passing Variable in CFGRID

    Hi I am usin coldfuison 9 and have a grid that gets poplulated by a query in a .cfc The queries work and the grid poplulates except when I try to add a hyperlink to a field that should link to a detail page. Here is my code I am an beginner working o

  • Oracle linux 6.3: (yum update) [Errno 14] PYCURL ERROR 18

    Hi all, I installed yesterday Oracle Linux 6.3 in the first time and when I tried to do yum update I got the following error: [root@ole6 ~]# yum update Loaded plugins: refresh-packagekit, security http://public-yum.oracle.com/repo/OracleLinux/OL6/lat

  • I cant call to a mobile number since yesterday, but can receive call from the same number. I am using iphone 4s. Is there any setting error?

    I can't call to a mobile number since yesterday, but still can receive call from the same number. I am using iphone 4s. Is there any setting error?

  • Pacman system upgrade

    hi i done a system upgrade with pacman -Syu everything downloaded ok, it gets to the install and errors with dependency errors saying quite a few (cant remember which ones) packages need xfree86. then it aborts i haven`t got a clue ........ help  :?: