Difference between classical ABAP and OO ABAP
1)If we look at the procedural programs , we find that the data and functions are loosely coupled.
For example. if we look at function group, it consists of multiple function modules. All the data declaration you will find in the top include. When you try to access any function module the whole function group is loaded into the memory. So in case if you are editing any variable in the Top include it will be reflected across all the function modules. Hence it might lead to data inconsistency.
But in the object oriented ABAP, the data and functions are tightly coupled. This means at any time an object has it’s own set of data and functionalities bounded to it and with the help of visibility section we can hide the data from the outer world
2)when we look at the exception part. Class based exceptions are more beneficial then classical exceptions.
In procedural exceptions, the exception is always assigned a number(no_rate_found = 1)
CALL FUNCTION 'CONVERT_TO_LOCAL_CURRENCY'
* CLIENT = SY-MANDT
date = itab-date_of_export
foreign_amount = dl_kwert
foreign_currency = itab-waers
local_currency = c_usd IMPORTING
local_amount = itab-value_of_goods
" un-comment these sections
no_rate_found = 1
overflow = 2
no_factors_found = 3
no_spread_found = 4
derived_2_times = 5
OTHERS = 6.
IF sy-subrc EQ 7.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
" this is display the system message automatically when ever exp are hit WITH
SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
That means if you didn’t handle it properly then it may mislead.
For example here sy-subrc = 7 is the condition which is never possible and hence the developer has not properly handled the exceptions.Whereas in the class based exceptions, it has proper text(using get_text())so that users can understand where the exception has really occurred.
If we have nested function modules and suppose the inner function module has thrown an exception then it will be propagated to the outer function module. Hence immediately the exception is not handled. Whereas in the class based exceptions , exceptions once raised arehandled immediately as and when they are raised using TRY …CATCH.
Very Nice. is this only difference. Please elaborate by taking one live business example. Why oops ABAP is better than ABAP. clearly show the difference.