You are on page 1of 5

SAP Network Blog: Basic ABAP OO eLearnings

Page 1 of 5

Blogs

Basic ABAP OO eLearnings


Thomas Jung Business Card Company: SAP Labs, LLC Posted on Aug. 11, 2009 06:29 AM in ABAP, Beginner, Business Server Pages, Web Dynpro

Subscribe Print Permalink Share

Introduction
This blog introduces a 5 part eLearning series based upon a frequent request to look at basic ABAP Object Oriented concepts. Throughout this series we will look at OO terminology, development tools, and design patterns that span a variety of ABAP release levels. We will try to keep the discussion away from all the new cutting edge syntax so that it is still quite usable for those of you on older releases like 4.6C or 6.20. For the 5 part series we will start with Part 1 looking at tooling (the ABAP Class Builder) and some basic terminology. In Part 2 we will expand the lesson by looking at static vs. instance, visibility, exception classes, inheritance, polymorphism and abstract classes. In part 3 we will see how a special type of class, called a persistent object, can be used for Object Oriented access to the database. In part 4 we will explore Object Oriented concepts in User Interface technologies. Keeping with the theme of older release levels, we will focus this part on using Model View Controller and OO eventing within Classic Dynpro applications. Finally in part 5 we will look at real world, complex example that uses all the techniques and technologies from the previous parts.

Part 1 - Basics
In Part1 of the eLearning we start with the very most basic concepts. We will explore the class builder tool within SE80 and discuss some of the terminology that you need to know in order to begin to learn Object Oriented design and development. Part 1 Video Running Time: 53 Minutes

Part 2 - Classes, Inheritance, Visibility, Polymorphism


In this part, we will expand the lesson by looking at static vs. instance, visibility, exception classes, inheritance, polymorphism and abstract classes. We start with a very basic class with only static methods that works very much like a Function Group/Function Modules. Next we change the methods into instance methods and see how a class instance allows us to model complex data structures and relationships in code. Then we see how exception classes can make our exceptions more meaningful and simplify the surrounding code for dealing with exceptions. Finally we see the real power of object oriented design come to life as we use inheritance and polymorphism to hide the inner complexity of our business logic from calling applications all while ensuring uniform execution of our code. These techniques may feel foreign at first, but in the long run they lead to code that is easier and safer to maintain. Part 2 Video Running Time: 1 Hour, 10 Minutes

Part 3 - Persistant Objects


In this part, we will expand the lessons of the previous tutorial and look at a special type of class in ABAP the Persistent Object. Persistent Objects are an OO-based approach to the types of data access that you would normally perform with SQL statements. With Persistent Objects you dont code any SQL statements. Instead a class is generated for you that contains SET and GET methods for reading and updating data. ABAP Persistent Objects also contain the functionality for more complex update scenarios like V2 Asynchronous updates. Part 3 Video Running Time: 1 Hour, 9 Minutes

Part 4 - User Interface


In this part, we look at the special use case of Object Oriented technology and design techniques as they are applied to User Interface creation. Throughout all the ABAP UI technologies, we study how MVC (Model View Controller) design can be applied. We look briefly at BSP and Web Dynpro ABAP and OO effects the overall design as well as specific features like UI element rendering and eventing. We close with an example of how you can adapt even Classic Dynpro and its PBO/PAI processing looks to a more Object Oriented MVC flow. Part 4 Video Running Time: 1 Hour

Part 5 - Putting It All Together


In this final entry in the 5 part ABAP OO series, we examine examples of how SAP puts the techniques that we learned in the previous 4 sessions to work within the standard code that they deliver to customers. We start by looking at the CL_BCS classes for sending email. CL_BCS* serves as a perfect example of the use of Persistent Objects and Polymorphism. We also look at the functionality behind the new ABAP Code Completion feature in the ABAP Editor. This block of code uses Persistent Objects, Inheritance/Polymorphism, Exception Classes, and MVC structured Classic Dynpro. Part 5 Video Running Time: 42 Minutes

