"
4 | SPDX-PackageDownloadLocation = "https://github.com/SAP-samples/cloud-abap-rap"
5 | SPDX-PackageComment = "The code in this project may include calls to APIs (“API Calls”) of\n SAP or third-party products or services developed outside of this project\n (“External Products”).\n “APIs” means application programming interfaces, as well as their respective\n specifications and implementing code that allows software to communicate with\n other software.\n API Calls to External Products are not licensed under the open source license\n that governs this project. The use of such API Calls and related External\n Products are subject to applicable additional agreements with the relevant\n provider of the External Products. In no event shall the open source license\n that governs this project grant any rights in or to any External Products,or\n alter, expand or supersede any terms of the applicable additional agreements.\n If you have a valid license agreement with SAP for the use of a particular SAP\n External Product, then you may make use of any API Calls included in this\n project’s code for that SAP External Product, subject to the terms of such\n license agreement. If you do not have a valid license agreement for the use of\n a particular SAP External Product, then you may only make use of any API Calls\n in this project for that SAP External Product for your internal, non-productive\n and non-commercial test and evaluation of such API Calls. Nothing herein grants\n you any rights to use or access any SAP External Product, or provide any third\n parties the right to use of access any SAP External Product, through API Calls."
6 |
7 | [[annotations]]
8 | path = "**"
9 | precedence = "aggregate"
10 | SPDX-FileCopyrightText = "2020 SAP SE or an SAP affiliate company"
11 | SPDX-License-Identifier = "Apache-2.0"
12 |
13 | [[annotations]]
14 | path = "src/**"
15 | precedence = "aggregate"
16 | SPDX-FileCopyrightText = "2020 SAP SE or an SAP affiliate company"
17 | SPDX-License-Identifier = "Apache-2.0"
18 |
19 | [[annotations]]
20 | path = "json_templates/**"
21 | precedence = "aggregate"
22 | SPDX-FileCopyrightText = "2020 SAP SE or an SAP affiliate company"
23 | SPDX-License-Identifier = "Apache-2.0"
24 |
--------------------------------------------------------------------------------
/how_to_managed_uuid.md:
--------------------------------------------------------------------------------
1 |
2 | # How to generate a RAP BO using table with UUID based key fields
3 |
4 | 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.
5 |
6 | In the following the use of the RAP generator is shown.
7 |
8 | - 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`)
9 |
10 | - You can now start the Fiori Elements preview of the RAP Generator business object
11 |
12 | 1. Select the entity **Project**
13 | 2. Click on **Preview**
14 |
15 | 
16 |
17 | - Press **New Project**
18 |
19 | 
20 |
21 | - In the **New Project** dialogue you have to specify parameters for the RAP business object
22 |
23 | | Parameter | Possible entries | Explanation |
24 | |--------------|-----------|------------|
25 | | Datasource Type | table, cds_view, abstract_entity | |
26 | | Implementation Type | managed, unmanaged | |
27 | | Binding Type | odata_v4_ui, odata_v4_api, odata_v2_ui or odata_v2_api | |
28 | | Draft enabled | Yes, No | |
29 | | (1) Root Entity Name | <EntityName> | Here you should enter a meaningful name for your root entity |
30 | | (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. |
31 | | (3) Package | <Package Name> | Here you can search (with type ahead support) for a package where the repository objects will be generated |
32 |
33 | 
34 |
35 | - Enter the name of the root entity
36 |
37 | 
38 |
39 | - Search for the data source ( start to search with the string *UUID* )
40 |
41 | 
42 |
43 | - Search for the package (here: enter *demo_of* )
44 |
45 | 
46 |
47 | - Press **New Project**
48 |
49 | - 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.
50 |
51 | 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.
52 |
53 | Therefore you have to click on the entry of the root entity (here: **SalesOrder**) in the tab **Entities**
54 |
55 | 
56 |
57 | - 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.
58 | The generator will try to suggest appropriate mappings based on information such as the underlying data elements and / or field names.
59 | 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.
60 | 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**.
61 |
62 | 
63 |
64 |
65 | - 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).
66 |
67 |
68 | 
69 |
70 | - 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.
71 |
72 | 
73 |
74 | - 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.
75 |
76 | When you are finished with your changes you have to press the **Apply** button to save your changes.
77 |
78 | 
79 |
80 | - 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**.
81 |
82 | 
83 |
84 | - 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.
85 |
86 | 
87 |
88 | - 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.
89 | 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.
90 |
91 | 
92 |
93 | - 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.
94 | If objects that have this name already exist in your system the generator will add a suffix (here "01") to the entity name.
95 | 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.
96 |
97 | 
98 |
99 | - 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.
100 |
101 | 
102 |
103 | - 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.
104 |
105 | 
106 |
107 |
108 |
109 | - The status of the application job will be shown in the object page as well as on the list page.
110 |
111 | 
112 |
113 |
114 | 
115 |
116 | - 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.
117 |
118 | 
119 |
120 | - If something went wrong you can check this in the log information
121 |
122 | 
123 |
124 |
125 | 
126 |
127 | - The generated root entity view should look as follows:
128 |
129 | 
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
--------------------------------------------------------------------------------
/images/100_Start_Fiori_Elements_Preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/100_Start_Fiori_Elements_Preview.png
--------------------------------------------------------------------------------
/images/110_New_rap_generator_project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/110_New_rap_generator_project.png
--------------------------------------------------------------------------------
/images/120_Set_root_entity_name_and_package.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/120_Set_root_entity_name_and_package.png
--------------------------------------------------------------------------------
/images/130_Enter_project_header_data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/130_Enter_project_header_data.png
--------------------------------------------------------------------------------
/images/140_implementation_types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/140_implementation_types.png
--------------------------------------------------------------------------------
/images/150_data_source_types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/150_data_source_types.png
--------------------------------------------------------------------------------
/images/160_binding_types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/160_binding_types.png
--------------------------------------------------------------------------------
/images/170_select_data_source.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/170_select_data_source.png
--------------------------------------------------------------------------------
/images/180_Press_return.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/180_Press_return.png
--------------------------------------------------------------------------------
/images/190_select_object_id.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/190_select_object_id.png
--------------------------------------------------------------------------------
/images/200_create_child.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/200_create_child.png
--------------------------------------------------------------------------------
/images/200_press_create.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/200_press_create.png
--------------------------------------------------------------------------------
/images/210_set_child_entity_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/210_set_child_entity_name.png
--------------------------------------------------------------------------------
/images/220_navigate_to_child_object_page.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/220_navigate_to_child_object_page.png
--------------------------------------------------------------------------------
/images/230_result_for_child.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/230_result_for_child.png
--------------------------------------------------------------------------------
/images/240_generate_objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/240_generate_objects.png
--------------------------------------------------------------------------------
/images/250_job_is_scheduled.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/250_job_is_scheduled.png
--------------------------------------------------------------------------------
/images/260_job_in_progress.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/260_job_in_progress.png
--------------------------------------------------------------------------------
/images/270_job_finished.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/270_job_finished.png
--------------------------------------------------------------------------------
/images/280_confirm.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/280_confirm.png
--------------------------------------------------------------------------------
/images/290_generated_objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/290_generated_objects.png
--------------------------------------------------------------------------------
/images/295_create_service_binding.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/295_create_service_binding.png
--------------------------------------------------------------------------------
/images/500_RAP_Generator_Overview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/500_RAP_Generator_Overview.png
--------------------------------------------------------------------------------
/images/510_RAP_Generator_UI.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images/510_RAP_Generator_UI.png
--------------------------------------------------------------------------------
/images/readme.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/images_how_to_uuid/100_start_FE_preview.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/100_start_FE_preview.png
--------------------------------------------------------------------------------
/images_how_to_uuid/110_new_project.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/110_new_project.png
--------------------------------------------------------------------------------
/images_how_to_uuid/120_the_new_project_dialog.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/120_the_new_project_dialog.png
--------------------------------------------------------------------------------
/images_how_to_uuid/130_root_entity_name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/130_root_entity_name.png
--------------------------------------------------------------------------------
/images_how_to_uuid/140_select_table_for_root_entity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/140_select_table_for_root_entity.png
--------------------------------------------------------------------------------
/images_how_to_uuid/150_select_package.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/150_select_package.png
--------------------------------------------------------------------------------
/images_how_to_uuid/200_select_root_entity_definition.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/200_select_root_entity_definition.png
--------------------------------------------------------------------------------
/images_how_to_uuid/300_map_field_for_object_id.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/300_map_field_for_object_id.png
--------------------------------------------------------------------------------
/images_how_to_uuid/310_select_object_id_field.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/310_select_object_id_field.png
--------------------------------------------------------------------------------
/images_how_to_uuid/320_show_other_mapped_fields.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/320_show_other_mapped_fields.png
--------------------------------------------------------------------------------
/images_how_to_uuid/330_show_proposed_repo_obj_names_and_field_names.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/330_show_proposed_repo_obj_names_and_field_names.png
--------------------------------------------------------------------------------
/images_how_to_uuid/400_add_child_entity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/400_add_child_entity.png
--------------------------------------------------------------------------------
/images_how_to_uuid/500_add_child_entity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/500_add_child_entity.png
--------------------------------------------------------------------------------
/images_how_to_uuid/520 edit child entity.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/520 edit child entity.png
--------------------------------------------------------------------------------
/images_how_to_uuid/530_maintain_fields_for_child.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/530_maintain_fields_for_child.png
--------------------------------------------------------------------------------
/images_how_to_uuid/540_rest_of_item_specifc_settings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/540_rest_of_item_specifc_settings.png
--------------------------------------------------------------------------------
/images_how_to_uuid/550_generate_repo_objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/550_generate_repo_objects.png
--------------------------------------------------------------------------------
/images_how_to_uuid/600_create_save_bo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/600_create_save_bo.png
--------------------------------------------------------------------------------
/images_how_to_uuid/600_generate_objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/600_generate_objects.png
--------------------------------------------------------------------------------
/images_how_to_uuid/610_in_process.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/610_in_process.png
--------------------------------------------------------------------------------
/images_how_to_uuid/620_finished.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/620_finished.png
--------------------------------------------------------------------------------
/images_how_to_uuid/650_check_log.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/650_check_log.png
--------------------------------------------------------------------------------
/images_how_to_uuid/700_navigate_back_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/700_navigate_back_1.png
--------------------------------------------------------------------------------
/images_how_to_uuid/800 Result.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/a77c63180847b95ab05631d84d24aead98d6b8ae/images_how_to_uuid/800 Result.png
--------------------------------------------------------------------------------
/images_how_to_uuid/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/json_schemas/RAPGenerator-schema-all.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json-schema.org/draft-04/schema#",
3 | "properties": {
4 | "$schema": {
5 | "type": "string"
6 | },
7 | "implementationtype": {
8 | "$ref": "#/definitions/implementationtype-schema",
9 | "default": "managed_uuid"
10 | },
11 | "namespace": {
12 | "type": "string",
13 | "minLength": 1,
14 | "default": "Z",
15 | "description": "The namespace will be added to the names of the repository objects of your RAP business object. The name of the CDS interface view and the behavior definition is generated using the following string template:\n|{ namespace }I_{ prefix }{ entityname }{ suffix }|."
16 | },
17 | "package": {
18 | "type": "string",
19 | "minLength": 1,
20 | "description": "Enter the name of an existing package which fits to the namespace that you have chosen."
21 | },
22 | "bindingType": {
23 | "$ref": "#/definitions/bindingtype-schema",
24 | "default": "odata_v4_ui"
25 | },
26 | "dataSourceType": {
27 | "$ref": "#/definitions/datasourceType-schema",
28 | "default": "table"
29 | },
30 | "draftenabled": {
31 | "type": "boolean",
32 | "default": true,
33 | "description": "When set to true the generator will genrate a draft table as well. If you want to determine the name of the draft table you can do so by setting the property draftTableName in each entity."
34 | },
35 | "prefix": {
36 | "type": "string",
37 | "description": "The prefix will be added to the names of the repository objects of your RAP business object. The name of the CDS interface view and the behavior definition is generated using the following string template:\n|{ namespace }I_{ prefix }{ entityname }{ suffix }|."
38 | },
39 | "suffix": {
40 | "type": "string",
41 | "description": "The suffix will be added to the names of the repository objects of your RAP business object. The name of the CDS interface view and the behavior definition is generated using the following string template:\n|{ namespace }I_{ prefix }{ entityname }{ suffix }|."
42 | },
43 | "transportrequest": {
44 | "type": "string",
45 | "description": "You can specifiy a modifiable transport request to be used. If no transport request is specified the generator will try to reuse an open transport request. If no transport request can be found a new transport request will be generated."
46 | },
47 | "multiInlineEdit": {
48 | "type": "boolean",
49 | "default": false,
50 | "description": "If set to true the generator will add a technical root entity with just one instance. This singleton instance then allows to leverage the multi inline edit capabilies of the SAP Fiori Elements object page. \nWhen set to true requires the following settings:\n\"bindingType\" : \"odata_v4_ui\"\n\"draftenabled\" : true"
51 | },
52 | "isCustomizingTable": {
53 | "type": "boolean",
54 | "default": false,
55 | "description": "Business configuration content can be recorded in customizing transport requests.\nWhen set to true requires the following settings:\n\"bindingType\" : \"odata_v4_ui\"\n\"draftenabled\" : true\n\"addBusinessConfigurationRegistration\" : true"
56 | },
57 | "addBusinessConfigurationRegistration": {
58 | "type": "boolean",
59 | "default": false,
60 | "description": "If set to true your business object will be listed in the Maintain Business Configurations App. Please note that the Maintain Business Configurations API only supports one level of sub nodes, i.e. your root entity can have associations to an arbitrary amount of entities but these sub entities cannot have associations to further sub entities. The data model must consist only of client-dependent tables.\n When set to true requires the following settings:\n\"bindingType\" : \"odata_v4_ui\"\n\"draftenabled\" : true"
61 | },
62 | "generateOnlyNodeHierachy": {
63 | "type": "boolean",
64 | "default": false,
65 | "description": "Parameter for testing purposes. If set to true the method generate_bo will not be executed."
66 | },
67 | "hierarchy": {
68 | "$ref": "#/definitions/rootNode-schema"
69 | }
70 | },
71 | "required": [
72 | "implementationtype",
73 | "namespace",
74 | "package",
75 | "bindingType",
76 | "dataSourceType",
77 | "draftenabled",
78 | "hierarchy"
79 | ],
80 | "additionalProperties": false,
81 | "definitions": {
82 | "rootNode-schema": {
83 | "properties": {
84 | "entityName": {
85 | "type": "string",
86 | "minLength": 1
87 | },
88 | "dataSource": {
89 | "type": "string",
90 | "minLength": 1
91 | },
92 | "objectId": {
93 | "type": "string",
94 | "minLength": 1
95 | },
96 | "uuid": {
97 | "type": "string",
98 | "default": "uuid",
99 | "minLength": 1
100 | },
101 | "etagMaster": {
102 | "type": "string",
103 | "default": "local_last_changed_at",
104 | "minLength": 1,
105 | "description": "Since eTags are required for each entity when consuming the RAP BO via OData this schema enforces you to specify the field of the datasource that contains a timestamp, a hash value, or any other versioning that precisely identifies the version of the data set."
106 | },
107 | "totalEtag": {
108 | "type": "string",
109 | "default": "last_changed_at",
110 | "minLength": 1,
111 | "description": "A total etag field is mandatory the root entity when using draft. It must be different from the field that is defined as an etag."
112 | },
113 | "createdBy": {
114 | "type": "string",
115 | "default": "created_by",
116 | "minLength": 1
117 | },
118 | "createdAt": {
119 | "type": "string",
120 | "default": "created_at",
121 | "minLength": 1
122 | },
123 | "lastChangedBy": {
124 | "type": "string",
125 | "default": "last_changed_by",
126 | "minLength": 1
127 | },
128 | "lastChangedAt": {
129 | "type": "string",
130 | "default": "last_changed_at",
131 | "minLength": 1
132 | },
133 | "localInstanceLastChangedAt": {
134 | "type": "string",
135 | "default": "local_last_changed_at",
136 | "minLength": 1
137 | },
138 | "draftTable": {
139 | "type": "string",
140 | "minLength": 1
141 | },
142 | "cdsInterfaceView": {
143 | "type": "string",
144 | "minLength": 1
145 | },
146 | "cdsProjectionView": {
147 | "type": "string",
148 | "minLength": 1
149 | },
150 | "metadataExtensionView": {
151 | "type": "string",
152 | "minLength": 1
153 | },
154 | "behaviorImplementationClass": {
155 | "type": "string",
156 | "minLength": 1
157 | },
158 | "serviceDefinition": {
159 | "type": "string",
160 | "minLength": 1
161 | },
162 | "serviceBinding": {
163 | "type": "string",
164 | "minLength": 1
165 | },
166 | "controlStructure": {
167 | "type": "string",
168 | "minLength": 1
169 | },
170 | "customQueryImplementationClass": {
171 | "type": "string",
172 | "minLength": 1
173 | },
174 | "keys": {
175 | "type": "array",
176 | "items": {
177 | "type": "string"
178 | }
179 | },
180 | "children": {
181 | "type": "array",
182 | "items": {
183 | "$ref": "#/definitions/childNode-schema"
184 | }
185 | }
186 | },
187 | "required": [
188 | "entityName",
189 | "dataSource",
190 | "objectId",
191 | "etagMaster"
192 | ],
193 | "additionalProperties": false
194 | },
195 | "childNode-schema": {
196 | "properties": {
197 | "entityName": {
198 | "type": "string",
199 | "minLength": 1
200 | },
201 | "dataSource": {
202 | "type": "string",
203 | "minLength": 1
204 | },
205 | "objectId": {
206 | "type": "string",
207 | "minLength": 1
208 | },
209 | "etagMaster": {
210 | "type": "string",
211 | "default": "local_last_changed_at",
212 | "minLength": 1,
213 | "description": "Since eTags are required for each entity when consuming the RAP BO via OData this schema enforces you to specify the field of the datasource that contains a timestamp, a hash value, or any other versioning that precisely identifies the version of the data set."
214 | },
215 | "uuid": {
216 | "type": "string",
217 | "default": "uuid",
218 | "minLength": 1
219 | },
220 | "parentUuid": {
221 | "type": "string",
222 | "default": "parent_uuid",
223 | "minLength": 1
224 | },
225 | "rootUuid": {
226 | "type": "string",
227 | "default": "root_uuid",
228 | "minLength": 1
229 | },
230 | "localInstanceLastChangedAt": {
231 | "type": "string",
232 | "default": "local_last_changed_at",
233 | "minLength": 1
234 | },
235 | "draftTable": {
236 | "type": "string",
237 | "minLength": 1
238 | },
239 | "cdsInterfaceView": {
240 | "type": "string",
241 | "minLength": 1
242 | },
243 | "cdsProjectionView": {
244 | "type": "string",
245 | "minLength": 1
246 | },
247 | "metadataExtensionView": {
248 | "type": "string",
249 | "minLength": 1
250 | },
251 | "keys": {
252 | "type": "array",
253 | "items": {
254 | "type": "string"
255 | }
256 | },
257 | "children": {
258 | "type": "array",
259 | "items": {
260 | "$ref": "#/definitions/childNode-schema"
261 | }
262 | }
263 | },
264 | "required": [
265 | "entityName",
266 | "dataSource",
267 | "objectId",
268 | "etagMaster"
269 | ],
270 | "additionalProperties": false
271 | },
272 | "implementationtype-schema": {
273 | "enum": [
274 | "managed_uuid",
275 | "managed_semantic",
276 | "unmanaged_semantic"
277 | ]
278 | },
279 | "bindingtype-schema": {
280 | "enum": [
281 | "odata_v4_ui",
282 | "odata_v2_ui",
283 | "odata_v4_web_api",
284 | "odata_v2_web_api"
285 | ]
286 | },
287 | "datasourceType-schema": {
288 | "enum": [
289 | "table",
290 | "cds_view",
291 | "abap_type",
292 | "structure"
293 | ]
294 | }
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-abstract-entities.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
3 | "namespace": "Z",
4 | "bindingType": "odata_v2_ui",
5 | "dataSourceType": "cds_view",
6 | "implementationtype": "unmanaged_semantic",
7 | "package": "ZAF_GWSAMPLE_BASIC",
8 | "draftenabled": false,
9 | "prefix": "AF_",
10 | "suffix": "_01",
11 | "hierarchy": {
12 | "entityName": "SalesOrder",
13 | "dataSource": "ZAF_SALESORDERSET",
14 | "objectId": "SalesOrderID",
15 | "etagMaster": "changedat",
16 | "children": [
17 | {
18 | "entityName": "SalesOrderItem",
19 | "dataSource": "ZAF_SALESORDERLINEITEMSET",
20 | "objectId": "ItemPosition",
21 | "etagMaster": "changedat"
22 | }
23 | ]
24 |
25 | }
26 | }
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-customizing-table.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
3 | "namespace": "Z",
4 | "package": "Z_###_YOUR_PACKAGE",
5 | "dataSourceType": "table",
6 | "multiInlineEdit": true,
7 | "isCustomizingTable": true,
8 | "addBusinessConfigurationRegistration": true,
9 | "implementationtype": "managed_semantic",
10 | "bindingType": "odata_v4_ui",
11 | "prefix": "AFME",
12 | "suffix": "_##",
13 | "draftenabled": true,
14 | "hierarchy": {
15 | "entityName": "Holiday",
16 | "dataSource": "/dmo/fcal_holi",
17 | "objectId": "holiday_id",
18 | "localInstanceLastChangedAt": "local_last_changed_at",
19 | "etagMaster": "local_last_changed_at",
20 | "children": [
21 | {
22 | "entityName": "HolidayText",
23 | "dataSource": "/dmo/fcal_holi_t",
24 | "objectId": "holiday_id",
25 | "localInstanceLastChangedAt": "local_last_changed_at",
26 | "etagMaster": "local_last_changed_at"
27 | }
28 | ]
29 | }
30 | }
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-managed-semantic.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
3 | "namespace":"Z",
4 | "dataSourceType": "table",
5 | "implementationtype": "managed_semantic",
6 | "bindingType": "odata_v4_ui",
7 | "package": "Z_###_YOUR_PACKAGE",
8 | "draftenabled":false,
9 | "prefix": "",
10 | "suffix": "",
11 | "hierarchy": {
12 | "entityName": "Travel",
13 | "dataSource": "/dmo/travel_m",
14 | "objectId": "travel_id",
15 | "localInstanceLastChangedAt": "last_changed_at",
16 | "etagMaster": "last_changed_at",
17 | "children": [
18 | {
19 | "entityName": "Booking",
20 | "dataSource": "/dmo/booking_m",
21 | "objectId": "booking_id",
22 | "localInstanceLastChangedAt": "last_changed_at",
23 | "etagMaster": "last_changed_at",
24 | "children": [
25 | {
26 | "entityName": "Supplements",
27 | "dataSource": "/dmo/booksuppl_m",
28 | "objectId": "booking_supplement_id",
29 | "localInstanceLastChangedAt": "last_changed_at",
30 | "etagMaster": "last_changed_at"
31 | }
32 | ]
33 | }
34 | ]
35 | }
36 |
37 |
38 | }
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-managed-uuid.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
3 | "namespace": "Z",
4 | "dataSourceType": "table",
5 | "implementationtype": "managed_uuid",
6 | "bindingType": "odata_v4_ui",
7 | "package": "Z_###_YOUR_PACKAGE",
8 | "draftenabled": true,
9 | "prefix": "",
10 | "suffix": "",
11 | "hierarchy": {
12 | "entityName": "Travel",
13 | "dataSource": "/dmo/a_travel_d",
14 | "objectId": "travel_id",
15 | "uuid": "travel_uuid",
16 | "etagMaster": "local_last_changed_at",
17 | "lastChangedAt": "last_changed_at",
18 | "lastChangedBy": "last_changed_by",
19 | "localInstanceLastChangedAt": "local_last_changed_at",
20 | "createdAt": "created_at",
21 | "createdBy": "created_by",
22 | "children": [
23 | {
24 | "entityName": "Booking",
25 | "dataSource": "/dmo/a_booking_d",
26 | "objectId": "booking_id",
27 | "uuid": "booking_uuid",
28 | "parentUuid": "parent_uuid",
29 | "etagMaster": "local_last_changed_at",
30 | "localInstanceLastChangedAt": "local_last_changed_at",
31 | "children": [
32 | {
33 | "entityName": "Supplements",
34 | "dataSource": "/dmo/a_bksuppl_d",
35 | "objectId": "booking_supplement_id",
36 | "uuid": "booksuppl_uuid",
37 | "parentUuid": "parent_uuid",
38 | "etagMaster": "local_last_changed_at",
39 | "localInstanceLastChangedAt": "local_last_changed_at"
40 |
41 | }
42 | ]
43 | }
44 | ]
45 | }
46 | }
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-unmanaged-abap_structure.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
3 | "namespace": "Z",
4 | "dataSourceType": "abap_type",
5 | "implementationtype": "unmanaged_semantic",
6 | "bindingType": "odata_v2_ui",
7 | "package": "Z_###_YOUR_PACKAGE",
8 | "draftenabled": false,
9 | "prefix": "",
10 | "suffix": "",
11 | "hierarchy": {
12 | "entityName": "FactoryCal",
13 | "dataSource": "cl_scal_api=>scals_factory_calendar",
14 | "objectId": "ident",
15 | "keys": [
16 | "ident",
17 | "spras"
18 | ]
19 | }
20 | }
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-unmanaged-ddic-structure.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
3 | "namespace": "Z",
4 | "dataSourceType": "structure",
5 | "implementationtype": "unmanaged_semantic",
6 | "bindingType": "odata_v2_ui",
7 | "package": "$TMP",
8 | "draftenabled":false,
9 | "prefix": "AF_",
10 | "suffix": "_01",
11 | "hierarchy": {
12 | "entityName": "Product",
13 | "dataSource": "BAPI_EPM_PRODUCT_HEADER",
14 | "objectId": "PRODUCT_ID",
15 | "etagMaster": "changed_at",
16 | "keys": ["Product_id"]
17 | }
18 | }
--------------------------------------------------------------------------------
/json_templates/RAPGenerator-sample-unmanaged-semantic.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./RAPGenerator-schema-all.json",
3 | "namespace": "Z",
4 | "dataSourceType": "table",
5 | "implementationtype": "unmanaged_semantic",
6 | "bindingType": "odata_v2_ui",
7 | "package": "Z_###_YOUR_PACKAGE",
8 | "draftenabled": false,
9 | "prefix": "",
10 | "suffix": "",
11 | "hierarchy": {
12 | "entityName": "Travel",
13 | "dataSource": "/dmo/travel",
14 | "objectId": "travel_id",
15 | "etagMaster": "lastchangedat",
16 | "children": [
17 | {
18 | "entityName": "Booking",
19 | "dataSource": "/dmo/booking",
20 | "objectId": "booking_id",
21 | "etagMaster": "lastchangedat",
22 | "children": [
23 | {
24 | "entityName": "Supplements",
25 | "dataSource": "/dmo/book_suppl",
26 | "objectId": "booking_supplement_id"
27 | }
28 | ]
29 | }
30 | ]
31 | }
32 | }
--------------------------------------------------------------------------------
/json_templates/README.md:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/optional_parameters.md:
--------------------------------------------------------------------------------
1 | # Optional parameters for workshops or other advanced scenarios
2 |
3 | The follwoing parameters have been implemented so that it is possible to create RAP business objects including a mapping (if CDS views are used as a data source) and including assocations and value helps.
4 |
5 | This is usefull if identical objects shall be created for trainings.
6 |
7 | The RAP Generator has and is used for SAP events such as the openSAP courses about RAP and SAP Fiori as well as for hands on sessions in SAP user group events or SAP TechEd.
8 |
9 | Here I got the following requirements:
10 |
11 | - Add additional fields to the generated CDS views (e.g. fields based on an association such as '_Travel.Customer' )
12 | - Change the field names of the generated artefacts (e.g. use the field name 'Customer' instead of 'PartnerID' which would be used if the field of the database table would be 'PARTNER_ID'.
13 |
14 | When using this parameters the json files will become more complicated. As a result the use of these parameters is not recommended if you want to develop a single RAP object. As said they will typically be used in workshops such as TechEd sessions, CodeJams or OpenSAP courses where there is the need to provide participants with complete RAP business objects as a starting point.
15 |
16 | **Please note**
17 | When creating JSON files in general and complicated JSON files in particular it is strongly recommended to use an appropriate JSON editor of your choice.
18 |
19 | I personally can recommend Visual Studio Code.
20 |
21 | #### mapping
22 | Using this parameter you can provide the mapping between the field names of the CDS view and the field names used by the legacy business logic if CDS views are used as a data source.
23 | When using tables as data sources this mapping is generated by the generator.
24 | When CDS views are used as a data source such a mapping has be created manually by the developer if it has not been set.
25 |
26 |
27 | {
28 | "implementationType": "unmanaged_semantic",
29 | "namespace": "Z",
30 | "suffix": "_####",
31 | "prefix": "RAP_",
32 | "package": "ZRAP_####",
33 | "datasourcetype": "cds_view",
34 | "hierarchy": {
35 | "entityName": "Travel",
36 | "dataSource": "/DMO/I_Travel_U",
37 | "objectId": "TravelID",
38 | "persistenttable": "/dmo/travel",
39 | "lastchangedat": "lastchangedat",
40 | "mapping": [
41 | {
42 | "dbtable_field": "TRAVEL_ID",
43 | "cds_view_field": "TravelID"
44 | },
45 | {
46 | "dbtable_field": "AGENCY_ID",
47 | "cds_view_field": "AgencyID"
48 | },
49 | {
50 | "dbtable_field": "CUSTOMER_ID",
51 | "cds_view_field": "CustomerID"
52 | },
53 | {
54 | "dbtable_field": "BEGIN_DATE",
55 | "cds_view_field": "BeginDate"
56 | },
57 | {
58 | "dbtable_field": "BOOKING_FEE",
59 | "cds_view_field": "BookingFee"
60 | },
61 | {
62 | "dbtable_field": "TOTAL_PRICE",
63 | "cds_view_field": "TotalPrice"
64 | },
65 | {
66 | "dbtable_field": "CURRENCY_CODE",
67 | "cds_view_field": "CurrencyCode"
68 | },
69 | {
70 | "dbtable_field": "DESCRIPTION",
71 | "cds_view_field": "Description"
72 | },
73 | {
74 | "dbtable_field": "STATUS",
75 | "cds_view_field": "Status"
76 | },
77 | {
78 | "dbtable_field": "LASTCHANGEDAT",
79 | "cds_view_field": "Lastchangedat"
80 | }
81 | ],
82 | "children": [
83 | {
84 | "entityName": "Booking",
85 | "dataSource": "/DMO/I_Booking_U",
86 | "objectId": "BookingID",
87 | "persistenttable": "/dmo/booking"
88 | }
89 | ]
90 | }
91 | }
92 |
93 |
94 | #### “associations” and “valuehelps”
95 | On node level it is also possible to set information to generate valuehelps and associations.
96 | These properties have been introduced mainly for setups in courses where one would like to be able that participants can generate a business object that contain exactly those associations and value help definitions that are required for the course.
97 | Though it might also be useful for other scenarios as well, you see that the complexity of your JSON file will grow and it might be simpler to code this manually in the CDS views that are generated by the RAP generator.
98 |
99 | ##### “associations”
100 |
101 | Associations is an array of objects where each object represents one association.
102 | An association needs the several properties
103 | - "name" is the name of the association and its name must start with an underscore '_'.
104 | - "target" is the name of the CDS view that is the target of your associaton
105 | - "cardinality" here you can enter one of the following values
106 | - "zero_to_one" [0..1]
107 | - "one" [1]
108 | - "zero_to_n" [0..n]
109 | - "one_to_n" [1..n]
110 | - "one_to_one" [1..1]
111 | - "conditions" is again an array of objects with two properties
112 | - "projectionField" this is the field ´"$projection.*AgencyID* = _Agency.AgencyID"´
113 | - "associationField" this is the field ´"$projection.AgencyID = _Agency.*AgencyID*"´
114 |
115 |
116 | ```
117 | "associations": [
118 | {
119 | "name": "_Agency",
120 | "target": "/DMO/I_Agency",
121 | "cardinality": "zero_to_n",
122 | "conditions": [
123 | {
124 | "projectionField": "AgencyID",
125 | "associationField": "AgencyID"
126 | }
127 | ]
128 | },
129 | {
130 | "name": "_Customer",
131 | "target": "/DMO/I_Customer",
132 | "cardinality": "zero_to_n",
133 | "conditions": [
134 | {
135 | "projectionField": "CustomerID",
136 | "associationField": "CustomerID"
137 | }
138 | ]
139 | }
140 | ]
141 |
142 | ```
143 |
144 | ##### valueHelps
145 |
146 | Valuehelps is also an array of objects where each object represents a value help. Each object may contain an addiitional array that contains the information for the additional binding.
147 |
148 | - "alias" is the alias of the value help used in the service definition.
149 | - "name" is the name of the CDS view used as a value help
150 | - "localelement" this denotes the field name in your projection view. Since this is already the CDS field name you have to be aware about the naming convertions that are used by the generator when it creates cds fields from the underlying ABAP field names, namely by using the conversion into camelCase notation.
151 |
152 |
153 | @Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Agency', element: 'AgencyID' } }]
154 | AgencyID,
155 |
156 |
157 | - "element" this is the field name in the CDS view that is used as a value help.
158 |
159 |
160 | @Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Agency', element: 'AgencyID' } }]
161 | AgencyID,
162 |
163 |
164 | - "additionalBinding" is again an array of objects with two properties
165 | - "localElement" these are the following fields
166 |
167 |
168 | @Consumption.valueHelpDefinition: [ {entity: {name: '/DMO/I_Flight', element: 'ConnectionID'},
169 | additionalBinding: [ { localElement: 'FlightDate', element: 'FlightDate'},
170 | { localElement: 'AirlineID', element: 'AirlineID'},
171 | { localElement: 'FlightPrice', element: 'Price', usage: #RESULT},
172 | { localElement: 'CurrencyCode', element: 'CurrencyCode' } ] } ]
173 |
174 |
175 | - "element" these are the following fields
176 |
177 |
178 | @Consumption.valueHelpDefinition: [ {entity: {name: '/DMO/I_Flight', element: 'ConnectionID'},
179 | additionalBinding: [ { localElement: 'FlightDate', element: 'FlightDate'},
180 | { localElement: 'AirlineID', element: 'AirlineID'},
181 | { localElement: 'FlightPrice', element: 'Price', usage: #RESULT},
182 | { localElement: 'CurrencyCode', element: 'CurrencyCode' } ] } ]
183 |
184 |
185 |
186 | - "usage" these are the following (optinonal) fields in a valuehelp
187 |
188 |
189 | @Consumption.valueHelpDefinition: [ {entity: {name: '/DMO/I_Flight', element: 'ConnectionID'},
190 | additionalBinding: [ { localElement: 'FlightDate', element: 'FlightDate'},
191 | { localElement: 'AirlineID', element: 'AirlineID'},
192 | { localElement: 'FlightPrice', element: 'Price', usage: #RESULT},
193 | { localElement: 'CurrencyCode', element: 'CurrencyCode' } ] } ]
194 |
195 |
196 |
197 | In order to generate a value help as mentioned above the following entry would have to be added to a node object, here the booking entity.
198 |
199 |
200 | "valueHelps": [
201 | {
202 | "alias": "Flight",
203 | "name": "/DMO/I_Flight",
204 | "localElement": "ConnectionID",
205 | "element": "ConnectionID",
206 | "additionalBinding": [
207 | {
208 | "localElement": "ConnectionID",
209 | "element": "ConnectionID"
210 | },
211 | {
212 | "localElement": "CarrierID",
213 | "element": "AirlineID"
214 | },
215 | {
216 | "localElement": "ConnectionID",
217 | "element": "ConnectionID",
218 | "usage": "RESULT"
219 | }
220 | ]
221 | },
222 | {
223 | "alias": "Currency",
224 | "name": "I_Currency",
225 | "localElement": "CurrencyCode",
226 | "element": "Currency"
227 | }
228 | ]
229 | }
230 | ]
231 |
232 |
233 |
234 | #### objectswithadditionalfields
235 |
236 | When using the RAP Generator in workshops it turned out that CDS views should also contain fields that are not part of the underlying data source such as fields that are retrieved via an association.
237 |
238 |
239 | _Customer.LastName as CustomerName,
240 |
241 |
242 | If additional fields are added this has to be done at various locations namely
243 |
244 | - cds_interface_view
245 | - cds_projection_view
246 | - draft_table
247 |
248 | One has to specifiy the field name, the alias and optionally the key word *localized*.
249 |
250 | So the JSON file must contain an array **objectswithadditionalfields**.
251 | For each object type an additional array called "additionalfields" has to be filled that contains the additional fields for each object.
252 |
253 | Please note that the field names for additional fields in the draft table must match the field name (or the alias name) of the field in the interface view.
254 |
255 |
256 |
257 | "objectswithadditionalfields": [
258 | {
259 | "object": "cds_projection_view",
260 | "additionalfields": [
261 | {
262 | "fieldname": "_HolidayTxt.HolidayDescription",
263 | "alias": "HolidayDescription",
264 | "localized": true
265 | },
266 | {
267 | "fieldname": "_DeprecationText.ConfignDeprecationCodeName",
268 | "alias": "DeprecationDescription",
269 | "localized": true
270 | },
271 | {
272 | "fieldname": "Criticality",
273 | "alias": "Criticality"
274 | }
275 | ]
276 | },
277 | {
278 | "object": "cds_interface_view",
279 | "additionalfields": [
280 | {
281 | "fieldname": "case overall_status when ' ' then 2 when 'N' then 2 when 'I' then 0 when 'P' then 0 when 'D' then 3 when 'X' then 1 else 0 end",
282 | "alias": "Criticality"
283 | }
284 | ]
285 | },
286 | {
287 | "object": "draft_table",
288 | "additionalfields": [
289 | {
290 | "fieldname": "Criticality",
291 | "builtintype": "int1"
292 | }
293 | ]
294 | }
295 | ],
296 |
297 |
298 |
--------------------------------------------------------------------------------
/readme_commandline.md:
--------------------------------------------------------------------------------
1 |
2 | **JSON schemas**
3 |
4 | In this folder [json_schemas](../../tree/master/json_schemas) JSON schemas are provided that can be used when using an appropriate JSON editor such as Visual Studio Code. Right now there is just one schema that contains all properties that can be used for the most common scenarios.
5 |
6 | It is planned to add additional schemas that make some or more fields and their values mandatory, e.g. a JSON schema for the scenario where a RAP BO shall be generated as a maintenace UI for a customizing table.
7 |
8 | **JSON templates**
9 |
10 | In this folder [json_templates](../../tree/master/json_templates) you will find sample JSON files for different scenarios that should help you to create your own json files that are needed as an input of the RAP Generator.
11 |
12 | ## Sample JSON file - managed scenario with semantic keys
13 |
14 | A simple sample of such a JSON file that would generate a managed business object based on the two tables **/dmo/a_travel_d** and **/dmo/a_booking_d** would look like follows.
15 |
16 |
17 | {
18 | "$schema": "https://raw.githubusercontent.com/SAP-samples/cloud-abap-rap/main/json_schemas/RAPGenerator-schema-all.json",
19 | "namespace": "Z",
20 | "dataSourceType": "table",
21 | "implementationtype": "managed_uuid",
22 | "bindingType": "odata_v4_ui",
23 | "package": "Z_###_YOUR_PACKAGE",
24 | "draftenabled": true,
25 | "prefix": "",
26 | "suffix": "",
27 | "hierarchy": {
28 | "entityName": "Travel",
29 | "dataSource": "/dmo/a_travel_d",
30 | "objectId": "travel_id",
31 | "uuid": "travel_uuid",
32 | "etagMaster": "local_last_changed_at",
33 | "lastChangedAt": "last_changed_at",
34 | "lastChangedBy": "last_changed_by",
35 | "localInstanceLastChangedAt": "local_last_changed_at",
36 | "createdAt": "created_at",
37 | "createdBy": "created_by",
38 | "children": [
39 | {
40 | "entityName": "Booking",
41 | "dataSource": "/dmo/a_booking_d",
42 | "objectId": "booking_id",
43 | "uuid": "booking_uuid",
44 | "parentUuid": "parent_uuid",
45 | "etagMaster": "local_last_changed_at",
46 | "localInstanceLastChangedAt": "local_last_changed_at",
47 | "children": [
48 | {
49 | "entityName": "Supplements",
50 | "dataSource": "/dmo/a_bksuppl_d",
51 | "objectId": "booking_supplement_id",
52 | "uuid": "booksuppl_uuid",
53 | "parentUuid": "parent_uuid",
54 | "etagMaster": "local_last_changed_at",
55 | "localInstanceLastChangedAt": "local_last_changed_at"
56 |
57 | }
58 | ]
59 | }
60 | ]
61 | }
62 | }
63 |
64 |
65 | ## Run the RAP Generator using a JSON input file
66 |
67 | This is a short description how the RAP Generator can be used.
68 |
69 | 1. Make sure you have set the following option **Wrap and escape text when pasting into string literal** for your ABAP source code editor in your ADT preferences as described in my blog [How to wrap long strings automatically in ADT](https://blogs.sap.com/2020/07/29/how-to-wrap-long-strings-automatically-in-adt/)
70 | 2. Create an class **zcl_rap_generator_console_####** in your package using the following code as a template. You can duplicate the class **`/dmo/cl_rap_generator_console`** for that.
71 |
72 |
73 | CLASS zcl_rap_generator_console_## DEFINITION
74 | PUBLIC
75 | INHERITING FROM cl_xco_cp_adt_simple_classrun
76 | FINAL
77 | CREATE PUBLIC .
78 |
79 | PUBLIC SECTION.
80 |
81 | PROTECTED SECTION.
82 | METHODS main REDEFINITION.
83 | METHODS get_json_string
84 | RETURNING VALUE(json_string) TYPE string.
85 | PRIVATE SECTION.
86 |
87 | ENDCLASS.
88 |
89 |
90 |
91 | CLASS zcl_rap_generator_console_## IMPLEMENTATION.
92 |
93 | METHOD main.
94 | TRY.
95 | DATA(json_string) = get_json_string( ).
96 | DATA(rap_generator) = /dmo/cl_rap_generator=>create_for_cloud_development( json_string ).
97 | "DATA(rap_generator) = /dmo/cl_rap_generator=>create_for_S4_2020_development( json_string ).
98 | DATA(framework_messages) = rap_generator->generate_bo( ).
99 | IF rap_generator->exception_occured( ).
100 | out->write( |Caution: Exception occured | ) .
101 | out->write( |Check repository objects of RAP BO { rap_generator->get_rap_bo_name( ) }.| ) .
102 | ELSE.
103 | out->write( |RAP BO { rap_generator->get_rap_bo_name( ) } generated successfully| ) .
104 | ENDIF.
105 | out->write( |Messages from framework:| ) .
106 | LOOP AT framework_messages INTO DATA(framework_message).
107 | out->write( framework_message ).
108 | ENDLOOP.
109 | CATCH /dmo/cx_rap_generator INTO DATA(rap_generator_exception).
110 | out->write( 'RAP Generator has raised the following exception:' ) .
111 | out->write( rap_generator_exception->get_text( ) ).
112 | ENDTRY.
113 | ENDMETHOD.
114 |
115 | METHOD get_json_string.
116 | json_string = '{ "Info" : "to be replaced with your JSON string" }' .
117 | ENDMETHOD.
118 |
119 | ENDCLASS.
120 |
121 |
122 | 4. Copy the json string shown above or one of the json strings for the different scenarios, that you can find in the folder [json_templates](../../tree/master/json_templates)
123 | between the two single quotes
124 | DATA(json_string) = ''.
125 | 5. Adapt the value for the parameter "package" : "Z_###_YOUR_PACKAGE"
126 | that is used as a placeholder so that it fits to the name of your package. You can choose to use a suffixand the suffix that you want to use.
127 | 6. Run the class using F9
128 |
129 | The class inherits from the class **cl_xco_cp_adt_simple_classrun** which is provided by the XCO framework. This class will catch all exceptions that are not chatched by the RAP Generator. The generator provides a list of warnings and messages that you will also see when you check the generated reposiotry objects in ADT. When an exception occurs that is not chatched by the generator the class will show the call stack as you are used to it by ADT.
130 |
131 | A much more detailed description (including screen shots and a video) can be found in my following blog posts:
132 |
133 | - [How to use the RAP Generator?](https://blogs.sap.com/2020/09/11/how-to-use-the-rap-generator/)
134 | - [How to use the RAP Generator in SAP S/4HANA on premise?](https://blogs.sap.com/2021/06/16/how-to-use-the-rap-generator-in-sap-s-4hana-on-premise/)
135 |
136 | The description of the technical details of this tool I have moved to this readme.md file instead.
137 |
138 | ## Supported scenarios
139 |
140 | The generator supports various implementation type ("implementationtype")
141 |
142 | - "managed_uuid"
143 | - "managed_semantic"
144 | - "unmanaged_semantic"
145 |
146 | in combination with the various supported data sources types ("dataSourceType").
147 |
148 | - "table"
149 | - "cds_view"
150 | - "structure"
151 | - "abap_type"
152 |
153 | Some of them also support draft.
154 |
155 |
156 | ## JSON file parameters
157 |
158 | The JSON file contains some mandatory properties that are needed for the generation of the repository objects.
159 | The node has a schema that contains an array called children, each of which are also node instances.
160 | This way we can model a root node including its child and grand child nodes in a way that is readable and reusable by the developer.
161 | Let’s start with the explanation of the (mandatory) properties of the business object itself.
162 |
163 | ### Mandatory parameters of the root node
164 |
165 | #### "implementationType"
166 |
167 | The generator currently supports three implementation types
168 | - managed_uuid
169 | - managed_semantic_key
170 | - unmanaged_semantic_key
171 |
172 | ##### "managed_uuid"
173 |
174 | If the implementation type **managed_uuid** is used, the generator will generate a managed business object that uses internal numbering. It is thus required that the key fields of the nodes and therefore also the key fields of the underlying tables are of type raw(16) (UUID).
175 |
176 |
177 | key client : abap.clnt not null;
178 | key uuid : sysuuid_x16 not null;
179 |
180 |
181 | ##### "managed_semantic" and "unmanaged_semantic"
182 |
183 | If one of the scenarios **"managed_semantic"** or **"unmanaged_semantic"** is used, the generator expects that there is a hierarchy of tables where the header table always contains all key fields of the item table.
184 |
185 | - Travel
186 |
187 | key client : abap.clnt not null;
188 | key travel_id : /dmo/travel_id not null;
189 |
190 | - Booking
191 |
192 | key client : abap.clnt not null;
193 | key travel_id : /dmo/travel_id not null;
194 | key booking_id : /dmo/booking_id not null;
195 |
196 | - BookingSupplements
197 |
198 | key client : abap.clnt not null;
199 | key travel_id : /dmo/travel_id not null;
200 | key booking_id : /dmo/booking_id not null;
201 | key booking_supplement_id : /dmo/booking_supplement_id not null;
202 |
203 |
204 | When the implementation type **managed_semantic** is chosen, the generator will generate a business object that uses a managed implementation that requires external numbering whereas **unmanaged_semantic** will generate a business object that uses an unmanaged implementation.
205 |
206 | #### “namespace”
207 | Here you have to specify the namespace of the repository objects. This would typically be the value **“Z”** or your own namespace **"/namespace/"** if you have registered one.
208 |
209 | #### "package"
210 | With the parameter **“package”** you have to provide the name of a package where all repository objects of your RAP business object will be generated in.
211 | Please note that in on premise systems the ABAP language version of the package must match static method being used for creating the RAP Generator object.
212 |
213 | #### "datasourcetype"
214 | The generator supports tables and CDS views as a data source.
215 | Please note that when starting from tables the generator will be able to also generate a mapping whereas a mapping has to be created manually by the developer when starting with CDS views as data sources. You have to provide one of the following values here:
216 | - table
217 | - cds_view
218 |
219 | ### Optional parameters of the root node
220 |
221 | #### "draftenabled"
222 |
223 | Using the boolean parameter **"draftenabled"** you can specify that the generated RAP object supports draft.
224 |
225 | New in the 2108 release is the feature that the generator will automatically generated appropriate draft tables whithout the need to specifiy the names of the draft tables beforehand. Please note that you can nevertheless specifiy the names of the draft tables for each node of the compostion tree using the parameter **"draftTable"**.
226 |
227 | #### "transportrequest"
228 |
229 | You can now provide the name of a transport request that shall be used for all objects that are being generated. If no transport request is specified the RAP Generator will first search for any modifiable transport that fits to the transport layer of the package which belongs to the developer.
230 |
231 | If not such transport is found a new transport request is being created.
232 |
233 | #### “suffix” and “prefix”
234 | These are optional parameters that can be used to tweak the names of the repository objects.
235 |
236 | The naming convention used by the generator follows the naming conventions propsed by the Virtual Data Model (VDM) used in SAP S/4 HANA.
237 | For example the name of a CDS interface view would be generated from the above mentioned properties as follows:
238 | `DATA(lv_name) = |{ namespace }I_{ prefix }{ entityname }{ suffix }|.`
239 | The name of the entity which is part of the repository object name is set by the property **“entityName”** on node level (see below).
240 |
241 | ### Mandatory properties of node objects
242 | For each node object must specify the following mandatory properties
243 |
244 | #### “entityName”
245 | Here you have to specify the name of your entity (e.g. “Travel” or “Booking”). The name of the entity becomes part of the names of the repository objects that will be generated and it is used as the name of associations (e.g. "_Travel").
246 | Please note, that the value of “entityName” must be unique within a business object.
247 |
248 | #### “dataSource” and “dataSourceType”
249 | The generator supports the data source types **“table”**, **"cds_view"** (views, view entities, abstract entities and custom entities), **structure** or **abap_type**
250 | The name of the data source is the name of the underlying table, the name of the underlying cds view, the name of the underlying DDIC structure or the name of the ABAP type. The latter uses the format (myclass_my_type_name=>mytype_name)
251 |
252 | #### “objectId”
253 | With **objectId** we denote a semantic key field that is part of the data source (table, cds view, structure or ABAP type).
254 | In our travel/booking scenario this would be the field **travel_id** for the Travel entity and **booking_id** for the Booking entity if the data source are tables and it would be **travelid** and **bookingid** if the CDS views of flight demo scenario are used.
255 | For managed scenarios the generator will generate a determination for each objectid.
256 | You also have to specify an **objectid** for semantic scenarios.
257 |
258 | #### “uuid”, “parent_uuid”, “root_uuid”
259 | In a managed scenario that uses keys of type **uuid** the tables of a child node must contain a field where the key of the parent entity is stored.
260 | Grandchild nodes and their children must in addition store the values of the key fields of the parent and the root entity.
261 | This is needed amongst others for the locking mechanism.
262 | The generator by default expects the following naming conventions for those fields
263 | - uuid
264 | - parent_uuid
265 | - root_uuid
266 |
267 | If you don’t want to use the same field names in all tables and prefer more descriptive names, such as
268 |
269 | key travel_uuid : sysuuid_x16 not null;
270 |
271 | and
272 |
273 | key booking_uuid : sysuuid_x16 not null;
274 | travel_uuid : sysuuid_x16 not null;
275 |
276 | you have to specify these field names in the definition of the node by providing values for `uuid` and `parentUuid` in the definition of the child entity and for `uuid` in the definition of the root entity.
277 |
278 |
279 | ...
280 | "node": {
281 | "entityName": "Travel",
282 | "dataSource": "zrap_atrav_0002",
283 | "dataSourceType" : "table",
284 | "objectId": "TRAVEL_ID",
285 | "uuid": "travel_uuid",
286 | "children": [
287 | {
288 | "entityName": "Booking",
289 | "dataSource": "zrap_abook_0002",
290 | "dataSourceType" : "table",
291 | "objectId": "BOOKING_ID",
292 | "uuid": "booking_uuid",
293 | "parentUuid": "travel_uuid"
294 | }
295 | ]
296 | }
297 | ...
298 |
299 |
300 | #### etag support
301 |
302 | OData services need to have etags in order to support optimistic locking. In addition the RAP framework supports to update automatically administrative fields that contain the information when an entity has been created, updated and by whom these actions have been performed. For this appropriate annoations have to be set in the CDS interface views.
303 | In addition to set these annotions in the CDS views it is required to specify which field plays the role of an etag in the behavior definition of your RAP business object. So we have to provide both informations:
304 | - fields that contain administrative information (for managed scenarios)
305 | - fields that act as etag for an entity ("etagMaster")
306 | - field that acts as the etag for the whole business object ("totalEtag") in case you are using a draft scenario
307 |
308 | ##### etagMaster
309 |
310 | Since eTags are required for each entity when consuming the RAP BO via OData this schema enforces you to specify the field of the datasource that contains a timestamp, a hash value, or any other versioning that precisely identifies the version of the data set.
311 |
312 | ##### totalEtag ( only needed for the root entity)
313 |
314 | A total etag field is mandatory for the root entity when using draft. It must be different from the field that is defined as the etagMaster.
315 |
316 | ##### "lastChangedAt", "lastChangedBy", "createdAt", "createdBy" and "localInstanceLastChangedAt"
317 |
318 | In a managed scenario it is required that the root entity provides fields to store administrative data when an entity was created and changed and by whom these actions have been performed.
319 |
320 | Again the generator assumes some default values for these field names, namely:
321 | - “last_changed_at",
322 | - "last_changed_by",
323 | - "created_at" and
324 | - "created_by"
325 |
326 |
327 | If the tables that you are using do not follow this naming convention it is possible to tell the generator about the actual field names by setting these optional properties.
328 |
329 | A good example is the table which is used in the Flight reference draft scenario where we need the following mapping
330 |
331 |
332 | "lastChangedAt": "last_changed_at",
333 | "lastChangedBy": "local_last_changed_by",
334 | "createdAt": "local_created_at",
335 | "createdBy": "local_created_by",
336 | "localInstanceLastChangedAt": "local_last_changed_at",
337 |
338 |
339 | In draft scenarios the fields used as etagMaster and totalEtag will be mapped as follows
340 |
341 | ### Optional parameters for node
342 |
343 | #### drafttable
344 |
345 | When you specify that a RAP business object shall support draft using the parameter **"draftenabled" : true** you can specifiy the name of the draft table that is being generated for each node using the following syntax
346 |
347 |
348 | "drafttable": "zd_book_0000",
349 |
350 |
351 | If no name is provided upfront the generator will generate a valid draft table name using the following string template:
352 |
353 | `to_upper( namespace ) && to_upper( prefix ) && to_upper( lv_entityname ) && hex_number && 'D' && to_upper( suffix ).`
354 |
355 | where the a hexadecimal number is calculated to get a unique repository object name that has not been used so far.
356 |
357 | # Changing the repository object names of the generated objects
358 |
359 | The names of the repository objects that are generated by the RAP Generator try to follow the naming conventions used in SAP S/4 HANA development and the naming conventions that you are used to when working with ADT.
360 |
361 | The generator uses string templates that contain the *namespace*, the *prefix* the *entityname* and the **suffix** together with naming conventions such as "I_" for interface views.
362 |
363 | **"draftTable"**
364 | |{ namespace }{ prefix }{ lv_entityname }{ unique_hex_number }D{ suffix }|.
365 | **"cdsInterfaceView"**
366 | |{ namespace }I_{ prefix }{ entityname }{ suffix }|.
367 | **"cdsProjectionView"**
368 | |{ namespace }C_{ prefix }{ entityname }{ suffix }|.
369 | **"metadataExtensionView"**
370 | |{ namespace }C_{ prefix }{ entityname }{ suffix }|.
371 | **"behaviorImplementationClass"**
372 | |{ namespace }BP_I_{ prefix }{ entityname }{ suffix }|.
373 | **"serviceDefinition"**
374 | |{ namespace }{ prefix }{ entityname }{ suffix }|.
375 | **"serviceBinding"**
376 | |{ namespace }{ binding }{ prefix }{ entityname }{ suffix }{ protocol_version }|.
377 | **"controlStructure"**
378 | |{ namespace }S{ prefix }{ entityname }_X{ suffix }|.
379 | **"customQueryImplementationClass"**
380 | |{ namespace }CL_CE_{ prefix }{ entityname }{ suffix }|.
381 |
382 | If you are not happy with these proposals you can override these settings by providing appropriate proposals in your JSON configuration file.
383 |
384 | So it would be technically possible to set the following names for the repository objects:
385 |
386 | "entityName": "Travel",
387 | "dataSource": "/dmo/a_travel_d",
388 | "objectId": "travel_id",
389 | "uuid": "travel_uuid",
390 | "etagMaster": "local_last_changed_at",
391 | "lastChangedAt": "last_changed_at",
392 | "lastChangedBy": "last_changed_by",
393 | "localInstanceLastChangedAt": "local_last_changed_at",
394 | "createdAt": "created_at",
395 | "createdBy": "created_by",
396 | "draftTable": "ZH34HJ4545",
397 | "cdsInterfaceView": "ZI_H34HJ4545",
398 | "cdsProjectionView": "ZP_H34HJ4545",
399 | "metadataExtensionView": "ZP_H34HJ4545",
400 | "behaviorImplementationClass": "ZCL_P_H34HJ4545",
401 | "serviceDefinition": "ZSD_H34HJ4545",
402 | "serviceBinding": "ZSD_H34HJ4545_O4",
403 | "controlStructure": "ZX_H34HJ454d",
404 | "customQueryImplementationClass": "ZCL_CE_H34HJ454d",
405 |
406 | Please note:
407 | There is no setting available for some repository object names such as the behavior definition since the name of the behavior definition must match the name of the CDS interface view of your root entity. The same is true for the name of the behvarior projection that must match the name of the projection view of your root entity.
408 |
409 |
410 | # Additional parameters for workshops and enhanced scenarios
411 |
412 | The RAP Generator has been used to generate repository objects for various hands-on sessions at SAP TechEd and in the openSAP courses that have been offered recently for the ABAP RESTful Programming Model and for SAP Fiori.
413 |
414 | Here additional requirements had to be met such as creating repository objects with additional fields that are not part of the data source or adding additional value helps and association upfront. These requirements meant to offer the option to add this additional information in the configuration JSON file as well.
415 |
416 | As a result the JSON files used in such scenarios become more complex and it would not be helpful to offer all these options to the developer that just wants to create a RAP business object as a starter object.
417 |
418 | So I have decided to provide the information about these advanced features that are quite valuable if you have the need for them in a separate readme file that you can find here:
419 |
420 | [Additional parameters for workshops](optional_parameters.md).
421 |
--------------------------------------------------------------------------------