When preparing hands-on sessions for the SAP Fiori Programming Model (in the past) and now for the ABAP RESTful Application Programming Model (RAP) I always faced the problem that we had to start from scratch.
That means that the participants were forced to create all objects of the stack such as table(s), interface CDS view(s), projection view(s), metadata extension view(s), behavior definition and projection for interface view(s) and projection view(s) and behavior Implementations alongside with a service definition and a service binding.
Most of what a developer has to do here is to write boiler plate coding such as the use of the insert all elements option when creating a CDS view based on a table or another CDS view.
For educational purposes it's OK that you learn how to develop all the objects step by step. But if you want to provide a deep dive session it is not much fun if you have to create lots of boiler plate coding before having the chance to dive into the more interesting topics.
Also for a normal developer it would be nice to have the chance to speed up the development process by getting an up- and running starter business object.
So I was very pleased when begin of 2020 I saw in an SAP internal review the new XCO framework (“Extension Components”) which allows you to generate various ABAP repository objects via released ABAP API's.
So I started to develop a class that allows you to generate nearly the complete stack of a RAP business object based on one root/header and multiple child and grandchild tables.
Meanwhile the project has grown and the RAP Generator project contains a RAP business object so that it offers a cool SAP FIori Elements UI. This Fiori Elements UI can be started using the Fiori Elements preview functionality from within ADT. And since the Fiori Elements UI offers an ADT link once the repository objects have been generated this UI well embedded in ADT as well.
With the 2202 release now the fifth version is available which now offers a SAP Fiori Elements UI similar to the well know key user tools in SAP S/4HANA. This can be as said started using the Fiori ELements preview of the RAP business object OData V2 service binding:
Lets have a look at the famous flight sample and take the two tables that are part flight sample repository
When you have dowloaded the RAP Generator and run the setup class so that the service binding ZDMO_UI_RAPGENERATOR_O2 is available.
Once you have created the RAP Generator project and have added the root and the child entity based on the two tables the RAP Generator will first create a JSON file
and once you press the "Generate Repository Objects" button the generator will create the following repository objects:
CDS restrictive reuse views
CDS interface views
CDS projection views
Behavior implementation classes
After the generation has taken place you will find an ADT link that lets you navigate back ADT to continue to work on the repository objects that have been generated for your convenience as shown in the following screen shot:
Please note that the generated artefacts follow the naming convention which is used for the development in SAP S/4HANA.
When using the RAP BO of the RAP Generator you will find that it offers some advanced features or RAP programming such as:
type ahead support when searching for packages or data sources (tables, CDS views or abstract entities)
drop down lists
fields and actions that change their behavior based on the current status of the instance of your RAP Generator project
storage of hierachial data in one table
First ADT based generation of RAP objects (SAP standard delivery available)
Meanwhile (as of release 2111) it is also possible to generate a RAP business object from within ADT as part of the SAP standard.
Why do I still work on the (openSource) RAP Generator though there is an ADT based version out?
This is because both generators have different goals / target groups.
The new ADT based wizard focuses on a simple used case. It does only support the generation of a RAP business object based on one table and will generate a draft enabled managed business object.
When starting my opensource based RAP Generator my goal was also to support more complex scenarios that encompass not only a root node but also scenarios where you deal with a root node and one or more child nodes that itself may have one or several childnodes themselves.
RAP generates RAP
The RAP Generator takes a JSON file as an input that contains all the information needed to generate all the objects of the business object hierachy.
The main problem was that the JSON file that I use as an input for the command line based RAP Generator class is nice from a technical point of view but it was not easy to handle by a developer who tries to use my tool for the first time.
The JSON file becomes however handy if you have to create multiple RAP business objects as we need them in RAP workshops or training courses.
To tackle the problem of having to explain how to handle the complex JSON file I decided to use our own tooling, namely RAP, to build a UI for my RAP Generator. ("eat your own dogfood ;-)).
The RAP Generator RAP BO is using a managed implementation with UUID based keys. While the root entity contains the header data of your RAP Generator project such as the implementation type being used (managed uuid, unmanaged semantic, ...) or the data source type being used (tabel, cds view, ...) or whether draft or not is to be supported the child entity contains the node hierachy of your RAP BO.
Special thanks for several discussions go to soerenschlegel who suggested to use an object oriented approach to get to a scalable architecture as we have it now.
A great thank you also to sebastianmichler the product owner of the XCO libraries for answering all my questions.
I added a click through guide on how to use the RAP Generator (on premise and in Steampunk) in the readme.md file of the GitHub repository:
When you want to create a table maintenance app with multi inline capability and that is automatically registered in the Business Configuration App of your Steampunk System you can select these as an option in the new Fiori Elements UI.
You find the technical documentation to the readme.md file of the GitHub repository.
Support for deletion of generated repository objects:The RAP Generator does currently not delete the objects that have been generated. When you choose "delete" only the project information will be deleted.
Support to copy projectsRight now you cannot yet copy an existing project but would have to enter all data from scratch.A workaround would be to use the JSON file and make adjustments there and start the RAP Generator via a commandline implementation
Where can I get the source code?
The source code for RAP Generator can be found on GitHub