Source Code
Source Code Download The source code for this tutorial is provided in two different formats. The directories cofiles and data contain ABAP transport files with all the development objects contained in this tutorial. If you have access and permission to import transport files from external systems, this can be a good way to import the tutorial source code. All objects are imported at once and all development object types are supported. However you should only use this approach if you are importing into a 7.0 or higher level system. The transport files contain development objects (like Web Dynpro ABAP) that only exist at this development level. If you import the transport in earlier releases, you will receive import errors. The other solution is to import the development objects using SAPlink. SAPlink is not an SAP provided or supported solution. It is a community created project for exporting and importing ABAP development objects in XML format. You can read more about SAPlink at http://www.saplink.org. The SAPlink files are the ones with the file extension NUGG. I have divided the SAPlink files into smaller groups so that you can import just the objects that you want and avoid technologies that might not be supported on your release level. The main drawback to SAPlink is that it doesn't have a plug-in that supports persistent objects. Therefore it is not possible to include the persistent classes from Part 3 of the Tutorial. I have still included the data dictionary objects and programs from this section of the tutorial. The following is the listing of the SAPlink objects and the suggested order of import: NUGG_AFS_OO - these are basic classes and programs from Tutorial #1 and #2. They should be usable back to WebAS 6.10 and higher based releases. NUGG_AFS_OO_PERSISTENT_DDIC - these are the only the data dictionary objects used in Tutorial #3. NUGG_AFS_OO_PERSISTENT_PROGRAMS - these are the dynpro programs that are used to test the persistent classes from Tutorial #3. They need the persistent objects that cannot be offered via SAPlink. You would need to create the persistent objects manually before you could import these programs without error. NUGG_AFS_OO_PERSISTENT_PROGRAMS_702 - These would mostly be an item of curiosity. For proper import they would require an ABAP 7.02 based system (which isn't available yet as of Aug 2009) or NetWeaver 7.1x or higher (of which there is not version of the Business Suite that runs on this NetWeaver release). Chances are low that there are many people who could import these objects without syntax errors. However knowing this, you might still want to study the code to see what will be possible in the near future. NUGG_AFS_OO_UI_DDIC - From Tutorial #4 - these are the data dictionary objects that are used throughout the UI based tutorials. Please import these before any of the other UI tutorials and regardless of which UI technology tutorials you are importing. NUGG_AFS_OO_UI_DYNPRO - From Tutorial #4 - these are the classic dynpro based tutorials and can be imported into any release level supported by SAPlink (technically the demos should

http://weblogs.sdn.sap.com/pub/wlg/15408

25/12/2011

SAP Network Blog: Basic ABAP OO eLearnings

Page 2 of 5

work back in 4.6C as well if you want to recreate them manually). NUGG_AFS_OO_UI_BSP - From Tutorial #4 - these are the BSP (Business Server Pages) related examples. Only import them into a WebAS 6.20 or higher based release level. NUGG_AFS_OO_UI_WDA - From Tutorial #4 - these are Web Dynpro ABAP related examples. Only import them into a NetWeaver 7.0 or higher based release level.

Thomas Jung

Thomas Jung is an SAP Technology Solution Architect focusing on Custom Development Tools - particularly in the areas of ABAP and User Interface Technology.

Comment on this weblog Showing messages 1 through 27 of 27. Titles Only ZCL_OO_TUTORIAL_6_BASE missing 2011-10-02 13:16:37 Valter Oliveira Business Card [Reply] Hello Thomas. First of all I must Thank you for the extremely helpfull videos! Very nice job! Main Topics Oldest First

I downloaded NUGG_AFS_OO file and I was trying to upload in my system (SAP ECC 6.0) using SAPLINK.

I activated sucessfully classes ZCL_OO_TUTORIAL_1 until ZCL_OO_TUTORIAL_5 but when activating ZCL_OO_TUTORIAL_6_747, ZCL_OO_TUTORIAL_6_A310 and ZCL_OO_TUTORIAL_6_OTHER I faced the follwing error: "Class ZCL_OO_TUTORIAL_6_BASE doesn't exist".

Regards, Valter Oliveira. ZCL_OO_TUTORIAL_6_BASE missing 2011-10-03 09:18:20 Thomas Jung Business Card [Reply]

I think the problem is just the order of activation. Have you tried activating ZCL_OO_TUTORIAL_6_BASE? It is the base class which the other classes inherit from and therefore must be active first. Better yet, simply activate all the classes at once from the inactive view of SE80 and then you don't have to mess with dependenices at all.

I checked the download and the nugget does contain class ZCL_OO_TUTORIAL_6_BASE, so nothing is missing from the download. O.O 2011-01-27 12:02:35 Albert Aurelien Business Card [Reply] Hi, Very great work, I've learned a lot about ABAP O.O thanks to your video.

