Most programs seem to borrow or repeat code that exists in other programs. In most cases the repetition is used...
By submitting your personal information, you agree that TechTarget and its partners may contact you regarding relevant content, products and special offers.
to create nearly the exact same functionality. But, when that functionality has to change, it needs to get changed in perhaps hundreds of programs.
In versions prior to object orientation in ABAP modularization was achieved through using macros, includes, and function modules. Each of which has problems ranging from number-of-lines inefficiency to not being available in the debugger.
Instead, develop a very simple class hierarchy to describe functionality found in most programs and implement it using template programs. This creates smaller, smarter, self-documenting, and maintainable code that is available in the debugger.
Classes also allow you to do things that couldn't always be done in other modularization techniques. For example, variables and constants for standard text or boolean values can not be declared (or sometimes defined) in the main program body using function modules. But as properties of a class they can be referenced simply with INSTANCE->PROPERTY (ie: hrapp->true)without being declared and defined in the main program body. Otherwise they would be declared and defined using DATA...VALUE... and then referenced by variable name.
Sample class heirarchy... My_company_program_class (File operations, titles/headers, text and boolean constants) HR Mstr Data & Planning HR Benefits HR Time & Payroll HR Application Class (This class is primarily an interface, inhereting most of its properties and methods from the four classes above. This is the class that will be implemented.) Sample simple report template... REPORT zgbhtst10 LINE-SIZE 80 LINE-COUNT 65 NO STANDARD PAGE HEADING. DATA: hrapp TYPE REF TO zhr_application_class. INITALIZATION. IF hrapp IS INITIAL. CREATE OBJECT hrapp. ENDIF. START-OF-SELECTION. IF hrapp IS INITIAL. CREATE OBJECT hrapp. ENDIF. * insert selection body here ... END-OF-SELECTION. * insert output body here ... CLEAR hrapp. FREE hrapp. TOP-OF-PAGE. CALL METHOD hrapp->hr_report_title.