Skip to content

Latest commit

 

History

History
138 lines (69 loc) · 8.28 KB

how_to_managed_uuid.md

File metadata and controls

138 lines (69 loc) · 8.28 KB

How to generate a RAP BO using table with UUID based key fields

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 package ZDMO_RAP_GENERATOR (or in TEST_RAP_GENERATOR)

  • You can now start the Fiori Elements preview of the RAP Generator business object

    1. Select the entity Project
    2. Click on Preview

    Start FE preview

  • Press New Project

    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 project details

  • Enter the name of the root entity

    Choose root entity name

  • Search for the data source ( start to search with the string UUID )

    select datasource

  • Search for the package (here: enter demo_of )

    select package

  • 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

    root entity meta data

  • 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.

    map field for semantic key

  • 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).

    select field for object 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.

    other automatically mapped fields

  • 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.

proposed repository object names and field names

  • 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.

    add child entity

  • 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.

    add child entity 2

  • 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.

    maintain fields for child entity

  • 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.

other item specific fields

  • 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.

    save business object

  • 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.

    generate_repo_objects

  • The status of the application job will be shown in the object page as well as on the list page.

    Press Generate button

    in process

  • 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.

finished

  • If something went wrong you can check this in the log information

check log

navigate back

  • The generated root entity view should look as follows:

result