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

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

Updates

  • 04.07.2021 – Since also the on premise version of the RAP Generator now comes with a Fiori Elements UI the use of the RAP Generator is basically the same on all three supported platforms (2020, 2021 and cloud).

 

In this blog I would like to provide a short click-trough so that you know how to generate a RAP BO using the RAP Generator in an SAP S/4HANA on premise system.

With the latest version the use of the RAP Generator in an on premise release is not much different from the use in SAP BTP ABAP Environment.

To avoid confusion I have deleted the old how to guide and I am refering you (for the time being to this how to guide instead).

How to use the RAP Generator (how to on github)

What is different on premise is the installation part, since on premise you have to use the report ZABAPGIT to upload the source to your SAP S/4HANA 2020 or SAP S/4HANA 2021 system.

In an on premise system it is also possible to use packages that support either the language version “standard” or “ABAP for Cloud Development” .

The boundary conditions for using the ABAP language version “ABAP for Cloud Development” have been discussed in detail by my colleague Thomas Schneider in his blog post Restricted ABAP and SAP S/4HANA On-Premise | SAP Blogs.

Make sure your system runs at least on top of SAP S/4HANA 2020 FSP1

The RAP Generator requires features and functions of the XCO libraries that have been delivered with on premise systems only as of SAP S/4HANA 2020 FSP1.

It uses in addition the generation of OData V4 services which are alos only supported as of SAP S/4HANA 2020 FSP1.

Steps after generation (2020)

After you have run the generator in an SAP S/4HANA 2020 system you have to perform some manual steps because the XCO libraties in 2020 do not support the generation of all artifacts and source code snippets that are supported in 2021 or in the cloud.

  1. Behavior definitionIn the behavior definition you have to change the the statement lock master and and add total etag LastChangedAt to it.
  2. Generate the behavior implementation classSince the RAP Generator cannot generate the behavior implementation class you have to perform this manual step yourself. You can however used code completion (Press Ctrl+1) to do this.
  3. Now you have to add the statement “use draft;” to the behavior projection
  4. Create and activate the Service BindingSince the RAP Generator cannot generate the Service Binding in SAP S/4 HANA 2020 you have to perform this step manually.Just right click on the Service Definition and select the option to generate the Service Binding from the context menu.

Result

As you can see, the RAP Generator has generated a RAP Business Object as it does it in SAP BTP ABAP Environment.

 

 

