MVC Package Structure – Custom Data Explorer

In most programming languages (that I’ve used anyway) packaging is directly related to directory structure. ABAP is different in this aspect and has its own particularities. Since almost everything related to SAP is stored within a database, including source code, we can’t talk about defining package structures with the help of directory structures. We have to manually create them.

There are three different types of packages. Your main package is a structure package, this allows you to add sub-packages to it in a hierarchical way. All packages under it are main packages possibly containing regular packages called “not main packages”.

You can create packages via SE80 Object Navigator. From the main left menu select “Repository Browser” and from the dropdown below it select “Package”. Typing a new package name and attempting to display it will display a package creation wizard. You can create packages and sub-packages this way, the interface being very intuitive.

The package structure for this MVC implementation is straightforward:
ZSAB_DATA_EXPLORER
|-- ZDE_MODEL
|-- ZCL_DE_MODEL
|-- ZDE_CONTROLLER
|-- ZCL_DE_CONTROLLER
|-- ZIF_DE_CTRL_EVENTS
|-- ZDE_VIEWS
|-- ZDE_MAIN

Notice there isn’t a global event controller dispatcher to be used by views/abap screens to dispatch controller events. Instead each view has its custom class for dealing with events (related or not to the controller) because abap only allows event handling inside class methods.

Usually, I add a Utils package as well besides model, view, controller packages for auxiliary/external functions that don’t really belong to any particular MVC component. But in this case, the custom data explorer is really simple and has no use for it.

This post is part of Custom Data Explorer.

Leave a Reply

Your email address will not be published. Required fields are marked *