Previous Post: ABAP Freak Show – July 1st – ABAP OO Tutorial Part 1 Next Post: ABAP Freak Show – July 15th – ABAP OO Tutorial Part 3
ABAP Freak Show – July 1st – ABAP OO Tutorial Part 2
by Thomas Jung on July 1, 2009 at 2:25 pm
This is part 2 of the 5 part series on ABAP OO. 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.
You can also download all the source code from all 5 tutorials. Just be sure to look at the ReadMe.pdf file for important tips on installing the source code.
http://abap-sdn-examples-tpj.googlecode.com/files/AFS_OO_Tutorials_Source_Code.zip
You can download a high resolution version MP4 version of the video here:
http://blip.tv/file/get/Thomas_jung-AFSJuly12009ABAPOOPart2337.mp4
You can download an iPod/iPhone version of the video here:
http://blip.tv/file/get/Thomas_jung-AFSJuly12009ABAPOOPart2447.mp4
Tags: ABAP, ABAP Freak Show, ABAP OO Tutorial, development, NetWeaver, OO

Great job guys. (again)
I’ve been playing this note on and on again: Developers are slow in adopting OO ABAP, what is a very sad thing…
I believe there are 3 questions that need to be addressed:
1 – Why do we need OO ABAP? Why is it better? – That question is a very important one since tons of developers still don’t get it. To address that I often recommend checking the following article from Horst Keller and Gerd Kluger:
https://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/37c5db90-0201-0010-3a9b-d0a5288f3c15
http://www.google.ca/url?sa=t&source=web&ct=res&cd=2&url=http%3A%2F%2Fwww.sappro.com%2Farticle.cfm%3Fid%3D3363&ei=03slSpvMHtfMlQecooDiBw&usg=AFQjCNE011INmwIpDcwECwtJvqNb1SD12g&sig2=8lUJ5yF8PZhFzd9NBJUlnw
2 – Once we understand the need and the value of OO ABAP, how does it work – In this group is where your series of BLOGs will definitely help. Additionally, I find the new book from SAPPress ABAP OO programming quite helpful;
3 – Once we believe in OO ABAP (1) and know how it works (2), are there best practices? – it is for this area that my series of BLOGs (and my SAPTechEd session) is oriented. (Best practices in development of Business Classes)
So, for your info guys, I will be posting BLOGs that in NO WAY compete with your initiative (How could I anyway?
) These Blogs are just an addition and I find it quite valuable. Here is the list:
• PART 1: What are Business Classes and why do we need them?
• PART 2: Naming convention and Class structure (Attributes and methods);
• PART 3: Instantiation;
• PART 4: Inheritance;
• PART 5: Database Access;
• PART 6: Exceptions (Exception Classes);
• PART 7: Model Classes
• PART 8: Others (Package Hierarchy, performance optimization);
• PART 9: Community content and collaboration;
Pleae let me know if you have any problem with it or if you would like me to change anything. I will run it by you before hand anyways.
ADDITIONALLY: There has been some Twitter postings around wizards and code automation… I’ve been working on a Wizard to automate the generation of the business class (generating the class, the associated exception class, message class, DB access, naming convention for Attributes and methods, etc…) I thought it would be a good DEMOJAM presentation, but I just dont see it getting ready in a few weeks…
Also I don’t think all see the value of a tool like that so I don’t think it would go anywhere…
Thanks again guys.
Leonardo De Araujo
See you soon in Phoenix
@leo – this sounds like a great initiative. Question #1 is definitely a huge barrier for all the old schoolers doing procedural programming only. It still amazes me in the ABAP world how slow the adoption has been of such fundamental concepts that have been around for a long time. Looking forward to reading your blogs…if you want to cross post them here on egeeks, just let me know.
Sure will.
It would be great to cross post them.
What we need now is to spread the word.
Leo
Hello,
I just listened to your first two parts of the ABAP Freak Show OO Tutorial, and would like to thank you for doing all that for the community!
Secondly I was pleased to see that it looks like the way we walked with our current project is from OO perspective the right track.
I am really looking forward for the next episodes.
It would be greak if you could find the time to discuss a bit on the topics Assertions, Log / Watchpoints via SAAB, but NOT on how to use them, thats explained quiet well, but WHEN to use what and maybe why… You came across with good examples in your last sessions, due to that I can Imagine that you can explain that very well …
Thanks again from Germany
TIMO
Leo, thanks for the great comments and discussion points. We used them as a starting point for our OO discussion on the most recent podcast: http://enterprisegeeks.com/blog/2009/07/13/egeeks-podcast-episode-24/ I look forward to seeing your blog series on the topic as well.
I had not planned to include Assertions, Logpoints, Watchpoints, etc into this original series on OO, but I’m always looking for topics that people would be interested in for the future. I’m sure this is something that could work its way into a future series – maybe one on writing testable code. We could touch on Unit Tests, Code Inspector, Coverage Analyzer, Trace tool; as well as the points you bring up.
Thank you guys!