
- 387 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Design Patterns in ABAP Objects
About this book
Use design patterns to step up your object-oriented ABAP game, starting with MVC! Want to create objects only when needed? Call objects only when required, minimizing runtime and memory costs? Reduce errors and effort by only coding an object once? Future-proof your code with a flexible design? Design patterns are the answer! With this guide, you'll get practical examples for every design pattern that will have you writing readable, flexible, and reusable code in no time! Creational Design Patterns Create objects with the abstract factor, builder, factory, lazy initialization, multiton, prototype, and singleton design patterns Structural Design Patterns Allow objects to interact and work together without interdependency with the adapter, bridge, composite, data access object, decorator, façade, flyweight, property container, and proxy design patterns. Behavioral Design Patterns Increase the flexibility of your object communication with the chain of responsibility, command, mediator, memento, observer, servant, state, strategy, template method, and visitor design patterns.
Highlights:
- MVC (model, view, controller) pattern
- Singleton pattern
- Factory pattern
- Builder pattern
- Observer pattern
- Visitor pattern
- Lazy initialization pattern
- Template method
- Strategy pattern
- Decorator pattern
- ABAP-specific examples
- Anti-patterns
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
Part I
1 MVC
- Model (”M”)
Class(es) that contain your application logic. A model class shouldn’t contain any code related to GUI operations. In the ABAP world, the model class would correspond to your backend classes in Transaction SE24. - View (”V”)
Class(es) that contain your GUI-related stuff. Textboxes, combo boxes, forms, etc. are all in this category. In the ABAP world, the view may correspond to your SAP List Viewer (ALV) grid, Web Dynpro ABAP components, etc. In a typical project, we reuse elements provided by SAP and don’t code views from the scratch. - Controller (”C”)
The client application that binds the model and view together. In the ABAP world, the controller would correspond to your executable application in Transaction SE38.
1.1 Case Study: Read, Process, Display, and Post
- Read: Read customer orders from tables VBAK and VBAP.
- Process: Eliminate orders of blocked customers.
- Display: Show results using ALV.
- Post: Create delivery documents for selected items.
REPORT zrep.
” Some data definitions
” Some selection-screen parameters
START-OF-SELECTION.
PERFORM read_orders.
PERFORM eliminate_blocked.
PERFORM display_alv.
END-OF-SELECTION.
FORM read_orders.
” Some code to read VBAK, VBAP, etc
ENDFORM.
FORM eliminate_blocked.
” Some code to read KN* tables and remove entries from the ITAB
ENDFORM.
FORM display_alv.
” Some code to call REUSE_ALV_GRID_DISPLAY
ENDFORM.
FORM user_command USING rucomm rs_selfield.
CHECK rucomm EQ c_ucomm_save.
PERFORM create_dlv.
ENDFORM.
FORM create_dlv.
” Some code to loop through the ITAB & create deliveries
ENDFORM.
” Some further forms
- You could simply copy and paste the code from Transaction SE38 to Transaction SE37. However, this is not the best idea. Why? If, for instance, you need to modify the blocked customer elimination logic or add a new field to the BAPI, you would need to modify multiple spots.
- You could take advantage of include files so forms are available everywhere. Not an elegant solution, because the data shared between forms would need to be defined in Transaction SE37/SE38 multiple times. If you need to add a new field to the internal table, you need to modify multiple spots.
- You could create a huge function group and turn forms into functions. This option is better than the others, but you wouldn’t be taking advantage of object-oriented features, such as polymorphism, inheritance, and encapsulation. See Appendix C for more information on these advantages.
Table of contents
- Dear Reader
- Notes on Usage
- Table of Contents
- Preface
- Part I Architectural Design Patterns
- 1 MVC
- Part II Creational Design Patterns
- 2 Abstract Factory
- 3 Builder
- 4 Factory
- 5 Lazy Initialization
- 6 Multiton
- 7 Prototype
- 8 Singleton
- Part III Structural Design Patterns
- 9 Adapter
- 10 Bridge
- 11 Composite
- 12 Data Access Object
- 13 Decorator
- 14 Façade
- 15 Flyweight
- 16 Property Container
- 17 Proxy
- 18 Chain of Responsibility
- Part IV Behavioral Design Patterns
- 19 Command
- 20 Mediator
- 21 Memento
- 22 Observer
- 23 Servant
- 24 State
- 25 Strategy
- 26 Template Method
- 27 Visitor
- A Object-Oriented Programming
- B Subclass Determination
- C Principles
- D The Author
- Index
- Service Pages
- Legal Notes