Skip to Content
Technical Articles
Author's profile photo Andre Fischer

The RAP Generator


  • 12.01.2021 – Added a hint to the ADT based option to generated RAP business objects that is available as of 2111.
  • 16.06.2021 – published a version for the use in SAP S/4HANA 2020 on premise systems
  • 12.03.2021 – added new version for 2102 with full OData V4 and draft support
  • 19.05.2020 – added link to GitHub repo
  • 31.05.2020 – added the demo from my SAP Online Track talk [SOT114] The RAP generator
  • 05.06.2020 – changed the code of the RAP Generator so that it works again after HFC3 has been applied
  • 10.06.2020 – Published new version that offers the following
    • Object oriented design
      • BO node class
      • BO generator class
    • Support for multiple child, grandchild, … nodes
    • Unit tests
    • Exception class
  • 31.08.2020 – New version that offers the following
    • Structure of the BO can be defined in a JSON file
    • Support for CDS views as a data source
  • 11.09.2020 – Added a link to a how to a click through guide
  • 12.03.2021 – Updated information about the new 2102 version
  • 21.04.2021 – Added support to generate business configurations that are automatically registered for the Business Configuration Maintenance App and that record changes in transport requests
  • 24.08.2021 – Added support for multi inline edit, abstract entities and structures as datasources


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 /dmo/cl_rap_generator 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.

And I decided to make my development available on GitHub

With the 2102 release now the fourth version is available and can be tested on the trial systems.

Special thanks for several discussions go to Soeren Schlegel who suggested to use an object oriented approach to get to a scalable architecture as we have it now.

While the first version was only able to generate a simple header item scenario the second version became much more flexible and allowed to generate more complex business object composition trees.

With the third version I introduced to possibility to define the specifics of your business object composition tree in a JSON file.

This way you do not have to write lots of service specific coding and you can concentrate on the structure of your BO.

With the fourth version that I now made available based on the release 2102 I added support to generate RAP Business Objects that offer support for draft and OData V4.

I won’t explain the XCO framework as such in great detail because this will be done by my colleague Sebastian Michler who is the product owner of this library.

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.

The process is described in the SAP Online Help:

Example: RAP Business Service Generation

This wizard does however only support the generation of a RAP business object based on one table and will generate a managed business object. It does also not support the generation of unmanaged RAP business objects and does also not support CDS views or abstract entities as a datasource.

To match the prerequisites mentioned in Prerequisites  you have add administrative fields that use specific data_elements to the database table.

  created_by            : abp_creation_user;
  created_at            : abp_creation_tstmpl;
  last_changed_by       : abp_locinst_lastchange_user;
  last_changed_at       : abp_locinst_lastchange_tstmpl;
  local_last_changed_at : abp_lastchange_tstmpl;

Please also note that the client field of your table must also use the predefined ABAP type abap.clnt since the the datatype MANDT is not supported yet.

key client            : abap.clnt not null;


Click-through guide

When you just want to try it out in a trial system or in your own SAP BTP ABAP environment you find a click-through guide in my following blog

How to use the RAP Generator

When you want to try out the RAP Generator in an SAP S/4HANA System 2020 you have a look in my following blog post

How to use the RAP Generator in SAP S/4HANA on premise?

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 (it also works in trial system !), click here:

Generating SAP Fiori table maintenance dialogs using the RAP Generator | SAP Blogs

What’s new with 2108

  • Support for multi inline edit
  • Enhanced support for customizing tables
    • Enhanced support to transport your changes
    • Support for inline edit scenarios in the Business Configuration App
  • Support for abstract entities as a data source so that it is easier to create a RAP business objects on top of a Service Consumption Model
  • Support for DDIC structures as a data source
  • Draft tables do not have to be specified upfront but are generated automatically for you

What’s new with 2102

  • OData V4 services can be generated and activated
  • Value helps are added automatically for unit of measure and currency code fields
  • A transport request can be specified
  • Register the generated service binding (OData V4, draft enabled) via the mbc_cp_api API so that it shows up in the Fiori App Maintain Business Configurations.
  • Move to the /DMO/ namespace. This way the RAP Generator files cannot be modified in the trial systems
  • Additional fields that are not part of the data source (e.g. _Customer.LastName as CustomerName) can now be added in the JSON file upfront for the following repository objects
    • CDS interface view
    • CDS projection view
    • Draft table
  • The RAP Generator can also be used in on premise systems as of SAP S/4HANA 2020. I plan to write a separate blog about this since here we have to distinguish between using different ABAP language versions
  • The RAP Generator can be used to generate Business Configurations
    Generating and registering Business Configuration Objects with transport API support using the RAP Generator | SAP Blogs