Assigned Tags

      27 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Syambabu Allu
      Syambabu Allu

      Hi Andre,

      Thanks for sharing.

      Thank you,

      Syam

      Author's profile photo Taranamjit Kaur Dhindsa
      Taranamjit Kaur Dhindsa

      Thanks Andre for sharing

      Author's profile photo Suzuki Kuniharu
      Suzuki Kuniharu

      Hi Andre,

      Thank you for sharing.

      An error occurred on line 166 of /DMO/CL_RAP_GENERATOR due to the lack of the method TRAVERSE.

      The environment is S / 4 2020 (SAP_BASIS 755 SP000).

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

      Hi Suzuki,

      sorry, but you are right. You have to have at least FSP1 of SAP S/4HANA 2020 installed.

      This is because the traverse method has not yet been delivered with SAP S/4HANA 2020 FSP00.

      Kind regards,

      Andre

      Author's profile photo Suzuki Kuniharu
      Suzuki Kuniharu

      Hi Andre,

      thank you for your answer.

      I understand that it is an environmental problem.

      Author's profile photo Martin Cavanagh
      Martin Cavanagh

      Hello,

      I'm really excited to try what you've ported.

      I created  package $ZRAP_GENERATOR and set the language version to ABAP for Cloud Development. I've tried to install it via ABAP Git - but when I want to import the repository I'm getting the following error.

      "Namespace /DMO/ does not exist. Create it in transaction SE03". How can I import Code in this namespace?
      Thanks in advance
      Martin
      Author's profile photo Martin Cavanagh
      Martin Cavanagh

      So I tried reading the sap and abapGit documentation...always a good place to start.

      Between the two documentations I was able to create the namespace /DMO/ but it still wasn't modifable.

      To make the namespace modifiable, I used SE03, set system change option. Again more documentation.

      Next problem - importing name space development, can't be done from a $package - so I need to replace $ZRAP_GENERATOR with ZRAP_GENERATOR. Done.

      Unfortunately I still can't import the code. I'm getting errors like these. Can anyone give me a hint?

      Object CLAS /DMO/CL_RAP_GENERATOR cannot be assigned to package ZRAP_GENERATOR Import of object /DMO/CL_RAP_GENERATOR failed

      Just a final thought - would it be possible to refactor these classes from /DMO/ to Z classes? That would make installation much simpler. I have in mind there might be some open source tools that can help here - although I can't name the project right now. I see that ABAP Git distributes its internal Z-Classes and interfaces as local classes/interfaces via abapMerge. Perhaps that could be a solution? Internally use /DMO/ classes and distribute as local classes?

      Author's profile photo Shai Sinai
      Shai Sinai

      Hi,

      I guess you should first create a package with /DMO/ namespace (e.g. /DMO/RAP_GENERATOR) and assign the class to it.

      Author's profile photo Martin Cavanagh
      Martin Cavanagh

      Hi,

       

      creating a package /DMO/RAP_GENERATOR did allow ABAPGit to import the project.

      I used the language version standard for this package.

      However there seem to be some restrictions on the usage of these classes outside of /DMO/.

      I get error messages like: Use of Class /DMO/CL_RAP_XCO_ON_PREM_LIB is not permitted.

      My current work around is the create the generator class zcl_test_rap_gen_002 in the /DMO/ package as /dmo/zcl_test_rap_gen_002 (okay - the z isn't really required anymore). Great so...the program activates!

      However the /dmo/cl_rap_gererator has syntax errors. In ABAP Git I changed the branch from master (head) to On-Premise-2020, and the syntax errors went away!

      Finally I'm able to generate RAP objects. Awesome.

      I was hoping to generate the RAP objects from the SAP Fiori Elements course - but there seem to be too many missing features in onPrem / and the class /dmo/cl_fe_travel_generator is much more complicated (many associations to other cds views, etc) than the sample here.

      I managed to complete the manual steps 1-3 - but when I try to create the service binding from the service definition it gives the me the errror "Usage fo ZRAP_INVENTORY_AF00 not permitted". This error message when away when I change the package back to a ABAP standard package

      Author's profile photo Kai Mintert
      Kai Mintert

      Andre Fischer will you update the OnPrem-Branch for S/4HANA 2021, so that we're able to use the Business Configuration Registration and the transportrequest-attribute ?

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

      Yes, that is planned.

      I even have created a SAP Fiori UI 😉

       

      Author's profile photo Kai Mintert
      Kai Mintert

      Great news, Andre Fischer !

      can you share a timeline with us? I can not wait to give it a try!

      Is there a chance to test it (beta version)?

      Author's profile photo Luis Becker
      Luis Becker

      Hi Andre Fischer

      " In principle it would also be possible to generate code in the language version Standard. But this would require to change the code of the RAP Generator class. But I did not want to make it to easy to leave the path of future proof cloud compatible development"

      This SAP obsession with cloud-based and reinventing the wheel all the time drives me crazy. Tried the RAP Generator, but with the cloud restriction can't use data elements. Without data elements we loose so many good features like automated search helps with UI5 Smartfields.

      Honestly, is SAP ever going to delete or rename BUKRS  or LIFNR? Of course not. So let people use it and make developers life easier. Otherwise they'll stick to old technologies like Table Maintenance Generator...

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

      Hi Luis,

      sorry that was meant as a (bad) joke.

      The new version of my generator simply takes the language version of the package that you provide.

      So it will generate code in abap language version "standard" if you want.

      We will not rename BUKRS or LIFNR.

      In SAP S/4HANA we have started to provide released API's for the various scenarios with released data elements.

      Kind regards,

      Andre

       

      Author's profile photo shavneet singh
      shavneet singh

      Hello Andre ,

      I have already posted my query at other places , but since this is a urgency to me, for some demo purposes , so i am posting i here  again for a faster reply.

      In our sandbox S/4 hana on premise System , Generate RAP objects is coming as disabled.

      My ADT version is
      Version: 2022-06 (4.24.0)
      Build id: 20220609-1112

      So i assume it is the latest.

      Any feedback, how to fix this ?

       

      Our system release is :

      S4HANA ON PREMISE 2021 01 (02/2022) FP sap.com SAP S/4HANA 2021

       

      So its not a cloud but Onpremise release.

      Does RAP generation objects through wizards does not works on onpremise system ?

       

      Regards ,

      Shavneet Singh

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

      Hi Shavneet,

      You wrote "I have already posted my query at other places". Here I only found two comments to an already answered question that you posted today.

      The likelyhood that somebody monitors comments to already answered questions is not that big.

      If you seek for faster answers I would suggest to publish your request as a separate answer next time.

      Nevertheless the answer for your question is (unfortunately) simply, namely that the ADT based generator (which is part of SAP standard delievery) is not supported for SAP S/4HANA 2021.

      This blog post refers to my open source project "The RAP Generator" which has a branch for 2021.

      SAP-samples/cloud-abap-rap at on-premise-2021 (github.com)

      Kind regards,

      Andre

       

      Author's profile photo shavneet singh
      shavneet singh

      Thanks Andre ,

      Thanks for the prompt reply.

      Surely i will make sure its a new request from next time.

      so ADT based generator is not supported for SAP S/4HANA 2021, So for which on premise release it is supported as of today  or it has to used as explained in this blog above ?

       

      Thanks and Regards ,

      Shavneet Singh

       

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

      It is planned to have a support for the ADT based generator as of SAP S/4HANA 2022. So this means later this year only.

      If you want to generate RAP objects in an SAP S/4HANA 2021 release you will have to use my open source based generator.

      Kind regards,

      Andre

       

      Author's profile photo shavneet singh
      shavneet singh

      Thank You so much

       

      Regards ,

      Shavneet Singh

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

      I just updated my blog post because this blog post did not yet referred to the new SAP Fiori Elements UI of my openSource RAP Generator.

      Hope it works for you.

      If not, post a question in the community.

      Author's profile photo shavneet singh
      shavneet singh

      Hello Andre ,

      Would you please help me with the Step 3 (Create an offline repository or an online repository with the package and with the URL of the RAP Generator repo )

      What URL we mean here  for both

      • SAP S/4HANA 2020 and
      • SAP S/4HANA 2021

      Links given under download and installation section , does not seems to work.

      And for on premise systems you have to use the appropriate branch on-premise-2020 https://github.com/SAP-samples/cloud-abap-rap/tree/On-Premise-2020 or on-premise-2021 https://github.com/SAP-samples/cloud-abap-rap/tree/On-Premise-2020

       

      Thanks and Best Regards ,

      Shavneet Singh

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

      The URL's seem to be case sensitive.

      These URL's should work.

      https://github.com/SAP-samples/cloud-abap-rap/tree/on-premise-2020
      https://github.com/SAP-samples/cloud-abap-rap/tree/on-premise-2021

      Author's profile photo shavneet singh
      shavneet singh

      Thank You Andre,

      Still while creating a online repo , it throws an error resource not found check url.Generator%20Error

      I know its getting extended , everything worked smoothly while i was in trial account. Still Everything is working fine in our development system. Its just that generator makes the life simpler , when we actually start developing the real apps.

      Thanks and Regards ,

      Shavneet Singh

      Generator Error

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

      You can enter the root URL

      https://github.com/SAP-samples/cloud-abap-rap/

      and then use the F4 help to select the correct branch.

      Author's profile photo shavneet singh
      shavneet singh

      Thank You,

      Works like a charm !!

       

      Cant wait for ADT generator for on premise releases, later this year

       

      Thanks again ,

      Regards ,

      Shavneet

      Author's profile photo shavneet singh
      shavneet singh

      Hello Andre ,

      Whenever I am trying to create RAP object with data source as Table , it gives me the error, table does not contains key field , even though it contains it.

      I had tried it using

      Customer table and airport table.

      This is my Airport table code :

      @EndUserText.label : 'Flight Reference Scenario: Airport'
      @AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
      @AbapCatalog.tableCategory : #TRANSPARENT
      @AbapCatalog.deliveryClass : #A
      @AbapCatalog.dataMaintenance : #RESTRICTED
      define table zairport {
      key client : abap.clnt not null;
      key airport_id : /dmo/airport_id not null;
      name : /dmo/airport_name;
      city : /dmo/city;
      country : land1;
      local_created_by : abp_creation_user;
      local_created_at : abp_creation_tstmpl;
      local_last_changed_by : abp_locinst_lastchange_user;
      local_last_changed_at : abp_locinst_lastchange_tstmpl;
      last_changed_at : abp_lastchange_tstmpl;

      }

      Key%20field%20Error

       

      What am I missing here ?

       

      Thanks and Regards ,

      Shavneet Singh

      Key field Error

      Author's profile photo shavneet singh
      shavneet singh

      Hello Andre ,

      Got the answer for my last query  , so table must contain a UUID field  , which was missing.

      Thanks ,

      Shavneet Singh