This video is an introduction to the new ways of thinking and the related concepts of OO (Object Oriented) ABAP.
An example of encapsulating data using a function group is presented, and the advantage of using OO ABAP instead of procedural programming is demonstrated.
Introduction
- Based on your existing knowledge of procedural programming with ABAP, I will explain the object-oriented approach using a Function Group.
- I will illustrate one of the advantages of using object-oriented programming over procedural programming.
- Let’s start by encapsulating data - a concept of the object-oriented programming mode – using a function group in ABAP.
Encapsulating Data: Speed
Function Group with functions to control the speed of a car.
FUNCTION-POOL zfg_vehicle.
*speed is a global variable
*used in the function-pool
DATA: speed TYPE i.
FUNCTION zfm_increase_speed.
ADD i_speed TO speed.
ENDFUNCTION.
FUNCTION zfm_decrease_speed.
SUBTRACT i_speed FROM speed.
ENDFUNCTION.
FUNCTION zfm_get_speed.
e_speed = speed.
ENDFUNCTION.