For green field scenarios tables with UUID based key fields are very convenient since the RAP framework can easily generate unique values for the key fields so that there is no need to implement a numbering as you would need it when using a semantic key layout.
In the following the use of the RAP generator is shown.
-
In ADT open the repository object
ZDMO_UI_RAPG_PROJECT_O4
which is located in the packageZDMO_RAP_GENERATOR
(or inTEST_RAP_GENERATOR
) -
You can now start the Fiori Elements preview of the RAP Generator business object
- Select the entity Project
- Click on Preview
-
Press New Project
-
In the New Project dialogue you have to specify parameters for the RAP business object
Parameter Possible entries Explanation Datasource Type table, cds_view, abstract_entity Implementation Type managed, unmanaged Binding Type odata_v4_ui, odata_v4_api, odata_v2_ui or odata_v2_api Draft enabled Yes, No (1) Root Entity Name <EntityName> Here you should enter a meaningful name for your root entity (2) Data Source Name <Table Name> Here you can search (with type ahead support) for an object of the type that you have selected beforehand. (3) Package <Package Name> Here you can search (with type ahead support) for a package where the repository objects will be generated -
Enter the name of the root entity
-
Search for the data source ( start to search with the string UUID )
-
Search for the package (here: enter demo_of )
-
Press New Project
-
Based on the information that you have entered a new Project will be created that contains the information for the root entity as a starting point.
The object page will be opened and you now have to maintain information that the generator needs to know in order to generate the RAP business object.
Therefore you have to click on the entry of the root entity (here: SalesOrder) in the tab Entities
-
On this page you have to map the fields of your data source to their function in your RAP business object. That means you have to specify which field of your data source is used as an etag or which field is used to store the information who has created or who has changed the business object. The generator will try to suggest appropriate mappings based on information such as the underlying data elements and / or field names. Since the table that we are using in this example uses appropriate data elements for the administrative fields the generator was able to map all fields beside the semantic key automatically. When using tables with UUID based keys you have at least to specify one field that contains the semantic key. Since this cannot be retrieved automatically we have to navigate to the tab Map fields for meta data extension.
-
Here you can select the field that is used as the semantic key via a drop down box (in this case the field SALESORDER_ID).
-
You can now check the mapping of the field names and you can change this mapping if needed. Please note that the generator has also suggested names for the repository objects that will be generated. The proposals for these names are based on the VDM naming conventions that can be found in the SAP Online Help, e.g. "Z" & "R_" & "EntityName" & "TP" for the base restricted view and the behavior definition.
-
As a new feature the RAP Generator now allows you to maintain the values of the aliases for the field names of your entity. The generator will propose aliases by creating CamelCase values from the underlying ABAP field names by removing the underscores that are usually used for table field names. That means it will suggest SalesOrderID when the ABAP field name is called SALES_ORDER_ID.
When you are finished with your changes you have to press the Apply button to save your changes.
-
Now we can add a child entity to our RAP generator project. To do so select the root entity SalesOrder and then press the button Add Child based on tables.
-
In the dialogue that opens you have to specify the name of the child entity and you have to select the datasource that is used by the child entity. By selecting the datasource the generator can run determinations for the field mappings before the object page opens.
-
Since we are using tables with UUID based key fields as the data source we again have to provide a mapping which field of the table is used to store the semantic key field of our child entity.
In addition we have to specify a field in the child table that stores the value of the UUID based key field of the parent entity, the Parent UUID. Since the table that we are using just have one UUID based key field and one UUID based field that is not a key field the generator will suggest to use this field to store the parent UUID. -
Since we have added a child entity the fields for root entity specific repository objects such as the service definition are read only and only names for the child entity specific repository objects will be suggested.
If objects that have this name already exist in your system the generator will add a suffix (here "01") to the entity name. To avoid duplicates it is also possible to add a suffix or prefix to all repository object names on the header level of the rap generator project.
-
You now can save your probject. This will perform a final validation of your project. If this has passed successfully you can start the generation of the repository objects.
-
After having saved the project and after the final validations have passed you can now press the button "Generate repository objects". By pressing this button an application job will be scheduled that runs the RAP Generator class in a separate session. This workaround is necessary since the generation of repository objects will perform several commit work statements which are forbidden within the RAP interaction and save phase.
-
The status of the application job will be shown in the object page as well as on the list page.
-
When the application job has finished successfully the status will change and a ADT URL will be displayed that lets you navigate back to ADT by opening the root entity view that has been generated.
- If something went wrong you can check this in the log information
- The generated root entity view should look as follows: