Practical Use of OOPs ABAP – Model View Controller (MVC). Part III

Benefits of OOPs
Share on Facebook5Share on LinkedIn19Tweet about this on TwitterShare on Google+0
Please Share!!

In Part I, we covered the concept of Model View Controller in OOPs ABAP. In Part II, we added another class to add more feature to the User Interface. Now in this concluding part is the final real time requirement, when the user needs only specific fields and additional information from multiple tables to be displayed.

This is a practical project scenario, where there is a change request for an already delivered object. In the initial development there was some business logic, but now the flow has changed and hence the business logic has changed. We need to enhance the old OOPs program and update our Model.

You have guessed it right. In this part, we will be changing only our MODEL i.e. our class CL_FETCH

We are selecting our data from multiple tables and eventually, we will be displaying the data using our final table.

OOPs ABAP

We have three methods here including CONSTRUCTOR.

FETCH_DATA: will return the respective data from different tables.

ARRANGE_DATA:  will append our data from the respective table into our final table.

ABAP Objects

So we have final table IT_FINAL which we will pass to our factory method.

Now if you observe our all scenarios we have changed the classes independently without disturbing the other classes.

The logic behind decoupling is simple. When we change our View (CL_ALV) we don’t have to bother about the MODEL i.e. our data class (CL_FETCH) and vice-versa.

Also ReadJust 4 Versions of the same program to understand OOPs ABAP

Final Program:

Do you Know? How to convert an existing ABAP Report to OOPs ABAP?

Here is the output of the program.

SAP Objects

OOPs Programming

Hope we were able to explain the Model View Controller concept and now you can use this in your real project. In these short 3 Parts series, we tried to showcase the benefits of OOPs and how we can decouple the Model, View, and Controller. ABAP mentors always say that OOPs if used correctly would make every ABAPer’s life easier. It is easier to maintain and support. But, until and unless we implement OOPs in real projects, we cannot learn enough.

So, dare to come out of the procedural programming language and venture into OOPs ABAP.

Did you find these 3 Parts series on MVC useful?

In either case, please leave a quick comment and let us know if you have something to share with our SAP enthusiasts.

Till next time. Happy learning.

OOPs ABAP series on MVC Concept

Part I – Model View Controller (MVC) in SAP ABAP – Introduction

Part II – Model View Controller (MVC) in SAP ABAP – Enhance the View

Part III – Model View Controller (MVC) in SAP ABAP – Enhance the Model

Please Subscribe, Like and Share our Page.

Share on Facebook5Share on LinkedIn19Tweet about this on TwitterShare on Google+0
Please Share!!

About the Author

Jyoti Patel
Jyoti Patel
Jyoti is an experienced SAP Technical Consultant, currently stationed at Muscat, Oman providing her valuable expertise to Al Turki Enterprises LLC. She is fond of Object Oriented Programming with a soft corner for Adobe and Smartforms too.She loves exploring and experimenting different programming techniques. Presently, she is especially fascinated by APIs.Whenever she is not in front of the SAP screen, you would find her in her car heading for a long unplanned drive or listening to random music. Find more about Jyoti on LinkedIn.

1 Comment on "Practical Use of OOPs ABAP – Model View Controller (MVC). Part III"

  1. Hi,
    this short tutorial of MVC in ABAP is good. But what about the BUS_SCREEN Framework? In my opinion it is easier to use and less work. What’s the advantage of this doing?

Leave a comment

Your email address will not be published.


*