What’s new with 2011

  • Support for draft enabled BO’s
  • Support for the following binding types
    • OData V4 – UI
    • OData V2- UI
    • OData V4 – Web API
    • OData V2 – Web API
  • The number of a transport request can be provided as an input parameter
  • Add a value help for fields that contain currency codes
  • Call of the RAP Generator as an API has been simplified (new class /dmo/rap_generator that only takes a json string as a parameter)

What’s new with 2008

  • Structure of the BO can be conveniently entered as a JSON file
  • Support for CDS views as a data source
  • Generation of service definition and service binding
  • Generation of control structures for unmanaged scenarios

I moved the technical documentation to the file of the GitHub repository.


  • there are currently no known limitations

What does it do?

Lets have a look at the famous flight sample and take the two tables that are part flight sample repository

  • /dmo/a_travel_d
  • /dmo/a_booking_d

I assume that you have created a package ZRAP_#### and within this package you have created a class ZCL_RAP_GENERATOR_CONSOLE_####.

On the trial systems I have installed the generator for your convenience, so no need to download the repo from GitHub on these systems.

You now only have to create a class ZCL_RAP_GENERATOR_CONSOLE_#### and a JSON file like the following

    "$schema": "",
    "namespace": "Z",
    "dataSourceType": "table",
    "implementationtype": "managed_uuid",
    "bindingType": "odata_v4_ui",
    "package": "Z_###_YOUR_PACKAGE",
    "draftenabled": true,
    "prefix": "",
    "suffix": "",
    "hierarchy": {
        "entityName": "Travel",
        "dataSource": "/dmo/a_travel_d",
        "objectId": "travel_id",
        "uuid": "travel_uuid",
        "etagMaster": "local_last_changed_at",
        "lastChangedAt": "last_changed_at",
        "lastChangedBy": "last_changed_by",
        "localInstanceLastChangedAt": "local_last_changed_at",
        "createdAt": "created_at",
        "createdBy": "created_by",
        "children": [
                "entityName": "Booking",
                "dataSource": "/dmo/a_booking_d",
                "objectId": "booking_id",
                "uuid": "booking_uuid",
                "parentUuid": "parent_uuid",
                "etagMaster": "local_last_changed_at",
                "localInstanceLastChangedAt": "local_last_changed_at"

Based on the two tables and the above mentioned JSON file the generator will create the following repository objects:

  • Draft  tables
  • CDS interface views
  • CDS projection views
  • Metadata Extensions
  • Behavior Definition
  • Behavior implementation classes
  • Service definition
  • Service binding

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.


How does it work?

Create a package

The generator needs a package where the ABAP artefacts that are going to be generated are stored. In the above mentioned demo I created a package ZRAP_7677.

Create the table(s) (for managed scenarios)

If you want to develop a managed scenario for a green field implementation you will want to create new objects. Here it is recommended to use tables with UUID based key fields since these can be changed such that they also support draft.

For a managed scenario where UUID’s are used as key fields for both, the header as well as the item table, the generator expects that the tables fulfill certain prerequisites:

The key field uuid must be a Universally Unique Identifier (UUID). This mandatory for a managed scenario where early numbering is used. That means where the ABAP framework automatically generates values for the key field when creating the data.

The last two fields of the header table

  • created_by
  • created_at
  • last_changed_by
  • last_changed_at
  • local_last_changed_at

are also mandatory in a managed scenario for a root object and also have to be specified in the parameters

  • etagMaster
  • totalEtag

The framework expects these type of fields (with appropriate annotations in the root CDS interface view) so that it is able to check when data has been created and changed.

For child nodes you have to specify a suitable field that can be used as an etag Master


Download the classes from Github (only needed for non-trial systems)

The tool consists out of several classes and a message class that you can download from Github. The package also contains three sample tables for a managed scenario with uuid based key fields.

Please note that for on premise versions you have to create and register the namespace /DMO/ as described here.

Call the generator using a console application

Simply ceate a class zcl_rap_generator_console_####.

Copy and paste the content of a json sample file (see above) or in the GitHub repository.

Be sure to have activated the settings in ADT that will wrap and escape the JSON string as I have described in this blog How to wrap long strings automatically in ADT.

Replace the placeholders #### so that they fit to the name of your package and the suffix if you want to use one for your objects.

When you press F9 the generator should simply tell you

RAP BO ZUI_RAP_SalesOrder_####_O4 generated successfully

There might be additional messages as the reminder to activate certain repository objects.

What happens if I did a typo?

If you for example forget to replace the placeholders an exception will be raised.

This exception is caught by our class since it inherits from the new class cl_xco_cp_adt_simple_classrun which is provided by the XCO framework and that shows the complete stack of the exception as you know it from ADT.



I plan to add the following features with an upcoming version of the RAP Generator

  • Generation of CDS views for domain fixed values
  • Gemeration of a class that allows to delete all generated repository objects
  • Support for ABAP types that have been defined via code

Where can I get the source code?

The source code for RAP Generator can be found on GitHub 


Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Ian Stubbings
      Ian Stubbings

      Great blog post Andre Fischer. This will make things substantionally easier when faced with creating several config tables for example.  I'll test it out in the next few days.

      I guess I'll have to edit my blog post after that as well 🙂



      Author's profile photo Paul Hardy
      Paul Hardy

      Can I ask what gets generated when you have a header and an item table e.g. sales order header and sales order item?

      The reason I ask is that every blog (often from different SAP employees) I read seems to have a different take on what CDS views need to be created in such a case. Sometimes one (or more) each for both tables, and one (or more) combined CDS view(s), sometimes just one combined view, or any combination of the above options.

      This is a wonderful step forward by the way. People are going to want to use this as a normal thing, not just for TechEd demos. It is just like the table control generator in DYNPROS or all the generated code in Web Dynpro or indeed the code that gets auto-generated when you want to call a BRF+ rule.

      In every case you do not want to do the exact same thing again and again, month after month, year after year, possibly doing it slightly differently each time and missing something, when your aim to to write the exact same code as you did before.

      Cheersy Cheers


      Author's profile photo Aleksandar Mijailovic
      Aleksandar Mijailovic

      I totally agree with you Paul!


      This is going to be very useful and time-saving!!


      Thanks Andre Fischer. for sharing.



      Author's profile photo Ravi Singh
      Ravi Singh

      Great stuff Andre. I tested it and works like a dream. Thanks !

      Author's profile photo Vijay Sharma
      Vijay Sharma

      Awesome!! Thanks for sharing Andre Fischer...

      Author's profile photo Denys van Kempen
      Denys van Kempen

      Thanks for publishing to GitHub (as mentioned).

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author 

      Author's profile photo Stefan Burghardt
      Stefan Burghardt

      Very interesting approach, thanks for sharing. Are there any prerequisites before creating the class zrap_cl_bo_generator?

      We are getting Errors since use of the sxco* elements is not permitted.

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      As I wrote the XCO framework is currently only available via a feature toggle. But we plan to make it available for all Steampunk system soon as well as for future on premise systems.

      Author's profile photo Mahesh Kumar Palavalli
      Mahesh Kumar Palavalli

      Nice one Andre Fischer. . Especially the XCO framework sounds very interesting. Hope to get my hands dirty on this soon 🙂

      Author's profile photo Swathi Vuddala
      Swathi Vuddala

      Great Blog! Thank you very much!

      Author's profile photo Shanthi Bhaskar
      Shanthi Bhaskar

      Nice blog Andrew, Never knew we can create a table in this way.

      Author's profile photo Michael Schliebner
      Michael Schliebner

      Just had a quick chat with my robots: They love the generator and XCO!

      Great piece of fuel for the steampunk and the head. Works like a charm.


      Author's profile photo Robert Eijpe
      Robert Eijpe

      Andre, Great stuff again and very useful. Thanks for sharing

      Author's profile photo Pavel Astashonok
      Pavel Astashonok

      If I get this in console:

      XCO Generation: PUT exception:
      "action | association | create | delete | determination | determine |
      draft | factory | field | function | internal | mapping | static |
      update | validation | }" expected, not ";".
      "action | association | create | delete | determination | determine |
      draft | factory | field | function | internal | mapping | static |
      update | validation | }" expected, not ";".
      "field | mapping | use | }" expected, not ";".
      "action | association | create | delete | determination | determine |
      draft | factory | field | function | internal | mapping | static |
      update | validation | }" expected, not ";".

      what has failed?

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      The generator has failed because it contained coding that I had to implement to provide a workaround for a tiny bug in the XCO framework.

      This bug was fixed with Hotfix Collection 3 that has now been applied to the trial systems.

      I have updated the code in GitHub.

      Just pull it again.

      It should work now.

      Best regards,



      Author's profile photo Javier Rodriguez Prieto
      Javier Rodriguez Prieto

      Hi Andre,

      I've just tested your rap code in my Abap trial account, and its brilliant.

      I've uploaded your code in the following package:


      Rap code in cloud

      and i've generated my own tables and its generated successfully:



      Author's profile photo Johann Fößleitner
      Johann Fößleitner

      Hi Andre Fischer.

      the RAP Generator is absolute brilliant. Today I tried it for the first time successfully in a ABAP Cloud Trial environment.

      I think, you spent a lot of days (or/and evenings?) to bring the RAP Generator alive.

      Thanks you very much!


      Author's profile photo Danny Van der Steen
      Danny Van der Steen



      Way to go thanks a lot for your time.





      Author's profile photo Sumit Kumar Kundu
      Sumit Kumar Kundu

      Can we use it now in S/4HANA on-prem 1909?

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      No  but in S/4HANA 2020.

      Author's profile photo Sumit Kumar Kundu
      Sumit Kumar Kundu

      Thanks Andre for your prompt reply. Some of my use cases are to create ‘Display only’ apps and web APIs SAP S/4HANA 1909. So as I understand it, prerequisite to use this generator is to create the tables first with parent-child relationships. I am thinking of :

      1. creating them in ABAP cloud environment in ADT
      2. generate the RAP objects using the RAP generator ABAP cloud
      3. copy the generated package through abapgit into S/4HANA on-prem.

      Is it possible or unmanaged scenario is not supported by RAP generator?

      Best regards,


      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      Hi Sumit,

      you are totally right. This is possible.

      You can create repository objects in a SAP Cloud Platform, ABAP Environment system and copy the generated objects via abapGit into S/4HANA 1909 on-prem. For this you can also use a trial system, but keep in mind that these systems are shared systems so the objects you are going to create are in principle visible for all trial users.

      For the use case you are interested in “unmanaged_semantic_key” the Generator only expects that there is a hierarchy of tables where the header table always contains all key fields of the item table. See also the file for more details

      Best regards,


      Author's profile photo Sumit Kumar Kundu
      Sumit Kumar Kundu

      Appreciate your detailed answer. Yes, I later realized that GitHub sample already contains sample JSON for unmanaged scenarios, should have peeked in there already.? Thanks for directing me to the right sample.

      Best regards,


      Author's profile photo Jagdish Chandrasekaran
      Jagdish Chandrasekaran

      Hi Andre,

      Really nice blog and RAP generator. I was trying out your RAP generator in my trial account. I found that it is generating ODATA V4 for the service definition. Is there a way to specify to choose the Odata version in the RAP generator? Perhaps an entry in the JSON?


      Kind regards,


      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      Hi Jagdish,

      You can do so using the new parameter "bindingtype".

      sorry, but I wasn't able to update the documentation so far.

      I just started to do so.

      Best regards



      Author's profile photo Jagdish Chandrasekaran
      Jagdish Chandrasekaran

      Hi Andre,

      Thank you for your swift reply 🙂 . I will try with this parameter to generate ODATA V2.

      Kind regards,


      Author's profile photo Attila Berencsi
      Attila Berencsi

      Hello Andre,

      thanks for sharing this, I love code generation, and espeially this tool. Here we see the real power of the environment and we have a knob to grab and use it finally. I also felt the same for years know, that I am doing the same time to time with transactional applications in Fiori.

      I have a question about the planned feature: Generation of CDS views for domain fixed values.

      Comparing the Trial Environment to S/4HANA, we do not have the CDS View I_DomainFixedValue in ABAP Trial.
      We do no have access even to table dd07t in Trial, so I was not able to create a reusable CDS View for domain texts myself.

      Does it mean we need to create custom tables for codes and texts in the Trial environmentl instead of using Domain fixed values? Maybe yo know this better, and how to overcome, due you planned this feature.

      Thank you, Attila


      Author's profile photo Philip Davy
      Philip Davy

      Andre Fischer.,

      Can we also create consumption view with XCO library ?

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author


      check out RAP BO Generation - SAP Help Portal 

      and there check method 

      add_ddls( )

      and use

       ->add_entity( ) 

      instead of

      ->add_view_entity( ).


      DATA(lo_view_entity) = lo_interface_specification->set_short_description( 'Vacation request'
      )->add_view_entity( ).
      Author's profile photo Pankaj Yadav
      Pankaj Yadav

      Hi Andre Fischer. ,

      I hope u r doing well.

      I am facing an issue while using RAP generator code in BTP, ABAP. Code has been loaded from git to BTP ABAP but it has syntax errors.

      I am connecting this repo: SAP-samples/cloud-abap-rap: This repository contains several examples how to develop with the ABAP RESTful Application Programming Model (RAP) in SAP BTP, ABAP environment. (

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      There are two branches available.

      I assume that you have used the on premise branch.

      cloud-abap-rap/#dmo#cl_rap_generator.clas.abap at On-Premise-2020 · SAP-samples/cloud-abap-rap (

      Only here you will find ABAP code that calls objects whose use is not permitted in the cloud.

      Please make sure that you have used this URL.

      and that you have used the "main" branch.

      Kind regards,




      Author's profile photo Pankaj Yadav
      Pankaj Yadav

      Thanks andre... you are right.. i am able to use it now.

      Author's profile photo Andre Fischer
      Andre Fischer
      Blog Post Author

      For any requirements you have that are not covered please raise an "issue" in the GitHub repo,
      I just have posted a new version of the readme and the source code of the 2108 at main · SAP-samples/cloud-abap-rap (

      Author's profile photo Pankaj Yadav
      Pankaj Yadav

      Sure Andre... i am able to use the latest code now.. thanks for your help and support to the community.

      Author's profile photo Chirag Poddar
      Chirag Poddar

      Hi Experts,


      Recently I was trying to use the RAP generator class /DMO/CL_FE_TRAVEL_GENERATOR. 


      I get the error as below. Not sure what the problem is. Can anyone suggest?


      PUT operation failed.
      Class name:
      Source position:
      Additional messages:
      DDLS ZI_FE_STAT_000698: Creation of CDS views is not allowed in the current environment.
      DDLS ZI_FE_CARR_000698: Creation of CDS views is not allowed in the current environment.
      DDLS ZI_FE_CONN_000698: Creation of CDS views is not allowed in the current environment.
      DDLS ZI_FE_FLIG_000698: Creation of CDS views is not allowed in the current environment.
      Stack trace:
      CX_XCO_RUNTIME_EXCEPTION constructor [method] Line: 15
      CX_XCO_GEN_PUT_EXCEPTION constructor [method] Line: 1
      CX_XCO_GEN_PUT_EXCEPTION for_ongoing_operation [method] Line: 3
      CL_XCO_GEN_O_PUT_ABSTRACT execute [method] Line: 8
      CL_XCO_GEN_DDLS_O_PUT if_xco_gen_ddls_o_put~execute [method] Line: 12
      CL_XCO_CP_GEN_DDLS_O_PUT_SCT if_xco_cp_gen_o_put_section~execute_operation [method] Line: 1
      CL_XCO_CP_GEN_D_WORK_SHOP put_section [method] Line: 1
      CL_XCO_CP_GEN_D_WORK_SHOP if_xco_cp_gen_d_work_shop~put_sections [method] Line: 4
      CL_XCO_CP_GEN_O_PUT if_xco_cp_gen_d_o_put~execute [method] Line: 4
      /DMO/CL_FE_TRAVEL_GENERATOR main [method] Line: 92
      CL_XCO_ADT_CR_SIMPLE_ACTION execute [method] Line: 1
      CL_XCO_DP_ACTION_ABSTRACT if_xco_dp_action~execute [method] Line: 8
      CL_XCO_ADT_CALL_CLASSRUN if_xco_rt_adt_call_classrun~dispatch [method] Line: 1
      CL_XCO_RT_ADT_CLASSRUN_ABSTR if_oo_adt_classrun~main [method] Line: 12
      CL_OO_ADT_RES_CLASSRUN execute_clas [method] Line: 118
      CL_OO_ADT_RES_CLASSRUN post [method] Line: 41
      CL_ADT_REST_RESOURCE if_rest_handler~handle [method] Line: 21
      CL_REST_ROUTER if_rest_handler~handle [method] Line: 59
      CL_REST_HTTP_HANDLER if_http_extension~handle_request [method] Line: 98
      CL_ADT_WB_RES_APP lif_request_handler~handle_request [method] Line: 18
      CL_ADT_WB_RES_APP handle_request [method] Line: 316
      CL_ADT_WB_RES_APP if_http_extension~handle_request [method] Line: 19
      CL_HTTP_SERVER execute_request [method] Line: 807
      SAPLHTTP_RUNTIME http_dispatch_request [function] Line: 1600
      SAPMHTTP %_http_start [module pbo] Line: 11





      Author's profile photo Dhruv GUPTA
      Dhruv GUPTA

      Thanks for the wonderful work..tried with own db tables on seamlessly with zero effort.