Have you plan to do/already did some extra video about ABAP O.O? Like Web services? If yes i'll be please to watch them.

Thanks thomas for you good job Great blog, but I have a problem... 2009-11-25 03:22:37 GED HURST Business Card [Reply] Hi Thomas, Really getting a lot out of this, but I have a problem with class ZCL_OO_TUTORIAL_6_BASE (from Part 2 - Classes, Inheritance, Visibility, Polymorphism).

I install from SAPlink OK, but when I try to activate this class I get the error message: 'Method "ZIF_OO_TUTORIAL_6~CALCULATE_FLIGHT_PRICE" has already been implemented'. Any ideas on what's going wrong?

Many thanks in advance.

Regards Ged Hurst Great blog, but I have a problem... 2009-11-25 05:50:06 Thomas Jung Business Card [Reply]

I believe this is a bug with SAPlink - and I've encountered it myself. It is inserting the method implementation twice. You might be able to fix it by going Goto->Sections->Public Section and seeing if you can delete one of the two method implementations. Other option is to make sure you are running the latest version of SAPlink and reimport this nugget. 2nd part of Video 1 stopped at 11:34/19:57 2009-11-06 12:29:04 Derek Ting Business Card [Reply]

http://weblogs.sdn.sap.com/pub/wlg/15408

25/12/2011

SAP Network Blog: Basic ABAP OO eLearnings

Page 3 of 5

Hi, It is a great demo. But I got some problem for the 2nd part of Video 1. It stopped at 11:34/19:57.

Tim 2nd part of Video 1 stopped at 11:34/19:57 Business Card [Reply] 2009-11-06 12:36:22 Thomas Jung I just watched the video it played fine beyond that point. The videos are streamed so there can of course be problems with the internet connection from either side or problems on the SCN server. You should be able to restart the video, skip back to that section and continue watching. 2nd part of Video 1 stopped at 11:34/19:57 2009-11-06 15:45:49 Derek Ting Business Card [Reply] Thanks.... It is working fine now. Great subject!.....but got import issue 2009-11-05 18:46:27 Sam Chung Business Card [Reply] Hi Thomas, This eLearning is quite great article for us. For new ppl who have no OO concept and to learn quickly. It's impressed me. Thanks very much.

BTW, I downloaded the object "ABAP OO Tutorial Source Code" and import to our system. When the object was importing, I hit a error msg as below.

================================================ Program ZCB_OO_TUT_PERS_DEMO==========CP, Include ZCB_OO_TUT_PERS_DEMO==========CM00P: Syntax error in line 000152 ield 'I_OPTIONS-DATABASE_QUERY_OPTIONS' is unknown. It is neither in one of the specified tables no =================================================

Looking at the src code and found it's syntax error at: ================================================= if ( I_OPTIONS-DATABASE_QUERY_OPTIONS O IF_OS_QUERY_OPTIONS=>IGNORE_DELETED ). ================================================= in method "IF_OS_CA_PERSISTENCY~GET_PERSISTENT_BY_QUERY" of class "ZCB_OO_TUT_PERS_SFLIGHT".

Do you or any one have the same issue?? or any idea?

Thanks, Sam Chung Great subject!.....but got import issue 2009-11-06 04:23:02 Thomas Jung Business Card [Reply]

What release level is your system? I assume it is older than mine. The persistent objects contain generated code which could be specific to a certain release level. This is forward compatible, but not necessarily backwards compatible. This is the risk you run when transporting into an older release level. You can look at my persistent object, but should really recreate the steps and generate your own persistent object on your release level. Great Work Thomas 2009-10-09 10:36:26 Rob Burbank Business Card [Reply] I have been writing procedural code for more years than I care to admit to. I went through your podcasts before taking the BC401 course and it helped immensely. Thank you.

One tiny quibble - when you are talking and putting your mouse over code or other features, it would be great if you could drag the mouse over or otherwise highlight what you are looking at.

Rob Thank you 2009-09-29 14:20:55 Aida J. Hilton Business Card [Reply] Thanks for a great presentation on ABAP OO. I've been getting a bit (okay a lot) behind and it is now time to catch up and start using ABAP OO. Seeing this blog was indeed timely. OOPssssss....clear :) 2009-09-17 00:34:34 anurag sharma Business Card [Reply] Hey man, Useful blog and helps to understand the basics clearly. I hope few more topics will come to your side. Thank you Thomas. ABAP development environment online 2009-11-03 20:29:23 Marathe Dhananjay Rajhans Business Card [Reply]

