Sometime ago I published here in the SCN Weblogs the ABAP101 Projects to aim juniors ABAP developers get some experience through open source projects. In summary, we “hire” ABAP newbies to work in the open source projects with our coaching.
The project chosen was ABAPDoc and we called our project as ABAPDoc2. The first goal of this project is to refactory the original code to able next level of improvements, like templates, XML (SAPLink), Web Dynpro etc. To able those future improvements, we will follow MVC framework and the text here I will explain the ABAPDoc2 Model.
ABAP Workbench Model
The goal of this model is to abstract all types of ABAP Workbench objects, like packages, function groups and global classes. Check picture bellow of ABAPDoc2 model:
Let’s start identifying all classes to represent the objects in the workbench, which starts with ZCL_WB_, where WB states workbench.
Representing function groups, we have the class ZCL_WB_FUNCTION_GROUP associated with class ZCL_WB_FUNCTION_MODULE that represent function modules. The association chosen here was composition, because the function module can only exist if it’s linked to only one function group.
It must be considered at implementation time and most probably the class ZCL_WB_FUNCTION_GROUP will be responsible to create all objects of class ZCL_WB_FUNCTION_MODULE. However, it’s an implementation detail that the program must have to respect when he/she is coding it.
The class ZCL_WB_SOURCECODE represents the source code, even for function modules or method implementation.
The class ZCL_WB_CLASS is responsible to provide services related with global classes. Like function group and function modules relationship, the class ZCL_WB_METHOD is linked to ZCL_WB_CLASS and the ZCL_WB_METHOD objects can only exists if it’s associated to a ZCL_WB_CLASS object.
The third object in the workbench is the package, represented by class ZCL_WB_PACKAGE. In the ABAP Workbench a package can contains others packages and WB objects. However we decided to do not represent it in the model, because SAPLink still does not support it and it should be included in the next release.
All WB classes heritage from the same class called ZCL_WB_OBJECT that implements ZIF_WB_OBJECT interface. This interface is very important because it defines all methods that must be implement in the all WB classes. Based on this picture, all WB objects have follow methods:
- LOAD( ) is responsible to extract the information from the system and load all attributes in the object. For instance, if I create an object from ZCL_WB_CLASS, with NAME attribute as “CL_GUI_ALV_GRID” and call LOAD( ) method, the implementation must read information of class CL_GUI_ALV_GRID in the system and load all object attributes.
- SET_NAME( ) and GET_NAME( ), those methods are responsible to define and return NAME attribute.
- GET_HTML( ) is responsible to generate and return the HTML code.
So you can see that LOAD( ) and GET_HTML( ) are the most important methods in this Model.
To coordinate all services from workbench model we have ZCL_ABAPDOC_PROJECT class, who is responsible to provide all services to load and generate HTML code.
In the method list you found SET and GET that are responsible to define and return attributes. Bellow I describe two most import methods in this class:
- LOAD_ALL( ), this method will loop at all objects associated with ZCL_ABAPDOC_PROJECT and call method LOAD( ), using polymorphism calling LOAD( ) method implementation according the object type.
- EXPORT_TO_HTML( ), here the HTML files are going to be generated in the user desktop.
For this release, the ABAPDoc2 are going to only generate HTML files. In the future, we plan to also generate Web Dynpro component. I still do not know how to do that, but I’m sure that Model can allow us to generate any type of output, include allow to user use template to format HTML output.