http://weblogs.sdn.sap.com/pub/wlg/15408

25/12/2011

SAP Network Blog: Basic ABAP OO eLearnings

Page 4 of 5

hi! can u please share some information about my prob. i want to practice on SAP development environment online with out spending any cost as i have spent a lot of it while doing certification. ABAP coding needs consistant practice. kindly suggest solution. ABAP development environment online Business Card [Reply] 2009-11-04 04:23:00 Thomas Jung I would suggest the free trial version of the ABAP AS that can be downloaded from SCN (got to the Downloads tab and then choose SAP NetWeaver Main Releases). You can install this on a typical desktop or laptop computer and use it to continue your learning of ABAP. Good 2009-09-16 21:01:38 Ashok Babu K Business Card [Reply] Good subject, Hats off to the blogs. Re: Basic ABAP OO eLearnings 2009-09-01 08:25:16 Kenneth Moore Business Card [Reply] Additionally, it's great to have a former customer working in SAP. Sort of a customer advocate which really "gets" the customer, their struggles, and their needs. Thanks! Re: Basic ABAP OO eLearnings 2009-09-01 08:22:30 Kenneth Moore Business Card [Reply] You're a good man, Charlie Brown. ;-) You are always extraordinary 2009-08-30 21:41:44 Prabhakar D Business Card [Reply] Tremendous job, Hats off to you all your blogs Great work! 2009-08-19 08:26:03 Guillaume Garcia Business Card [Reply] Hi, Thanks for compiling this and also for the podcasts on the same subject! As a nice follow-up, it would be great if you could talk a bit more about the new UML features that (should) come with EhP2. :) [I saw this the first time in this resource of yours: https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/90db53c4-812d-2c10-0789-dc18f6c9c725] Thanks in advance.

Best regards, Guillaume Very informative blog 2009-08-18 13:35:08 Brian Vanderwiel Business Card [Reply] Excellent eLearning - thanks. One question: I tried to import the WDA component via SAPLink but CL_WDY_MD_PANEL UI element is not in my 7.00 system. Can you please confirm that it should be? Specific error is "Definition for UI element type "CL_WDY_MD_PANEL" does not exist". Brian Very informative blog 2009-09-01 07:21:28 Thomas Jung Business Card [Reply]

Sorry that it took a while, but I have a patch for the WD Component in the exercises that removes the usage of the 7.02 Panel UI element. You can access the saplink patch here: http://sdn-mentor-handson-2008.googlecode.com/files/WDYN_ZAFS_OO_WDA.slnk Very informative blog 2009-09-04 13:18:43 Brian Vanderwiel Business Card [Reply] The Slinkee worked. After creating the WD application, I needed to change the last line in the FILL_SFLIGHT method of the COMPONENTCONTROLLER - replacing lt_flight with i_sflight. Everything is working. Thanks again for a great blog series. Very informative blog 2009-08-18 13:39:10 Thomas Jung

Business Card [Reply]

No panel wouldn't be there in 7.0. That is one of the newer UI elements. I will have to swap the panel with a tray and put a new a SAPLink file up. Might take a few days. Outstanding Work! 2009-08-16 10:11:18 avinash pandey Business Card [Reply] Thanks a lot Thomas! I have enjoyed immensely and learned a lot from this 5 part series and honestly it is such an eye-opener to me on several things which I have been using for years without actually understanding the base logic behind them.

http://weblogs.sdn.sap.com/pub/wlg/15408

25/12/2011

SAP Network Blog: Basic ABAP OO eLearnings

Page 5 of 5

Thanks a lot once again and I do hope that you will be pulling off such great stuff more often than not. OO - First Time 2009-08-14 13:52:32 aRs . Business Card [Reply] I am seeing this presentation as first time attempt on Object Oriented Approach. And it covered most of the basic and advanced concepts in OO.

Once again thanks

as Kudos to you Thomas 2009-08-11 17:14:41 Matt Harding Business Card [Reply] Teaching ABAP OO to non-OO ABAP programmers is really tough, and this is a great resource I can point people towards. Thanks heaps, Matt

Showing messages 1 through 27 of 27.

http://weblogs.sdn.sap.com/pub/wlg/15408

25/12/2011

You might also like