├── .reuse └── dep5 ├── LICENSE ├── LICENSES └── Apache-2.0.txt ├── README.md ├── exercises ├── ex0 │ ├── README.md │ ├── README_fast_track.md │ └── images │ │ ├── 00_00_0010.png │ │ ├── adt_open_object.png │ │ ├── find01.png │ │ ├── groupid01.png │ │ ├── package01.png │ │ ├── package02.png │ │ ├── package03.png │ │ ├── package04.png │ │ ├── package05.png │ │ ├── package06.png │ │ └── package07.png ├── ex1 │ ├── README.md │ ├── images │ │ ├── 01_01_0010.png │ │ ├── 01_02_0010.png │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── bookingtable01.png │ │ ├── bookingtable02.png │ │ ├── bookingtable03.png │ │ ├── bookingtable04.png │ │ ├── datamodel01.png │ │ ├── filltables01.png │ │ ├── filltables02.png │ │ ├── filltables03.png │ │ ├── traveltable01.png │ │ ├── traveltable02.png │ │ ├── traveltable03.png │ │ ├── traveltable04.png │ │ └── traveltable05.png │ └── sources │ │ ├── EX1_1_TABL_ZRAP_ATRAV.txt │ │ ├── EX1_2_TABL_ZRAP_ABOOK.txt │ │ └── EX1_3_CLAS_ZCL_GENERATE_DEMO_DATA.txt ├── ex10 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── auth01.png │ │ ├── auth02.png │ │ ├── auth03.png │ │ ├── auth04.png │ │ ├── auth05.png │ │ ├── auth06.png │ │ ├── auth07.png │ │ ├── auth08.png │ │ ├── auth09.png │ │ └── auth10.png │ └── sources │ │ ├── EX10_3_BDEF_ZI_RAP_TRAVEL.txt │ │ └── EX10_4_CLAS_ZBP_I_RAP_TRAVEL.txt ├── ex1_4 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── bookingprojection01.png │ │ ├── bookingprojection02.png │ │ ├── bookingtable01.png │ │ ├── bookingview01.png │ │ ├── datamodel01.png │ │ ├── doc.png │ │ ├── helperclass01.png │ │ ├── helperclass02.png │ │ ├── helperclass03.png │ │ ├── helperclass04.png │ │ ├── helperclass05.png │ │ ├── helperclass06.png │ │ ├── helperclass_00_new.png │ │ ├── helperclass_01_new.png │ │ ├── helperclass_02_new.png │ │ ├── helperclass_03_new.png │ │ ├── helperclass_04_new.png │ │ ├── helperclass_05_new.png │ │ ├── travelmetadata01.png │ │ ├── travelprojection01.png │ │ ├── travelprojection02.png │ │ ├── traveltable01.png │ │ └── travelview01.png │ └── sources │ │ ├── EX14_1_CLAS_ZCL_RAP_GEN_DATA_MODEL.txt │ │ ├── EX14_2_DDLS_ZC_RAP_TRAVEL.txt │ │ ├── EX14_3_DDLS_ZC_RAP_BOOKING.txt │ │ └── EX14_5_DDLX_ZC_RAP_TRAVEL.txt ├── ex2 │ ├── README.md │ ├── images │ │ ├── 02_01_0010.png │ │ ├── 02_02_0010.png │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── iactivate01.png │ │ ├── iactivate02.png │ │ ├── ibookingCDS01.png │ │ ├── ibookingCDS02.png │ │ ├── ibookingCDS03.png │ │ ├── itravelCDS01.png │ │ ├── itravelCDS02.png │ │ └── itravelCDS03.png │ └── sources │ │ ├── EX2_1_DDLS_ZI_RAP_TRAVEL.txt │ │ └── EX2_2_DDLS_ZI_RAP_BOOKING.txt ├── ex3 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── cactivate01.png │ │ ├── cbookingCDS01.png │ │ ├── cbookingCDS02.png │ │ ├── cbookingCDS03.png │ │ ├── ctravelCDS01.png │ │ ├── ctravelCDS02.png │ │ └── ctravelCDS03.png │ └── sources │ │ ├── EX3_1_DDLS_ZC_RAP_TRAVEL.txt │ │ └── EX3_2_DDLS_ZC_RAP_BOOKING.txt ├── ex4 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── bookingmde01.png │ │ ├── bookingmde02.png │ │ ├── bookingmde03.png │ │ ├── travelmde01.png │ │ ├── travelmde02.png │ │ └── travelmde03.png │ └── sources │ │ ├── EX4_1_DDLX_ZC_RAP_TRAVEL.txt │ │ └── EX4_2_DDLX_ZC_RAP_BOOKING.txt ├── ex5 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── preview01.png │ │ ├── preview02.png │ │ ├── servicebinding01.png │ │ ├── servicebinding02.png │ │ ├── servicebinding03.png │ │ ├── servicebinding04.png │ │ ├── servicebinding05.png │ │ ├── servicedefinition01.png │ │ ├── servicedefinition02.png │ │ └── servicedefinition03.png │ └── sources │ │ └── EX5_1_SRVD_ZUI_RAP_TRAVEL.txt ├── ex6 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── basebdef01.png │ │ ├── basebdef02.png │ │ ├── basebdef03.png │ │ ├── basebdef04.png │ │ ├── basebdef05.png │ │ ├── basebdef06.png │ │ ├── basebdef07.png │ │ ├── basebdef08.png │ │ ├── basebdef09.png │ │ ├── basebdef10.png │ │ ├── basebdef11.png │ │ ├── basebdef12.png │ │ ├── preview01.png │ │ ├── preview02.png │ │ ├── projectionbdef01.png │ │ ├── projectionbdef02.png │ │ └── projectionbdef03.png │ └── sources │ │ ├── EX6_1_BDEF_ZI_RAP_TRAVEL.txt │ │ └── EX6_2_BDEF_ZC_RAP_TRAVEL.txt ├── ex7 │ ├── README.md │ ├── images │ │ ├── action01.png │ │ ├── action02.png │ │ ├── action03.png │ │ ├── action04.png │ │ ├── action05.png │ │ ├── action05ft.png │ │ ├── action06.png │ │ ├── action07.png │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ └── adt_save_all.png │ └── sources │ │ ├── EX7_1_BDEF_ZI_RAP_TRAVEL.txt │ │ ├── EX7_1_CLAS_ZBP_I_RAP_TRAVEL.txt │ │ ├── EX7_2_BDEF_ZC_RAP_TRAVEL.txt │ │ └── EX7_3_DDLX_ZC_RAP_TRAVEL.txt ├── ex8 │ ├── README.md │ ├── images │ │ ├── adt_activate.png │ │ ├── adt_activate_all.png │ │ ├── adt_open_object.png │ │ ├── adt_save.png │ │ ├── adt_save_all.png │ │ ├── determination01.png │ │ ├── determination02.png │ │ └── determination03.png │ └── sources │ │ ├── EX8_1_BDEF_ZI_RAP_TRAVEL.txt │ │ ├── EX8_1_CLAS_ZBP_I_RAP_BOOKING.txt │ │ └── EX8_1_CLAS_ZBP_I_RAP_TRAVEL.txt └── ex9 │ ├── README.md │ ├── images │ ├── adt_activate.png │ ├── adt_activate_all.png │ ├── adt_open_object.png │ ├── adt_save.png │ ├── adt_save_all.png │ ├── validation01.png │ ├── validation02.png │ ├── validation03.png │ ├── validation04.png │ ├── validation05.png │ ├── validation06.png │ ├── validation07.png │ ├── validation08.png │ ├── validation09.png │ ├── validation10.png │ └── validation11.png │ └── sources │ ├── EX9_2_CLAS_ZCM_RAP.txt │ ├── EX9_3_CLAS_ZBP_I_RAP_TRAVEL.txt │ └── EX9_4_BDEF_ZI_RAP_TRAVEL.txt ├── images └── app_overview.png └── presentation └── DEV260.pdf /.reuse/dep5: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: teched2020-DEV260 3 | Upstream-Contact: () 4 | Source: https://github.com/sap-samples/teched2020-DEV260 5 | Disclaimer: The code in this project may include calls to APIs (“API Calls”) of 6 | SAP or third-party products or services developed outside of this project 7 | (“External Products”). 8 | “APIs” means application programming interfaces, as well as their respective 9 | specifications and implementing code that allows software to communicate with 10 | other software. 11 | API Calls to External Products are not licensed under the open source license 12 | that governs this project. The use of such API Calls and related External 13 | Products are subject to applicable additional agreements with the relevant 14 | provider of the External Products. In no event shall the open source license 15 | that governs this project grant any rights in or to any External Products,or 16 | alter, expand or supersede any terms of the applicable additional agreements. 17 | If you have a valid license agreement with SAP for the use of a particular SAP 18 | External Product, then you may make use of any API Calls included in this 19 | project’s code for that SAP External Product, subject to the terms of such 20 | license agreement. If you do not have a valid license agreement for the use of 21 | a particular SAP External Product, then you may only make use of any API Calls 22 | in this project for that SAP External Product for your internal, non-productive 23 | and non-commercial test and evaluation of such API Calls. Nothing herein grants 24 | you any rights to use or access any SAP External Product, or provide any third 25 | parties the right to use of access any SAP External Product, through API Calls. 26 | 27 | Files: * 28 | Copyright: 2020 SAP SE or an SAP affiliate company and teched2020-DEV260 contributors 29 | License: Apache-2.0 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEV260 - Build SAP Fiori Apps with the ABAP RESTful Application Programming Model 2 | 3 | [![REUSE status](https://api.reuse.software/badge/github.com/SAP-samples/teched2020-DEV260)](https://api.reuse.software/info/github.com/SAP-samples/teched2020-DEV260) 4 | 5 | ## Description 6 | 7 | This repository contains the material for the SAP TechEd 2020 session called **DEV260** - **Build SAP Fiori Apps with the ABAP RESTful Application Programming Model**. 8 | 9 | ## Disclaimer 10 | 11 | > Note that this workshop was first offered in 2020; consequently, all its assets were created before the branding changes related to SAP technology were announced in January 2021. For example, SAP Cloud Platform, ABAP environment has been renamed to SAP Business Technology Platform (BTP), ABAP environment. 12 | 13 | ## Overview 14 | 15 | In this session we will guide you to build a draft-enabled transactional SAP Fiori Elements Application based on the ABAP RESTful Application Programming Model (in short RAP). The underlying OData service will be exposed using the OData V4 protocol, and the resulting app will look like this: 16 | 17 | ![APP Overview](images/app_overview.png) 18 | 19 | The Fiori app you are going to implement is based on the RAP Flight Reference Scenario. To set the business context the scenario is the following: The department responsible for managing worldwide Travels for multiple Agencies is requesting you to build a new Fiori app with draft capabilities for processing (i.e. creating, updating and deleting) Travels. 20 | 21 | Presentation: [DEV260 - Build SAP Fiori Apps with the ABAP RESTful Application Programming Model](presentation/DEV260.pdf) 22 | 23 | Further reading: [Developing Transactional Apps with Draft Capabilities](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/71ba2bec1d0d4f22bc344bba6b569f2e.html) 24 | 25 | ## Requirements 26 | 27 | The requirements to follow the exercises in this repository are: 28 | 29 | * You have installed the _latest_ ABAP Development Tools (ADT), see [ABAP Development Tools](https://tools.hana.ondemand.com/#abap) 30 | * You have created a SAP Cloud Platform ABAP Environment Trial Account and connected your ADT to the Trial Account using a ABAP Cloud Project, see [Create an SAP Cloud Platform ABAP Environment Trial User](https://developers.sap.com/tutorials/abap-environment-trial-onboarding.html) 31 | 32 | ## Exercises 33 | 34 | Follow these steps to build a draft-enabled transactional Fiori app with RAP. 35 | 36 | The **Fast Track** uses a tool to generate the artefacts of exercises 1-4. In the **Regular Track** you create them manually, step-by-step. 37 | 38 | | Regular Track | Fast Track | 39 | | ------------- | ---------- | 40 | | [Getting Started - Regular Track](exercises/ex0/) | [Getting Started - Fast Track](exercises/ex0/README_fast_track.md) | 41 | | [Exercise 1 - Database Tables](exercises/ex1/) | [Exercises 1-4 - Generate Data Model](exercises/ex1_4/#readme) | 42 | | [Exercise 2 - Core Data Services (CDS) Data Model](exercises/ex2/) | 43 | | [Exercise 3 - CDS Data Model Projection](exercises/ex3/) | 44 | | [Exercise 4 - Metadata Extensions](exercises/ex4/) | 45 | | [Exercise 5 - Business Service](exercises/ex5/) | [Exercise 5 - Business Service](exercises/ex5/) | 46 | | [Exercise 6 - Business Object Behavior](exercises/ex6/) | [Exercise 6 - Business Object Behavior](exercises/ex6/) | 47 | | [Exercise 7 - Actions](exercises/ex7/) | [Exercise 7 - Actions](exercises/ex7/) | 48 | | [Exercise 8 - Determinations](exercises/ex8/) | [Exercise 8 - Determinations](exercises/ex8/) | 49 | | [Exercise 9 - Validations](exercises/ex9/) | [Exercise 9 - Validations](exercises/ex9/) | 50 | | [Exercise 10 - Authorizations (optional)](exercises/ex10/) | [Exercise 10 - Authorizations (optional)](exercises/ex10/) | 51 | 52 | ## How to obtain support 53 | 54 | Support for the content in this repository is available during the actual time of the online session for which this content has been designed. Otherwise, you may request support via the [Issues](../../issues) tab. 55 | 56 | ## License 57 | Copyright (c) 2020 SAP SE or an SAP affiliate company. All rights reserved. This file is licensed under the Apache Software License, version 2.0 except as noted otherwise in the [LICENSE](LICENSES/Apache-2.0.txt) file. 58 | -------------------------------------------------------------------------------- /exercises/ex0/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started - Regular Track 2 | 3 | ## Introduction 4 | You've already created an ABAP Trial Account and connected your ADT to it using a ABAP Cloud Project as described in the [Requirements](../../../../#requirements) section. 5 | 6 | In this exercise you will define a group ID that you will need in the course of this workshop to uniquely identify your repository artefacts and separate them from those of other users conducting the same workshop on this system. 7 | 8 | Furthermore you will create a development package that will contain all your artefacts. 9 | 10 | Please note that ADT dialogs and views as well as Fiori UIs may change in upcoming releases. 11 | 12 | > **Hints and Tips** 13 | > Speed up typing by making use of the Code Completion feature (shortcut Ctrl+Space) and the prepared code snippets provided. 14 | > You can easily open an object with the shortcut *Ctrl+Shift+A*, format your source code using the Pretty Printer feature *Shift+F1* and toggle the fullscreen of the editor using the shortcut *Ctrl+M*. 15 | > 16 | > An overview of ADT shortcuts can be found here: [Useful ADT Shortcuts](https://blogs.sap.com/2013/11/21/useful-keyboard-shortcuts-for-abap-in-eclipse/) 17 | 18 | ## Group ID 19 | 20 | As the ABAP Trial environment is used by many people, we've defined a naming pattern for each artefact you are going to create to make sure it doesn't conflict with other ones. For this you'll find the placeholder **`####`** used in object names that must be replaced with the group ID of your choice during the exercises. The group ID can contain a maximum of 4 characters (numbers and letters). 21 | 22 | You can check for **already used group IDs** by choosing Open ABAP Development Object ![open_object_icon](images/adt_open_object.png) (Ctrl+Shift+A) and searching for e.g. `zrap_travel_`. This lists all artefacts fitting that pattern. Try to add e.g. your initials, followed by a number to verify nobody else is already using this group ID. 23 | 24 | ![Group id 01](images/groupid01.png) 25 | 26 | *No results* means this group ID seems to be available. 27 | 28 | Once you've found an available group ID, choose **Cancel**. 29 | 30 | > **Hints and Tips** 31 | > The screenshots in this document have been taken using group ID `1234` and system `X11`. We **don't recommend** using group ID `1234`. 32 | 33 | ## Find/Replace 34 | 35 | In the course of these exercises you will frequently see the task to "_replace the placeholder `####` with your group ID_". For this it's recommended to make use of the **Find/Replace** feature of the Eclipse Editor. It can be opened either via the menu (**_Edit -> Find/Replace..._**) or via **Ctrl+F**. 36 | 37 | ![find and replace](images/find01.png) 38 | 39 | Choosing **Replace All** allows you to replace all ocurrences of `####` with your group ID. 40 | 41 | ## Create an ABAP package for your repository objects 42 | 43 | 1. In the Project Explorer, expand your ABAP Cloud project, right-click on **Project** and choose **_New > ABAP Package_** from the context menu. 44 | 45 | ![create ABAP package 01](images/package01.png) 46 | 47 | 2. Maintain `ZRAP_TRAVEL_####` (where `####` is your chosen group ID) as **Name** and a meaningful **Description** (e.g. _`DEV260 - RAP Exercises`_). Make sure the Superpackage is set to `ZLOCAL`. Choose **Next** to continue. 48 | 49 | ![create ABAP package 02](images/package02.png) 50 | 51 | 3. Assign a transport request. For that, either select an existing transport request – if available – or choose **Create a new request**, enter a meaningful **Request Description** and choose **Finish**. 52 | 53 | ![create ABAP package 03](images/package03.png) 54 | 55 | The editor shows the created package. 56 | 57 | ![create ABAP package 04](images/package04.png) 58 | 59 | 4. **Optional**: Add your ABAP package to the **Favorites Packages** 60 | To add an ABAP package to your _Favorite Packages_, either (a) right-click on the relevant package and choose the context menu entry **Add to Favorite Packages** or (b) right-click on the **Favorites Packages** folder in the Project Explorer, choose the context menu entry **Add Package...**, filter the entries for the relevant package, mark your package and press **OK** to add it. 61 | 62 | ![create ABAP package 05](images/package05.png) 63 | 64 | ![create ABAP package 06](images/package06.png) 65 | 66 | 5. **Optional**: Enable the **Link with Editor** option. Whenever this option is enabled, the current object in the editor will be automatically selected in the expanded Project Explorer tree. 67 | 68 | ![create ABAP package 07](images/package07.png) 69 | 70 | ## Summary 71 | 72 | Now that you have... 73 | - specified your individual group ID and 74 | - created a package, 75 | 76 | you can continue withthe following exercise: 77 | 78 | - \[Regular Track\]: [Exercise 1 - Database Tables](../ex1/README.md) to create the data model step-by-step 79 | -------------------------------------------------------------------------------- /exercises/ex0/README_fast_track.md: -------------------------------------------------------------------------------- 1 | # Getting Started - Fast Track 2 | 3 | ## Introduction 4 | You've already created an ABAP Trial Account and connected your ADT to it using a ABAP Cloud Project as described in the [Requirements](../../../../#requirements) section. 5 | 6 | Please note that ADT dialogs and views as well as Fiori UIs may change in upcoming releases. 7 | 8 | > **Hints and Tips** 9 | > Speed up typing by making use of the Code Completion feature (shortcut Ctrl+Space) and the prepared code snippets provided. 10 | > You can easily open an object with the shortcut *Ctrl+Shift+A*, format your source code using the Pretty Printer feature *Shift+F1* and toggle the fullscreen of the editor using the shortcut *Ctrl+M*. 11 | > 12 | > An overview of ADT shortcuts can be found here: [Useful ADT Shortcuts](https://blogs.sap.com/2013/11/21/useful-keyboard-shortcuts-for-abap-in-eclipse/) 13 | 14 | ## Group ID 15 | 16 | As the ABAP Trial environment is used by many people, we've defined a naming pattern for each artefact you are going to create to make sure it doesn't conflict with other ones. For this you'll find the placeholder **`####`** used in object names that must be replaced with the group ID of your choice during the exercises. 17 | 18 | The group ID will be generated for you in the next exercise and it contains 4 numbers. 19 | 20 | > **Hints and Tips** 21 | > The screenshots in this document have been taken using group ID `1234` and system `X11`. 22 | 23 | ## Find/Replace 24 | 25 | In the course of these exercises you will frequently see the task to "_replace the placeholder `####` with your group ID_". For this it's recommended to make use of the **Find/Replace** feature of the Eclipse Editor. It can be opened either via the menu (**_Edit -> Find/Replace..._**) or via **Ctrl+F**. 26 | 27 | ![find and replace](images/find01.png) 28 | 29 | Choosing **Replace All** allows you to replace all ocurrences of `####` with your group ID. 30 | 31 | ## Link with Editor (Optional) 32 | 33 | Enable the **Link with Editor** option. Whenever this option is enabled, the current object in the editor will be automatically selected in the expanded Project Explorer tree. 34 | 35 | ![create ABAP package 07](images/package07.png) 36 | 37 | ## Summary 38 | 39 | Now you can continue with the following exercise: 40 | - \[Fast Track\]: [Exercises 1-4 - Generate Data Model](../ex1_4/README.md) to generate the data model 41 | 42 | -------------------------------------------------------------------------------- /exercises/ex0/images/00_00_0010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/00_00_0010.png -------------------------------------------------------------------------------- /exercises/ex0/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex0/images/find01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/find01.png -------------------------------------------------------------------------------- /exercises/ex0/images/groupid01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/groupid01.png -------------------------------------------------------------------------------- /exercises/ex0/images/package01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package01.png -------------------------------------------------------------------------------- /exercises/ex0/images/package02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package02.png -------------------------------------------------------------------------------- /exercises/ex0/images/package03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package03.png -------------------------------------------------------------------------------- /exercises/ex0/images/package04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package04.png -------------------------------------------------------------------------------- /exercises/ex0/images/package05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package05.png -------------------------------------------------------------------------------- /exercises/ex0/images/package06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package06.png -------------------------------------------------------------------------------- /exercises/ex0/images/package07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex0/images/package07.png -------------------------------------------------------------------------------- /exercises/ex1/images/01_01_0010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/01_01_0010.png -------------------------------------------------------------------------------- /exercises/ex1/images/01_02_0010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/01_02_0010.png -------------------------------------------------------------------------------- /exercises/ex1/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex1/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex1/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex1/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex1/images/bookingtable01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/bookingtable01.png -------------------------------------------------------------------------------- /exercises/ex1/images/bookingtable02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/bookingtable02.png -------------------------------------------------------------------------------- /exercises/ex1/images/bookingtable03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/bookingtable03.png -------------------------------------------------------------------------------- /exercises/ex1/images/bookingtable04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/bookingtable04.png -------------------------------------------------------------------------------- /exercises/ex1/images/datamodel01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/datamodel01.png -------------------------------------------------------------------------------- /exercises/ex1/images/filltables01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/filltables01.png -------------------------------------------------------------------------------- /exercises/ex1/images/filltables02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/filltables02.png -------------------------------------------------------------------------------- /exercises/ex1/images/filltables03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/filltables03.png -------------------------------------------------------------------------------- /exercises/ex1/images/traveltable01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/traveltable01.png -------------------------------------------------------------------------------- /exercises/ex1/images/traveltable02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/traveltable02.png -------------------------------------------------------------------------------- /exercises/ex1/images/traveltable03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/traveltable03.png -------------------------------------------------------------------------------- /exercises/ex1/images/traveltable04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/traveltable04.png -------------------------------------------------------------------------------- /exercises/ex1/images/traveltable05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1/images/traveltable05.png -------------------------------------------------------------------------------- /exercises/ex1/sources/EX1_1_TABL_ZRAP_ATRAV.txt: -------------------------------------------------------------------------------- 1 | @EndUserText.label : 'Travel data' 2 | @AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE 3 | @AbapCatalog.tableCategory : #TRANSPARENT 4 | @AbapCatalog.deliveryClass : #C 5 | @AbapCatalog.dataMaintenance : #RESTRICTED 6 | define table zrap_atrav_#### { 7 | key client : mandt not null; 8 | key travel_uuid : sysuuid_x16 not null; 9 | travel_id : /dmo/travel_id; 10 | agency_id : /dmo/agency_id; 11 | customer_id : /dmo/customer_id; 12 | begin_date : /dmo/begin_date; 13 | end_date : /dmo/end_date; 14 | @Semantics.amount.currencyCode : 'zrap_atrav_####.currency_code' 15 | booking_fee : /dmo/booking_fee; 16 | @Semantics.amount.currencyCode : 'zrap_atrav_####.currency_code' 17 | total_price : /dmo/total_price; 18 | currency_code : /dmo/currency_code; 19 | description : /dmo/description; 20 | overall_status : /dmo/overall_status; 21 | created_by : syuname; 22 | created_at : timestampl; 23 | last_changed_by : syuname; 24 | last_changed_at : timestampl; 25 | local_last_changed_at : timestampl; 26 | 27 | } -------------------------------------------------------------------------------- /exercises/ex1/sources/EX1_2_TABL_ZRAP_ABOOK.txt: -------------------------------------------------------------------------------- 1 | @EndUserText.label : 'Booking data' 2 | @AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE 3 | @AbapCatalog.tableCategory : #TRANSPARENT 4 | @AbapCatalog.deliveryClass : #C 5 | @AbapCatalog.dataMaintenance : #RESTRICTED 6 | define table zrap_abook_#### { 7 | key client : mandt not null; 8 | key booking_uuid : sysuuid_x16 not null; 9 | travel_uuid : sysuuid_x16 not null; 10 | booking_id : /dmo/booking_id; 11 | booking_date : /dmo/booking_date; 12 | customer_id : /dmo/customer_id; 13 | carrier_id : /dmo/carrier_id; 14 | connection_id : /dmo/connection_id; 15 | flight_date : /dmo/flight_date; 16 | @Semantics.amount.currencyCode : 'zrap_abook_####.currency_code' 17 | flight_price : /dmo/flight_price; 18 | currency_code : /dmo/currency_code; 19 | created_by : syuname; 20 | last_changed_by : syuname; 21 | local_last_changed_at : timestampl; 22 | 23 | } -------------------------------------------------------------------------------- /exercises/ex1/sources/EX1_3_CLAS_ZCL_GENERATE_DEMO_DATA.txt: -------------------------------------------------------------------------------- 1 | CLASS zcl_generate_demo_data_#### DEFINITION 2 | PUBLIC 3 | FINAL 4 | CREATE PUBLIC . 5 | 6 | PUBLIC SECTION. 7 | INTERFACES if_oo_adt_classrun. 8 | PROTECTED SECTION. 9 | PRIVATE SECTION. 10 | ENDCLASS. 11 | 12 | CLASS zcl_generate_demo_data_#### IMPLEMENTATION. 13 | METHOD if_oo_adt_classrun~main. 14 | 15 | " delete existing entries in the database table 16 | DELETE FROM zrap_atrav_####. 17 | DELETE FROM zrap_abook_####. 18 | 19 | " insert travel demo data 20 | INSERT zrap_atrav_#### FROM ( 21 | SELECT 22 | FROM /dmo/travel 23 | FIELDS 24 | uuid( ) AS travel_uuid , 25 | travel_id AS travel_id , 26 | agency_id AS agency_id , 27 | customer_id AS customer_id , 28 | begin_date AS begin_date , 29 | end_date AS end_date , 30 | booking_fee AS booking_fee , 31 | total_price AS total_price , 32 | currency_code AS currency_code , 33 | description AS description , 34 | CASE status 35 | WHEN 'B' THEN 'A' " accepted 36 | WHEN 'X' THEN 'X' " cancelled 37 | ELSE 'O' " open 38 | END AS overall_status , 39 | createdby AS created_by , 40 | createdat AS created_at , 41 | lastchangedby AS last_changed_by , 42 | lastchangedat AS last_changed_at , 43 | lastchangedat AS local_last_changed_at 44 | ORDER BY travel_id UP TO 200 ROWS 45 | ). 46 | COMMIT WORK. 47 | 48 | " insert booking demo data 49 | INSERT zrap_abook_#### FROM ( 50 | SELECT 51 | FROM /dmo/booking AS booking 52 | JOIN zrap_atrav_#### AS z 53 | ON booking~travel_id = z~travel_id 54 | FIELDS 55 | uuid( ) AS booking_uuid , 56 | z~travel_uuid AS travel_uuid , 57 | booking~booking_id AS booking_id , 58 | booking~booking_date AS booking_date , 59 | booking~customer_id AS customer_id , 60 | booking~carrier_id AS carrier_id , 61 | booking~connection_id AS connection_id , 62 | booking~flight_date AS flight_date , 63 | booking~flight_price AS flight_price , 64 | booking~currency_code AS currency_code , 65 | z~created_by AS created_by , 66 | z~last_changed_by AS last_changed_by , 67 | z~last_changed_at AS local_last_changed_by 68 | ). 69 | COMMIT WORK. 70 | 71 | out->write( 'Travel and booking demo data inserted.'). 72 | ENDMETHOD. 73 | 74 | ENDCLASS. -------------------------------------------------------------------------------- /exercises/ex10/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 10 - Authorizations (optional) 2 | 3 | ## Introduction 4 | In the previous exercise you've defined and implemented validations (see [Exercise 9](/exercises/ex9/README.md)). 5 | 6 | In this exercise you will implement instance and global authorization control for the travel business object. For this we will create a new authorization field and an authorization object to demonstrate the authorization handling based on the field `TravelStatus`. The use case assumes that you are allowed to reject a travel (set the status to `X`) - but once saved, you may not change rejected travels anymore. 7 | 8 | > Please note: The ABAP trial environment does not allow for adjusting the individual user authorizations. So we can only simulate how different authorizations behave by adjusting the corresponding method implementations. 9 | 10 | Further information can be found here: [Adding Authorization Control to Managed Business Objects](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/375a8124b22948688ac1c55297868d06.html) 11 | 12 | ## Exercise 10.1 - Authorization Field 13 | 14 | 1. Underneath your package in the Project Explorer, right-click on **Authorizations** and select **`New > Authorization Field`** from the context menu (in case the **Authorizations** entry is not visible, right-click on the package name and choose **Load Full Content F5** / **Refresh F5**). 15 | 16 | > **Please note**: In case no **Authorizations** folder is available in your exercise package in the _Project Explorer_ view, then do as follows: 17 | > 1. right-click on your exercise package and select **`New > Other ABAP Repository Objects`** from the context menu. 18 | > 2. In the appearing dialog, enter the text *`Authorizations Field`* in the filter field. 19 | > 3. Select the appropriate entry and press on *Finish* to continue. 20 | 21 | ![Create Authorization Field](images/auth01.png) 22 | 23 | 2. Maintain **`ZOSTAT####`** (where `####` is your group ID) as **name** in the creation wizard and choose **Next >**. 24 | 25 | ![Create Authorization Field](images/auth02.png) 26 | 27 | 3. Assign a transport request and choose **Finish**. The new authorization field appears in the editor. 28 | 29 | Enter **`/DMO/OVERALL_STATUS`** into the **Data Element** field. 30 | 31 | ![Create Authorization Field](images/auth03.png) 32 | 33 | 4. Save ![save icon](images/adt_save.png) the authorization field. An activation is not required. Keep the editor open. 34 | 35 | ## Exercise 10.2 - Authorization Object 36 | 37 | 1. Choose **Create a new Authorization Object and assign the Authorization Field to it** from the _**What's next?**_ section. 38 | 39 | ![Create Authorization Field](images/auth04.png) 40 | 41 | 2. Maintain **`ZOSTAT####`** (where `####` is your group ID) as name and a description (e.g. _**Authorization object for Travel Status**_) in the creation wizard and choose **Next >** to continue. 42 | 43 | ![Create Authorization Object](images/auth05.png) 44 | 45 | 3. Assign a transport request and choose **Finish**. The new authorization object appears in the editor. 46 | 47 | The previously created authorization field **`ZOSTAT####`** and the default activity field **`ACTVT`** are both listed in the _**Authorization Fields**_ area. 48 | 49 | Maintain the permitted activities in the _**Permitted Activities**_ area in the editor. Double click _**\**_ and enter the four activities below as shown on the screenshot. The description is filled automatically. 50 | - **`01`** (Add or Create) 51 | - **`02`** (Change) 52 | - **`03`** (Display) 53 | - **`06`** (Delete) 54 | 55 | ![Create Authorization Object](images/auth06.png) 56 | 57 | 4. Save ![save icon](images/adt_save.png) the changes to activate the authorization object. The **Object Class** will be filled automatically. 58 | 59 | ## Exercise 10.3 - Define the Authorization Master and the Authorization Dependent 60 | The **authorization master** defines the node where the authorization checks are implemented. Currently only the root node can be defined as authorization master. All other nodes in the composition hierarchy have to be defined as **authorization dependent**, delegating authorization requests via the association to the corresponding master. 61 | 62 | 1. Open the base behavior definition **`ZI_RAP_Travel_####`** – where **`####`** is your group ID – of your business object by either double-clicking on it in the _Project Explorer_ or using the shortcut **Ctrl+Shift+A** (_Open ABAP Development Object_). 63 | 64 | 2. Add the following line into the **Travel** entity, right after the `etag master LocalLastChangedAt` statement. 65 | 66 |
 67 |     authorization master ( instance, global )
 68 |     
69 | 70 | ![Base Behavior Definition](images/auth07.png) 71 | 72 | 3. Add the following line into the **Booking** entity, right after the `etag master LocalLastChangedAt` statement. 73 | 74 |
 75 |     authorization dependent by _Travel
 76 |     
77 | 78 | ![Base Behavior Definition](images/auth08.png) 79 | 80 | 4. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior definition. 81 | 82 | ## Exercise 10.4 - Behavior Implementation 83 | 84 | 1. You can again use the Quick Fix marker to add the missing implementations into the local handler class. This approach would be used in a regular development flow. 85 | 86 | ![Base Behavior Definition](images/auth09.png) 87 | 88 | 2. In this exercise we replace the entire code with the prepared one. Open the behavior implementation class **zbp_i_rap_travel_####** for the **Travel** entity. Replace the **entire** code on the **_Local Types tab_** with the following coding and replace all occurrences of `####` with your group ID: 89 | 90 | [Behavior Implementation Class ZBP_I_RAP_TRAVEL_####](sources/EX10_4_CLAS_ZBP_I_RAP_TRAVEL.txt) 91 | 92 | This declares and implements both authorization methods as well as three helper methods. 93 | 94 | The three helper methods **is_update_granted**, **is_delete_granted** and **is_create_granted** are used to perform the actual `AUTHORITY-CHECK` calls, returning a boolean flag indicating the operation is granted or not. 95 | 96 | > As already mentioned, the individual user authorizations can not be adjusted in the ABAP trial environment - therefore limited authorizations need to be simulated by adjusting the method implementations (which is of course not the recommended approach in a productive use case). 97 | 98 | The instance authorization handler **get_authorizations** calculates the requested authorizations against the state present in the persistent table `zrap_atrav_####` (which is called _before-image_ in the implementation). Editing of active instances is only possible if the user has the authorization for the related travel status. This covers the _Edit Draft_ use-case, in which an active instance exists. For editing _New Drafts_ the implementation validates the create authorization. 99 | 100 | The RAP framework provides the importing parameter `requested_authorizations` when calling the instance authorization handler. This structure consists of flags for which the authorizations need to be calculated. The sample implementation maps these flags to the typical activities used in the authorization object (`01` - Create, `02`- Update and `06`- Delete), and uses the above mentioned helper methods to perform the actual authority-check calls. 101 | 102 | The global authorization handler **get_global_authorizations** can be used for instance independent authorizations, like the **create** operation or any static actions. But the exit can also be used for instance specific operations (e.g. update or delete), in case the operation is not allowed in general (to avoid calculating this for each instance again and again). 103 | 104 | Please note that - depending on the scenario - authorization checks not only need to be implemented in these 2 authorization exists. In a scenario where e.g. the user authorization does not allow for entering a certain value into an editable field, you also need to define and implement a corresponding validation that calls the authority-check with the current field value. 105 | 106 | > In the UI use case the authorization result is exposed via so-called user hints. This allows the Fiori Elements UI to enable/disable related operations based on the existing user authorization. These hints are merged with the result from the instance specific feature control implementation. 107 | 108 | ## Exercise 10.5 - Preview the Travel App 109 | 1. Use the service binding to start the app preview. Make sure to launch the **Travel** entity set. In case the browser window is still open it's also sufficient to simply reload (F5) the page. 110 | 111 | As a result, editing / deleting a rejected (status = `X`) travel is not possible anymore. 112 | 113 | ![Preview App](images/auth10.png) 114 | 115 | ## Summary 116 | 117 | Now that you've... 118 | - created an authorization field and an authorization object, 119 | - defined the authorization master and dependent in the base behavior definition and 120 | - implemented the authorization exits in the behavior implementation class, 121 | 122 | you are done with this workshop. Congratulations! 123 | 124 | ## Appendix 125 | 126 | Find the source code for the base behavior definition, the travel behavior implementation class in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 127 | 128 | - [Behavior Definition ZI_RAP_TRAVEL_####](sources/EX10_3_BDEF_ZI_RAP_TRAVEL.txt) 129 | - [Behavior Implementation Class ZBP_I_RAP_Travel_####](sources/EX10_4_CLAS_ZBP_I_RAP_TRAVEL.txt) 130 | 131 | 132 | -------------------------------------------------------------------------------- /exercises/ex10/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex10/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex10/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex10/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex10/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth01.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth02.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth03.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth04.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth05.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth06.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth07.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth08.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth09.png -------------------------------------------------------------------------------- /exercises/ex10/images/auth10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex10/images/auth10.png -------------------------------------------------------------------------------- /exercises/ex10/sources/EX10_3_BDEF_ZI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | managed; 2 | with draft; 3 | 4 | define behavior for ZI_RAP_Travel_#### alias Travel 5 | implementation in class zbp_i_rap_travel_#### unique 6 | persistent table zrap_atrav_#### 7 | draft table zrap_dtrav_#### 8 | lock master total etag LastChangedAt 9 | etag master LocalLastChangedAt 10 | authorization master ( instance, global ) 11 | { 12 | create; 13 | update; 14 | delete; 15 | association _Booking { create; with draft; } 16 | 17 | field ( numbering : managed, readonly ) TravelUUID; 18 | field ( readonly ) TravelId, TotalPrice, TravelStatus; 19 | field ( readonly ) LastChangedAt, LastChangedBy, CreatedAt, CreatedBy, LocalLastChangedAt; 20 | field ( mandatory ) AgencyID, CustomerID; 21 | 22 | action ( features : instance ) acceptTravel result [1] $self; 23 | action ( features : instance ) rejectTravel result [1] $self; 24 | internal action recalcTotalPrice; 25 | 26 | determination setInitialStatus on modify { create; } 27 | determination calculateTotalPrice on modify { field BookingFee, CurrencyCode; } 28 | determination calculateTravelID on save { create; } 29 | 30 | validation validateAgency on save { field AgencyID; create; } 31 | validation validateCustomer on save { field CustomerID; create; } 32 | validation validateDates on save { field BeginDate, EndDate; create; } 33 | 34 | draft determine action Prepare { 35 | validation validateAgency; 36 | validation validateCustomer; 37 | validation validateDates; 38 | } 39 | 40 | mapping for zrap_atrav_#### 41 | { 42 | TravelUUID = travel_uuid; 43 | TravelID = travel_id; 44 | AgencyID = agency_id; 45 | CustomerID = customer_id; 46 | BeginDate = begin_date; 47 | EndDate = end_date; 48 | BookingFee = booking_fee; 49 | TotalPrice = total_price; 50 | CurrencyCode = currency_code; 51 | Description = description; 52 | TravelStatus = overall_status; 53 | CreatedBy = created_by; 54 | CreatedAt = created_at; 55 | LastChangedBy = last_changed_by; 56 | LastChangedAt = last_changed_at; 57 | LocalLastChangedAt = local_last_changed_at; 58 | } 59 | } 60 | 61 | define behavior for ZI_RAP_Booking_#### alias Booking 62 | implementation in class zbp_i_rap_booking_#### unique 63 | persistent table zrap_abook_#### 64 | draft table zrap_dbook_#### 65 | lock dependent by _Travel 66 | etag master LocalLastChangedAt 67 | authorization dependent by _Travel 68 | { 69 | update; 70 | delete; 71 | 72 | association _Travel { with draft; } 73 | 74 | field ( numbering : managed, readonly ) BookingUUID; 75 | field ( readonly ) TravelUUID, BookingId; 76 | field ( readonly ) CreatedBy, LastChangedBy, LocalLastChangedAt; 77 | 78 | determination calculateBookingID on modify { create; } 79 | determination calculateTotalPrice on modify { field FlightPrice, CurrencyCode; } 80 | 81 | mapping for zrap_abook_#### 82 | { 83 | BookingUUID = booking_uuid; 84 | TravelUUID = travel_uuid; 85 | BookingID = booking_id; 86 | BookingDate = booking_date; 87 | CustomerID = customer_id; 88 | CarrierID = carrier_id; 89 | ConnectionID = connection_id; 90 | FlightDate = flight_date; 91 | FlightPrice = flight_price; 92 | CurrencyCode = currency_code; 93 | CreatedBy = created_by; 94 | LastChangedBy = last_changed_by; 95 | LocalLastChangedAt = local_last_changed_at; 96 | } 97 | } -------------------------------------------------------------------------------- /exercises/ex1_4/README.md: -------------------------------------------------------------------------------- 1 | # Exercises 1-4 (Fast Track) - Generate Data Model 2 | 3 | ## Introduction 4 | The data model in this workshop consists of two transactional tables (**travel** and **booking**) as well as some master data that we will re-use from the already existing demo content (**Agency**, **Customer** and **Flight**), as well as a few more. 5 | A *Travel* entity defines general travel data, such as the agency ID or customer ID, the overall status of the travel and the price of travel. 6 | A *Booking* entity comprises general flight and booking data, the customer ID for whom the flight is booked as well as the travel ID to which the booking belongs to – and some admin fields. 7 | 8 | ![Data Model](images/datamodel01.png) 9 | 10 | You've already defined a group ID and created an ABAP package as described in the [Getting Started](/exercises/ex0/README.md) section. 11 | 12 | In the current exercise you will create a helper class which will take care of the generation of the following RAP artefacts: 13 | - **two database tables** (`ZRAP_A*`) to store the *travel* and *booking* data - both filled with some sample data 14 | - **two BO CDS views** (`ZRAP_I_*`) for the root entity *travel* and child entity *booking* (CDS composition model) 15 | - **two Projection CDS views** - aka Consumption views - (`ZRAP_C_*`) for the root entity *travel* and child entity *booking* (CDS data model projection) 16 | - **two CDS metadata extensions** (`ZRAP_C_*`) to enrich the projected root entity *travel* and projected child entity *booking* with UI semantics for the later rendering of the SAP Fiori Elements app (UI semantics). 17 | 18 | ## Exercise 1_4.1 - Generate the data model 19 | 20 | In the ABAP trial systems we have prepared a helper class **/dmo/cl_gen_dev260_artifacts** to generate the database tables and different CDS artefacts needed for the next exercises. The helper class will also fill some demo data into the database tables. For this purpose, demo data provided by the ABAP Flight Reference Scenario (main package: `/DMO/FLIGHT`) will be used. 21 | 22 | 1. Select the **Open ABAP Development Object** icon or press **Ctrl+Shift+A**. 23 | 24 | ![Open ABAP Development Object](images/helperclass_00_new.png) 25 | 26 | 2. In the *Open ABAP Development Object* dialogue enter **/dmo/cl_gen_dev260_artifacts** as search string and press **OK**. 27 | 28 | ![Generate Data Model](images/helperclass_01_new.png) 29 | 30 | 2. The class **/dmo/cl_gen_dev260_artifacts** is displayed in a new tab. 31 | 32 | ![Generate Data Model](images/helperclass_02_new.png) 33 | 34 | 3. Press **F9** to run the ABAP class as a console application. As a result, you will see a success message in the Console. 35 | 36 | ![Generate Data Model](images/helperclass_03_new.png) 37 | 38 | 4. Please note down your group ID **`####`** and copy the name of the newly created package **ZRAP_TRAVEL_####** 39 |
 40 |      ... 
 41 |       - Package: ZRAP_TRAVEL_#### 
 42 |       - Group ID: #### 
 43 |      ...
 44 |      
45 | 46 | 5. Right click on the folder **Favorite Packages** and select **Add Package...**. 47 | 48 | ![Open ABAP Development Object](images/helperclass_04_new.png) 49 | 50 | 6. Enter the name of your package **ZRAP_TRAVEL_####** and press **OK**. 51 | 52 | 7. Go to your package `ZRAP_TRAVEL_####` in the *Project Explorer* (where `####` is your group ID) and press **F5** to refresh the project explorer. It should now contain the generated objects. 53 | You can preview the data from a database table or a CDS view by choosing the relevant objects in the *Project Explorer* and pressing **F8**. 54 | 55 | - Dictionary > Database Tables: `ZRAP_ATRAV_####` and `ZRAP_ABOOK_####` 56 | - Core Data Services > Data Definitions: `ZI_RAP_TRAVEL_####`, `ZI_RAP_BOOKING_####`, `ZC_RAP_TRAVEL_####` and `ZC_RAP_BOOKING_####` 57 | - Core Data Services > Metadata Extensions: `ZC_RAP_TRAVEL_####` and `ZC_RAP_BOOKING_####` 58 | 59 | 60 | ![Generate Data Model](images/helperclass06.png) 61 | 62 | You can preview the data of a database table or a CDS view in the Data Preview editor by selecting it and pressing **F8**. 63 | Short explanations about the generated artefacts are provided below (where `####` is your group ID). 64 | 65 | 8. **Database tables** 66 | **`ZRAP_ATRAV_####`** is used to store _Travel_ data. Its table key consists of the `client` field and the `travel_uuid` field which is a technical key (16 Byte UUID). It also contains a human-readable travel identifier `travel_id`. 67 | 68 | **`ZRAP_ABOOK_####`** is used to store _Booking_ data. Its table key consists of the `client` field and the `booking_uuid` field which is a technical key (16 Byte UUID). It also comprises a human-readable booking identifier: `booking_id`. 69 | 70 | 9. **CDS Data Model (Composition Model)** 71 | Both CDS data definitions **`ZI_RAP_Travel_####`** and **`ZI_RAP_Booking_####`** (where `####` is your group ID) are CDS view entities used to define the *composition model* of our RAP BO. They are called *BO views* or *Interface views*, and typically beginn with the suffix `I_` (e.g. `ZI_`) - following the naming convention of the SAP S/4HANA's Virtual Data Model (VDM). 72 | 73 | Our composition model consists of two nodes: The **root node travel** (`ZI_RAP_Travel_####`) and its **child node booking** (`ZI_RAP_Booking_####`). The root node (_Travel_) is explicitly defined by adding the keyword **`root`** to the define statement. Associations that define the composition model are explicitly defined using the keyword **`composition`**. Their corresponding on-condition is defined in the child entity. 74 | 75 | In the child node (_Booking_), the corresponding **`to parent`** association is defined with the related on-condition. 76 | 77 | 10. **CDS Data Model Projection** 78 | Both CDS data definitions **`ZC_RAP_Travel_####`** and **`ZC_RAP_Booking_####`** (where `####` is your group ID) are CDS projection views used to define the use case or consumption specific CDS data model projection of our RAP BO. They are called *Consumption views* or *Projection views*, and typically beginn with the suffix `C_` (e.g. `ZC_`) following the naming convention of the SAP S/4HANA's Virtual Data Model (VDM). They are defined on top of the interface views (`ZI_*`). 79 | 80 | The _Travel_ projection view exposes all the elements and _Booking_ composition defined in the underlying _Travel_ interface view - enhanced with additional metadata such as value Helps and searches. However, the composition to the booking BO child node - i.e. the association **`_Booking`** - must be redirected to the Booking BO projection view. This is done using the **`redirected to composition child`** statement. 81 | 82 | In the _Booking_ projection view, the association to the _Travel_ BO parent node has been redirected to the _Travel_ BO projection view using the **`redirect to parent`** statement. 83 | 84 | 11. **CDS Metadata Extensions** 85 | Both CDS metadata extensions **`ZC_RAP_Travel_####`** and **`ZC_RAP_Booking_####`** (where `####` is your group ID) are used to enrich respectively the *Travel* projection view and the *Booking* projection view with UI semantics for the later rendering of the SAP Fiori elements-based _Travel_ app - using UI-specific CDS annotations. The metadata extensions define e.g. the columns and fields shown on the list report page as well as on the object page in the SAP Fiori elements app. 86 | 87 | 88 | ## Exercise 1_4.2 - Adjust the CDS data model projection 89 | Due to some current restrictions in the helper class, some adjustments of the _Travel_ and _Booking_ projection views are required. 90 | 91 | 1. Open the *Travel* projection view **`ZC_RAP_Travel_####`** by double-clicking on it in the Project Explorer and adjust it as described next two steps. 92 | 93 | 2. **Replace** the line 94 |
 AgencyID, 
95 | with 96 |
 97 |      @ObjectModel.text.element: ['AgencyName']
 98 |      @Search.defaultSearchElement: true
 99 |      AgencyID,
100 |      _Agency.Name       as AgencyName,
101 |    
102 | 103 | 3. Also **replace** the line 104 |
 CustomerID, 
105 | with 106 |
107 |      @ObjectModel.text.element: ['CustomerName']
108 |      @Search.defaultSearchElement: true
109 |      CustomerID,
110 |      _Customer.LastName as CustomerName,
111 |    
112 | 113 | The changes should look as follows: 114 | 115 | ![CDS Data Model Projection](images/travelprojection02.png) 116 | 117 | 4. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the changes. 118 | You can preview (**F8**) the result of the changes in the Data Preview editor. 119 | 120 | 5. Now open the _Booking_ projection view **`ZC_RAP_Booking_####`** by double-clicking on it in the Project Explorer and adjust it as described in the next two steps. 121 | 122 | 6. **Replace** the line 123 |
 CustomerID, 
124 | 125 | with 126 | 127 |
128 |       @ObjectModel.text.element: ['CustomerName']
129 |       @Search.defaultSearchElement: true
130 |       CustomerID,
131 |       _Customer.LastName as CustomerName,
132 |     
133 | 134 | 7. Also **replace** the line 135 |
 CarrierID, 
136 | 137 | with 138 | 139 |
140 |        @ObjectModel.text.element: ['CarrierName']
141 |        CarrierID,
142 |        _Carrier.Name      as CarrierName,
143 |    
144 | 145 | The changes should look as follows: 146 | 147 | ![CDS Data Model Projection](images/bookingprojection02.png) 148 | 149 | 8. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the changes. 150 | You can preview (**F8**) its data in the Data Preview editor. 151 | 152 | ## Summary 153 | 154 | Now that you've... 155 | - created the enriched data model: database tables, interface views, projections view and metadata extensions 156 | - filled the database tables with sample data, 157 | - and adjusted the projections views and the metadata extensions 158 | 159 | You can continue with - [Exercise 5 - Business Service](../ex5/README.md) 160 | 161 | ## Appendix 162 | Find the source code for the CDS views in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 163 | 164 | Find the source code for the database tables and the helper class in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID or chosen suffix. 165 | 166 | 167 | - [Projection View ZC_RAP_TRAVEL_####](sources/EX14_2_DDLS_ZC_RAP_TRAVEL.txt) 168 | - [Projection View ZC_RAP_BOOKING_####](sources/EX14_3_DDLS_ZC_RAP_BOOKING.txt) 169 | -------------------------------------------------------------------------------- /exercises/ex1_4/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/bookingprojection01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/bookingprojection01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/bookingprojection02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/bookingprojection02.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/bookingtable01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/bookingtable01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/bookingview01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/bookingview01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/datamodel01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/datamodel01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/doc.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/doc.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass02.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass03.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass04.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass05.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass06.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass_00_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass_00_new.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass_01_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass_01_new.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass_02_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass_02_new.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass_03_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass_03_new.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass_04_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass_04_new.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/helperclass_05_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/helperclass_05_new.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/travelmetadata01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/travelmetadata01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/travelprojection01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/travelprojection01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/travelprojection02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/travelprojection02.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/traveltable01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/traveltable01.png -------------------------------------------------------------------------------- /exercises/ex1_4/images/travelview01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex1_4/images/travelview01.png -------------------------------------------------------------------------------- /exercises/ex1_4/sources/EX14_2_DDLS_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @Metadata.allowExtensions: true 3 | @EndUserText.label: 'Projection View forTravel' 4 | @Search.searchable: true 5 | define root view entity ZC_RAP_TRAVEL_#### 6 | as projection on ZI_RAP_Travel_#### 7 | { 8 | key TravelUUID, 9 | 10 | @Search.defaultSearchElement: true 11 | @Search.fuzzinessThreshold: 0.90 12 | TravelID, 13 | 14 | @Consumption.valueHelpDefinition: [ { 15 | entity: { 16 | name: '/DMO/I_Agency', 17 | element: 'AgencyID' 18 | } 19 | } ] 20 | @ObjectModel.text.element: ['AgencyName'] 21 | @Search.defaultSearchElement: true 22 | AgencyID, 23 | _Agency.Name as AgencyName, 24 | 25 | @Consumption.valueHelpDefinition: [ { 26 | entity: { 27 | name: '/DMO/I_Customer', 28 | element: 'CustomerID' 29 | } 30 | } ] 31 | @ObjectModel.text.element: ['CustomerName'] 32 | @Search.defaultSearchElement: true 33 | CustomerID, 34 | _Customer.LastName as CustomerName, 35 | 36 | BeginDate, 37 | 38 | EndDate, 39 | 40 | @Semantics.amount.currencyCode: 'CurrencyCode' 41 | BookingFee, 42 | 43 | @Semantics.amount.currencyCode: 'CurrencyCode' 44 | TotalPrice, 45 | 46 | @Consumption.valueHelpDefinition: [ { 47 | entity: { 48 | name: 'I_Currency', 49 | element: 'Currency' 50 | } 51 | } ] 52 | CurrencyCode, 53 | 54 | Description, 55 | 56 | TravelStatus, 57 | 58 | CreatedBy, 59 | 60 | CreatedAt, 61 | 62 | LastChangedBy, 63 | 64 | LastChangedAt, 65 | 66 | LocalLastChangedAt, 67 | 68 | _Booking : redirected to composition child ZC_RAP_Booking_#### 69 | } -------------------------------------------------------------------------------- /exercises/ex1_4/sources/EX14_3_DDLS_ZC_RAP_BOOKING.txt: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @Metadata.allowExtensions: true 3 | @EndUserText.label: 'Projection View forBooking' 4 | @Search.searchable: true 5 | define view entity ZC_RAP_BOOKING_#### 6 | as projection on ZI_RAP_Booking_#### 7 | { 8 | key BookingUUID, 9 | 10 | TravelUUID, 11 | 12 | @Search.defaultSearchElement: true 13 | @Search.fuzzinessThreshold: 0.90 14 | BookingID, 15 | 16 | BookingDate, 17 | 18 | @Consumption.valueHelpDefinition: [ { 19 | entity: { 20 | name: '/DMO/I_Customer', 21 | element: 'CustomerID' 22 | } 23 | } ] 24 | @ObjectModel.text.element: ['CustomerName'] 25 | @Search.defaultSearchElement: true 26 | CustomerID, 27 | _Customer.LastName as CustomerName, 28 | 29 | @Consumption.valueHelpDefinition: [ { 30 | entity: { 31 | name: '/DMO/I_Carrier', 32 | element: 'AirlineID' 33 | } 34 | } ] 35 | @ObjectModel.text.element: ['CarrierName'] 36 | CarrierID, 37 | _Carrier.Name as CarrierName, 38 | 39 | @Consumption.valueHelpDefinition: [ { 40 | entity: { 41 | name: '/DMO/I_Flight', 42 | element: 'ConnectionID' 43 | }, 44 | additionalBinding: [ { 45 | localElement: 'FlightDate', 46 | element: 'FlightDate' 47 | }, { 48 | localElement: 'CarrierID', 49 | element: 'AirlineID' 50 | }, { 51 | localElement: 'FlightPrice', 52 | element: 'Price' 53 | }, { 54 | localElement: 'CurrencyCode', 55 | element: 'CurrencyCode' 56 | } ] 57 | } ] 58 | ConnectionID, 59 | 60 | FlightDate, 61 | 62 | @Semantics.amount.currencyCode: 'CurrencyCode' 63 | FlightPrice, 64 | 65 | @Consumption.valueHelpDefinition: [ { 66 | entity: { 67 | name: 'I_Currency', 68 | element: 'Currency' 69 | } 70 | } ] 71 | CurrencyCode, 72 | 73 | CreatedBy, 74 | 75 | LastChangedBy, 76 | 77 | LocalLastChangedAt, 78 | 79 | _Travel : redirected to parent ZC_RAP_Travel_#### 80 | } -------------------------------------------------------------------------------- /exercises/ex1_4/sources/EX14_5_DDLX_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @Metadata.layer: #CORE 2 | @UI: { 3 | headerInfo: { typeName: 'Travel', 4 | typeNamePlural: 'Travels', 5 | title: { type: #STANDARD, label: 'Travel', value: 'TravelID' } }, 6 | presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction: #DESC }], visualizations: [{type: #AS_LINEITEM}] }] } 7 | 8 | annotate view ZC_RAP_Travel_#### with 9 | { 10 | @UI.facet: [ { id: 'Travel', 11 | purpose: #STANDARD, 12 | type: #IDENTIFICATION_REFERENCE, 13 | label: 'Travel', 14 | position: 10 }, 15 | { id: 'Booking', 16 | purpose: #STANDARD, 17 | type: #LINEITEM_REFERENCE, 18 | label: 'Booking', 19 | position: 20, 20 | targetElement: '_Booking'} ] 21 | 22 | @UI:{ identification: [{ position: 1, label: 'Travel UUID' }] } 23 | TravelUUID; 24 | 25 | @UI: { lineItem: [ { position: 10 } ], 26 | identification: [ { position: 10 } ], 27 | selectionField: [ { position: 10 } ] } 28 | TravelID; 29 | 30 | @UI: { lineItem: [ { position: 20 } ], 31 | identification: [ { position: 20 } ], 32 | selectionField: [ { position: 20 } ] } 33 | AgencyID; 34 | 35 | @UI: { lineItem: [ { position: 30 } ], 36 | identification: [ { position: 30 } ], 37 | selectionField: [ { position: 30 } ] } 38 | CustomerID; 39 | 40 | @UI: { lineItem: [ { position: 40 } ], 41 | identification: [ { position: 40 } ] } 42 | BeginDate; 43 | 44 | @UI: { lineItem: [ { position: 50 } ], 45 | identification: [ { position: 50 } ] } 46 | EndDate; 47 | 48 | @UI: { lineItem: [ { position: 60 } ], 49 | identification: [ { position: 60 } ] } 50 | BookingFee; 51 | 52 | @UI: { lineItem: [ { position: 70 } ], 53 | identification: [ { position: 70 } ] } 54 | TotalPrice; 55 | 56 | @UI: { lineItem: [ { position: 80 } ], 57 | identification: [ { position: 80 } ] } 58 | Description; 59 | 60 | @UI: { lineItem: [ { position: 90 } 61 | // , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' }, 62 | // { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } 63 | ], 64 | identification: [ { position: 90 } 65 | // , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' }, 66 | // { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } 67 | ] } 68 | TravelStatus; 69 | 70 | @UI.hidden: true 71 | LastChangedAt; 72 | 73 | @UI.hidden: true 74 | LocalLastChangedAt; 75 | 76 | @UI.selectionField: [{ element: '_Booking.CarrierID', position: 40 }] 77 | _Booking; 78 | } -------------------------------------------------------------------------------- /exercises/ex2/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 2 - Core Data Services (CDS) Data Model 2 | 3 | ## Introduction 4 | In the previous exercise you've created the database tables for the demo Travel app and filled them with sample data (see [Exercise 1](/exercises/ex1/README.md)). 5 | 6 | In this exercise you will define the travel and the booking interface views of the CDS data model for the travel app. 7 | 8 | We assume that you are familiar with working with ABAP CDS views. Further information can be found here: [ABAP CDS Development User Guide](https://help.sap.com/viewer/f859579898c7494dbe2449bb7f278dcc/Cloud/en-US) 9 | 10 | ## Exercise 2.1 - Create the Interface CDS View for the Travel entity 11 | 12 | 1. Right-click on your travel table **`ZRAP_ATRAV_####`** and choose **New Data Definition** from the context menu. 13 | 14 | ![Create Travel BO view](images/itravelCDS01.png) 15 | 16 | 2. Maintain **` ZI_RAP_Travel_####`** (where `####` is your group ID) as name and a **description** (e.g. _Travel BO view_) in the creation wizard and choose **Next** to continue. 17 | > In this exercise, we will follow the naming convention of the Virtual Data Model (VDM) of the SAP S/4HANA where the name of interface and BO views begins with _`I`_ and the name of consumption views begins with the namespace followed by _`C`_. 18 | 19 | ![Create Travel BO view](images/itravelCDS02.png) 20 | 21 | 3. Assign a transport request and choose **Finish** (please note: clicking on **Next** in the _Selection of Transport Request_ step, you get to the optional _Templates_ step in which you can choose from predefined templates). 22 | 23 | Replace the code of the travel data definition in the editor with the code snippet provided below and replace all occurrences of `####` with your group ID. You can make use of the Replace All feature (**Ctrl+F**) in ADT for this purpose. 24 | 25 |
 26 |     @AccessControl.authorizationCheck: #CHECK
 27 |     @EndUserText.label: 'Travel BO view'
 28 |     define root view entity ZI_RAP_Travel_####
 29 |       as select from zrap_atrav_#### as Travel
 30 | 
 31 |       composition [0..*] of ZI_RAP_Booking_#### as _Booking
 32 | 
 33 |       association [0..1] to /DMO/I_Agency       as _Agency   on $projection.AgencyID = _Agency.AgencyID
 34 |       association [0..1] to /DMO/I_Customer     as _Customer on $projection.CustomerID = _Customer.CustomerID
 35 |       association [0..1] to I_Currency          as _Currency on $projection.CurrencyCode = _Currency.Currency  
 36 |     {
 37 |       key travel_uuid           as TravelUUID,
 38 |           travel_id             as TravelID,
 39 |           agency_id             as AgencyID,
 40 |           customer_id           as CustomerID,
 41 |           begin_date            as BeginDate,
 42 |           end_date              as EndDate,
 43 |           @Semantics.amount.currencyCode: 'CurrencyCode'
 44 |           booking_fee           as BookingFee,
 45 |           @Semantics.amount.currencyCode: 'CurrencyCode'
 46 |           total_price           as TotalPrice,
 47 |           currency_code         as CurrencyCode,
 48 |           description           as Description,
 49 |           overall_status        as TravelStatus,
 50 |           @Semantics.user.createdBy: true
 51 |           created_by            as CreatedBy,
 52 |           @Semantics.systemDateTime.createdAt: true
 53 |           created_at            as CreatedAt,
 54 |           @Semantics.user.lastChangedBy: true
 55 |           last_changed_by       as LastChangedBy,
 56 |           @Semantics.systemDateTime.lastChangedAt: true
 57 |           last_changed_at       as LastChangedAt,
 58 |           @Semantics.systemDateTime.localInstanceLastChangedAt: true
 59 |           local_last_changed_at as LocalLastChangedAt,
 60 | 
 61 |           /* associations */
 62 |           _Booking,
 63 |           _Agency,
 64 |           _Customer,
 65 |           _Currency      
 66 |     }
 67 |     
68 | 69 | The travel data definition should look as follows: 70 | 71 | ![Create Travel BO view](images/itravelCDS03.png) 72 | 73 | Our composition model consists of two nodes: The root node travel and its child node booking. The root node is explicitly defined by adding the keyword **`root`** to the define statement. Associations that define the composition model are explicitly defined using the keyword **`composition`**. Their corresponding on-condition is defined in the child entity. 74 | 75 | >**Note:** Save your changes, but do **not yet activate** the CDS view. This will be done via **mass activation** once the CDS view for the booking entity has been defined. 76 | 77 | ## Exercise 2.2 - Create the Interface CDS View for the Booking entity 78 | 79 | 1. Right-click on your booking table **`ZRAP_ABOOK_####`** and choose **New Data Definition** from the context menu. 80 | 81 | ![Create Booking BO view](images/ibookingCDS01.png) 82 | 83 | 2. Maintain **`ZI_RAP_Booking_####`** (where `####` is your group ID) as name and a **description** (e.g. _Booking BO view_) in the creation wizard and choose **Next** to continue. 84 | 85 | ![Create Booking BO view](images/ibookingCDS02.png) 86 | 87 | 3. Assign a transport request and choose **Finish**. Replace the code of the booking data definition in the editor with the code snippet provided below and replace all occurrences of `####` with your group ID. You can make use of the Replace All feature (**Ctrl+F**) in ADT for this purpose. 88 | 89 |
 90 |     @AccessControl.authorizationCheck: #CHECK
 91 |     @EndUserText.label: 'Booking BO view'
 92 |     define view entity ZI_RAP_Booking_####
 93 |       as select from zrap_abook_#### as Booking
 94 | 
 95 |       association to parent ZI_RAP_Travel_####        as _Travel     on  $projection.TravelUUID = _Travel.TravelUUID
 96 | 
 97 |       association [1..1] to /DMO/I_Customer           as _Customer   on  $projection.CustomerID   = _Customer.CustomerID
 98 |       association [1..1] to /DMO/I_Carrier            as _Carrier    on  $projection.CarrierID    = _Carrier.AirlineID
 99 |       association [1..1] to /DMO/I_Connection         as _Connection on  $projection.CarrierID    = _Connection.AirlineID
100 |                                                                      and $projection.ConnectionID = _Connection.ConnectionID
101 |       association [1..1] to /DMO/I_Flight             as _Flight     on  $projection.CarrierID    = _Flight.AirlineID
102 |                                                                      and $projection.ConnectionID = _Flight.ConnectionID
103 |                                                                      and $projection.FlightDate   = _Flight.FlightDate
104 |       association [0..1] to I_Currency                as _Currency   on $projection.CurrencyCode    = _Currency.Currency    
105 |     {
106 |       key booking_uuid          as BookingUUID,
107 |           travel_uuid           as TravelUUID,
108 |           booking_id            as BookingID,
109 |           booking_date          as BookingDate,
110 |           customer_id           as CustomerID,
111 |           carrier_id            as CarrierID,
112 |           connection_id         as ConnectionID,
113 |           flight_date           as FlightDate,
114 |           @Semantics.amount.currencyCode: 'CurrencyCode'
115 |           flight_price          as FlightPrice,
116 |           currency_code         as CurrencyCode,
117 |           @Semantics.user.createdBy: true
118 |           created_by            as CreatedBy,
119 |           @Semantics.user.lastChangedBy: true
120 |           last_changed_by       as LastChangedBy,
121 |           @Semantics.systemDateTime.localInstanceLastChangedAt: true
122 |           local_last_changed_at as LocalLastChangedAt,
123 | 
124 |           /* associations */
125 |           _Travel,
126 |           _Customer,
127 |           _Carrier,
128 |           _Connection,
129 |           _Flight,
130 |           _Currency
131 | 
132 |     }
133 |     
134 | 135 | The booking data definition should look as follows: 136 | 137 | ![Create Booking BO view](images/ibookingCDS03.png) 138 | 139 | In the child node, you define the corresponding **`to parent`** association with the related on-condition. 140 | 141 | Save your changes, but do **not yet activate** the CDS view. 142 | 143 | ## Exercise 2.3 - Activate the CDS Data Model 144 | 145 | To avoid errors during the activation, both new CDS views – i.e. the Travel interface view and the Booking interface view – must be activated together for the first time. 146 | 147 | 1. Choose **Activate All** ![activate all icon](images/adt_activate_all.png) or use the shortcut **Ctrl+Shift+F3**, select both CD views **`ZI_RAP_TRAVEL_####`** and **`ZI_RAP_BOOKING_####`** in the appearing dialog, and press **Activate** to active them together. 148 | 149 | ![Activate CDS Data Model](images/iactivate01.png) 150 | 151 | Both views are now activated, but warnings are displayed in the _Problems_ view and in the editor. The reason behind this is that the authority check is allowed for these CDS views (`@AccessControl.authorizationCheck: #CHECK`), but no CDS access control is currently defined for them. 152 | 153 | ![Activate CDS Data Model](images/iactivate02.png) 154 | 155 | The creation of the CDS access control will not be covered in the session. Further information can be found here: [Access Controls](https://help.sap.com/viewer/f859579898c7494dbe2449bb7f278dcc/Cloud/en-US/7072ee4d6bf41014b5040bee4e204223.html) 156 | 157 | ## Summary 158 | 159 | Now that you've... 160 | - created both CDS interface views and 161 | - activated them using mass activation, 162 | 163 | you can continue with - [Exercise 3 - CDS Data Model Projection](../ex3/README.md) 164 | 165 | ## Appendix 166 | 167 | Find the source code for the CDS views in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 168 | 169 | - [CDS View ZI_RAP_TRAVEL_####](sources/EX2_1_DDLS_ZI_RAP_TRAVEL.txt) 170 | - [CDS View ZI_RAP_BOOKING_####](sources/EX2_2_DDLS_ZI_RAP_BOOKING.txt) 171 | -------------------------------------------------------------------------------- /exercises/ex2/images/02_01_0010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/02_01_0010.png -------------------------------------------------------------------------------- /exercises/ex2/images/02_02_0010.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/02_02_0010.png -------------------------------------------------------------------------------- /exercises/ex2/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex2/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex2/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex2/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex2/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex2/images/iactivate01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/iactivate01.png -------------------------------------------------------------------------------- /exercises/ex2/images/iactivate02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/iactivate02.png -------------------------------------------------------------------------------- /exercises/ex2/images/ibookingCDS01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/ibookingCDS01.png -------------------------------------------------------------------------------- /exercises/ex2/images/ibookingCDS02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/ibookingCDS02.png -------------------------------------------------------------------------------- /exercises/ex2/images/ibookingCDS03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/ibookingCDS03.png -------------------------------------------------------------------------------- /exercises/ex2/images/itravelCDS01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/itravelCDS01.png -------------------------------------------------------------------------------- /exercises/ex2/images/itravelCDS02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/itravelCDS02.png -------------------------------------------------------------------------------- /exercises/ex2/images/itravelCDS03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex2/images/itravelCDS03.png -------------------------------------------------------------------------------- /exercises/ex2/sources/EX2_1_DDLS_ZI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @EndUserText.label: 'Travel BO view' 3 | define root view entity ZI_RAP_Travel_#### 4 | as select from zrap_atrav_#### as Travel 5 | 6 | composition [0..*] of ZI_RAP_Booking_#### as _Booking 7 | 8 | association [0..1] to /DMO/I_Agency as _Agency on $projection.AgencyID = _Agency.AgencyID 9 | association [0..1] to /DMO/I_Customer as _Customer on $projection.CustomerID = _Customer.CustomerID 10 | association [0..1] to I_Currency as _Currency on $projection.CurrencyCode = _Currency.Currency 11 | { 12 | key travel_uuid as TravelUUID, 13 | travel_id as TravelID, 14 | agency_id as AgencyID, 15 | customer_id as CustomerID, 16 | begin_date as BeginDate, 17 | end_date as EndDate, 18 | @Semantics.amount.currencyCode: 'CurrencyCode' 19 | booking_fee as BookingFee, 20 | @Semantics.amount.currencyCode: 'CurrencyCode' 21 | total_price as TotalPrice, 22 | currency_code as CurrencyCode, 23 | description as Description, 24 | overall_status as TravelStatus, 25 | @Semantics.user.createdBy: true 26 | created_by as CreatedBy, 27 | @Semantics.systemDateTime.createdAt: true 28 | created_at as CreatedAt, 29 | @Semantics.user.lastChangedBy: true 30 | last_changed_by as LastChangedBy, 31 | @Semantics.systemDateTime.lastChangedAt: true 32 | last_changed_at as LastChangedAt, 33 | @Semantics.systemDateTime.localInstanceLastChangedAt: true 34 | local_last_changed_at as LocalLastChangedAt, 35 | 36 | /* associations */ 37 | _Booking, 38 | _Agency, 39 | _Customer, 40 | _Currency 41 | } -------------------------------------------------------------------------------- /exercises/ex2/sources/EX2_2_DDLS_ZI_RAP_BOOKING.txt: -------------------------------------------------------------------------------- 1 | @AccessControl.authorizationCheck: #CHECK 2 | @EndUserText.label: 'Booking BO view' 3 | define view entity ZI_RAP_Booking_#### 4 | as select from zrap_abook_#### as Booking 5 | 6 | association to parent ZI_RAP_Travel_#### as _Travel on $projection.TravelUUID = _Travel.TravelUUID 7 | 8 | association [1..1] to /DMO/I_Customer as _Customer on $projection.CustomerID = _Customer.CustomerID 9 | association [1..1] to /DMO/I_Carrier as _Carrier on $projection.CarrierID = _Carrier.AirlineID 10 | association [1..1] to /DMO/I_Connection as _Connection on $projection.CarrierID = _Connection.AirlineID 11 | and $projection.ConnectionID = _Connection.ConnectionID 12 | association [1..1] to /DMO/I_Flight as _Flight on $projection.CarrierID = _Flight.AirlineID 13 | and $projection.ConnectionID = _Flight.ConnectionID 14 | and $projection.FlightDate = _Flight.FlightDate 15 | association [0..1] to I_Currency as _Currency on $projection.CurrencyCode = _Currency.Currency 16 | { 17 | key booking_uuid as BookingUUID, 18 | travel_uuid as TravelUUID, 19 | booking_id as BookingID, 20 | booking_date as BookingDate, 21 | customer_id as CustomerID, 22 | carrier_id as CarrierID, 23 | connection_id as ConnectionID, 24 | flight_date as FlightDate, 25 | @Semantics.amount.currencyCode: 'CurrencyCode' 26 | flight_price as FlightPrice, 27 | currency_code as CurrencyCode, 28 | @Semantics.user.createdBy: true 29 | created_by as CreatedBy, 30 | @Semantics.user.lastChangedBy: true 31 | last_changed_by as LastChangedBy, 32 | @Semantics.systemDateTime.localInstanceLastChangedAt: true 33 | local_last_changed_at as LocalLastChangedAt, 34 | 35 | /* associations */ 36 | _Travel, 37 | _Customer, 38 | _Carrier, 39 | _Connection, 40 | _Flight, 41 | _Currency 42 | 43 | } -------------------------------------------------------------------------------- /exercises/ex3/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 3 - CDS Data Model Projection 2 | 3 | ## Introduction 4 | In the previous exercise you've created the travel and the booking interface views of the CDS data model for the travel app (see [Exercise 2](/exercises/ex2/README.md)). 5 | 6 | In this exercise you will define the CDS data model projection for your travel app on top of the CDS data model. 7 | 8 | Further information can be found here: [CDS Projection View](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/448c144391764977aefea5e1984ced38.html) 9 | 10 | ## Exercise 3.1 - Create the Travel Projection View 11 | 12 | 1. Right-click on your travel BO view (aka interface view) **`ZI_RAP_Travel_####`** and choose **New Data Definition** from the context menu. 13 | 14 | ![Create Travel BO projection view](images/ctravelCDS01.png) 15 | 16 | 2. Maintain **`ZC_RAP_Travel_####`** (where `####` is your group ID) as name and a **description** (e.g. _Travel BO projection view_) in the creation wizard and choose **Next >** to continue. 17 | 18 | ![Create Travel BO projection view](images/ctravelCDS02.png) 19 | 20 | 3. Assign a transport request and choose **Finish** (please note: clicking on **Next** in the _Selection of Transport Request_ step, you get to the optional _Templates_ step in which you can choose from predefined templates). 21 | 22 | Replace the travel data definition in the editor with the code snippet provided below and replace all occurrences of `####` with your group ID. 23 | 24 | Save ![save icon](images/adt_save.png) the changes, but **DO NOT** yet activate the travel BO projection view. 25 | 26 |
 27 |     @EndUserText.label: 'Travel BO projection view'
 28 |     @AccessControl.authorizationCheck: #CHECK
 29 |     @Search.searchable: true
 30 |     @Metadata.allowExtensions: true
 31 | 
 32 |     @ObjectModel.semanticKey: ['TravelID']
 33 | 
 34 |     define root view entity ZC_RAP_Travel_####
 35 |       as projection on ZI_RAP_Travel_#### as Travel
 36 |     {
 37 |       key TravelUUID,
 38 |           @Search.defaultSearchElement: true
 39 |           TravelID,
 40 |           @Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Agency', element: 'AgencyID'} }]
 41 |           @ObjectModel.text.element: ['AgencyName']
 42 |           @Search.defaultSearchElement: true
 43 |           AgencyID,
 44 |           _Agency.Name       as AgencyName,
 45 |           @Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Customer', element: 'CustomerID'} }]
 46 |           @ObjectModel.text.element: ['CustomerName']
 47 |           @Search.defaultSearchElement: true
 48 |           CustomerID,
 49 |           _Customer.LastName as CustomerName,
 50 |           BeginDate,
 51 |           EndDate,
 52 |           @Semantics.amount.currencyCode: 'CurrencyCode'
 53 |           BookingFee,
 54 |           @Semantics.amount.currencyCode: 'CurrencyCode'
 55 |           TotalPrice,
 56 |           @Consumption.valueHelpDefinition: [{ entity: { name: 'I_Currency', element: 'Currency'} }]
 57 |           CurrencyCode,
 58 |           Description,
 59 |           TravelStatus,
 60 |           LastChangedAt,
 61 |           LocalLastChangedAt,
 62 | 
 63 |           /* Associations */
 64 |           _Agency,
 65 |           _Booking : redirected to composition child ZC_RAP_Booking_####,
 66 |           _Currency,
 67 |           _Customer   
 68 |     }
 69 |     
70 | 71 | The data definition should look as follows: 72 | 73 | ![Create Travel BO projection view](images/ctravelCDS03.png) 74 | 75 | The Travel projection view exposes all associations that are defined in the underlying travel interface view. However, the composition to the booking BO child node (**`_Booking`**) must be redirected to the Booking BO projection view. This is done using the **`redirected to composition child`** statement. 76 | 77 | ## Exercise 3.2 - Create the Booking Projection View 78 | 79 | 1. Right-click on your Booking BO view (aka interface view) **`ZI_RAP_BOOKING_####`** and choose **New Data Definition** from the context menu. 80 | 81 | ![Create Booking BO projection view](images/cbookingCDS01.png) 82 | 83 | 2. Maintain **`ZC_RAP_BOOKING_####`** (where `####` is your group ID) as name and a description (e.g. _Booking BO projection view_) in the creation wizard and choose **Next >** to continue. 84 | 85 | ![Create Booking BO projection view](images/cbookingCDS02.png) 86 | 87 | 3. Assign a transport request and choose **Finish**. Replace the booking data definition in the editor with the code snippet provided below and replace all occurrences of `####` with your group ID. 88 | 89 | Save ![save icon](images/adt_save.png) the changes, but **DO NOT** yet activate the booking BO projection view. 90 | 91 |
 92 |     @EndUserText.label: 'Booking BO projection view'
 93 |     @AccessControl.authorizationCheck: #CHECK
 94 |     @Search.searchable: true
 95 |     @Metadata.allowExtensions: true
 96 | 
 97 |     define view entity ZC_RAP_Booking_####
 98 |       as projection on ZI_RAP_Booking_#### as Booking
 99 |     {
100 |       key BookingUUID,
101 |           TravelUUID,
102 |           @Search.defaultSearchElement: true
103 |           BookingID,
104 |           BookingDate,
105 |           @Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Customer', element: 'CustomerID'  } }]
106 |           @ObjectModel.text.element: ['CustomerName']
107 |           @Search.defaultSearchElement: true
108 |           CustomerID,
109 |           _Customer.LastName as CustomerName,
110 |           @Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Carrier', element: 'AirlineID' }}]
111 |           @ObjectModel.text.element: ['CarrierName']
112 |           CarrierID,
113 |           _Carrier.Name      as CarrierName,
114 |           @Consumption.valueHelpDefinition: [ {entity: {name: '/DMO/I_Flight', element: 'ConnectionID'},
115 |                                                additionalBinding: [ { localElement: 'CarrierID',    element: 'AirlineID' },
116 |                                                                     { localElement: 'FlightDate',   element: 'FlightDate',   usage: #RESULT},
117 |                                                                     { localElement: 'FlightPrice',  element: 'Price',        usage: #RESULT },
118 |                                                                     { localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ] } ]
119 |           ConnectionID,
120 |           FlightDate,
121 |           @Semantics.amount.currencyCode: 'CurrencyCode'
122 |           FlightPrice,
123 |           @Consumption.valueHelpDefinition: [{entity: {name: 'I_Currency', element: 'Currency' }}]
124 |           CurrencyCode,
125 |           LocalLastChangedAt,
126 | 
127 |           /* associations */
128 |           _Travel : redirected to parent ZC_RAP_Travel_####,
129 |           _Customer,
130 |           _Carrier,
131 |           _Connection,
132 |           _Flight
133 | 
134 |     }
135 |     
136 | 137 | The data definition now looks as follows: 138 | 139 | ![Create Booking BO projection view](images/cbookingCDS03.png) 140 | 141 | The association to the travel BO parent node has been redirected to the Travel BO projection view using the **`redirect to parent`** statement. 142 | 143 | ## Exercise 3.3 - Activate the CDS Data Model Projection 144 | To avoid error during the activation, both new CDS projection views – i.e. Travel view and Booking view – must be activated together for the first time. 145 | 146 | 1. Choose **`Activate All`** ![activate all icon](images/adt_activate_all.png) or use the shortcut **Ctrl+Shift+F3** to active both CDS views together. 147 | 148 | ![Activate CDS Data Model Projection](images/cactivate01.png) 149 | 150 | Your projected CDS data model consisting of the Travel BO projection view and the Booking BO projection view is now activated. 151 | 152 | 153 | ## Summary 154 | 155 | Now that you've... 156 | - created both CDS projection views and 157 | - activated them using mass activation, 158 | 159 | you can continue with - [Exercise 4 - Metadata Extensions](../ex4/README.md) 160 | 161 | ## Appendix 162 | 163 | Find the source code for the CDS views in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 164 | 165 | - [CDS View ZC_RAP_TRAVEL_####](sources/EX3_1_DDLS_ZC_RAP_TRAVEL.txt) 166 | - [CDS View ZC_RAP_BOOKING_####](sources/EX3_2_DDLS_ZC_RAP_BOOKING.txt) 167 | -------------------------------------------------------------------------------- /exercises/ex3/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex3/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex3/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex3/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex3/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex3/images/cactivate01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/cactivate01.png -------------------------------------------------------------------------------- /exercises/ex3/images/cbookingCDS01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/cbookingCDS01.png -------------------------------------------------------------------------------- /exercises/ex3/images/cbookingCDS02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/cbookingCDS02.png -------------------------------------------------------------------------------- /exercises/ex3/images/cbookingCDS03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/cbookingCDS03.png -------------------------------------------------------------------------------- /exercises/ex3/images/ctravelCDS01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/ctravelCDS01.png -------------------------------------------------------------------------------- /exercises/ex3/images/ctravelCDS02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/ctravelCDS02.png -------------------------------------------------------------------------------- /exercises/ex3/images/ctravelCDS03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex3/images/ctravelCDS03.png -------------------------------------------------------------------------------- /exercises/ex3/sources/EX3_1_DDLS_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @EndUserText.label: 'Travel BO projection view' 2 | @AccessControl.authorizationCheck: #CHECK 3 | @Search.searchable: true 4 | @Metadata.allowExtensions: true 5 | 6 | @ObjectModel.semanticKey: ['TravelID'] 7 | 8 | define root view entity ZC_RAP_Travel_#### 9 | as projection on ZI_RAP_Travel_#### as Travel 10 | { 11 | key TravelUUID, 12 | @Search.defaultSearchElement: true 13 | TravelID, 14 | @Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Agency', element: 'AgencyID'} }] 15 | @ObjectModel.text.element: ['AgencyName'] 16 | @Search.defaultSearchElement: true 17 | AgencyID, 18 | _Agency.Name as AgencyName, 19 | @Consumption.valueHelpDefinition: [{ entity: { name: '/DMO/I_Customer', element: 'CustomerID'} }] 20 | @ObjectModel.text.element: ['CustomerName'] 21 | @Search.defaultSearchElement: true 22 | CustomerID, 23 | _Customer.LastName as CustomerName, 24 | BeginDate, 25 | EndDate, 26 | @Semantics.amount.currencyCode: 'CurrencyCode' 27 | BookingFee, 28 | @Semantics.amount.currencyCode: 'CurrencyCode' 29 | TotalPrice, 30 | @Consumption.valueHelpDefinition: [{ entity: { name: 'I_Currency', element: 'Currency'} }] 31 | CurrencyCode, 32 | Description, 33 | TravelStatus, 34 | LastChangedAt, 35 | LocalLastChangedAt, 36 | 37 | /* Associations */ 38 | _Agency, 39 | _Booking : redirected to composition child ZC_RAP_Booking_####, 40 | _Currency, 41 | _Customer 42 | } 43 | -------------------------------------------------------------------------------- /exercises/ex3/sources/EX3_2_DDLS_ZC_RAP_BOOKING.txt: -------------------------------------------------------------------------------- 1 | @EndUserText.label: 'Booking BO projection view' 2 | @AccessControl.authorizationCheck: #CHECK 3 | @Search.searchable: true 4 | @Metadata.allowExtensions: true 5 | 6 | define view entity ZC_RAP_Booking_#### 7 | as projection on ZI_RAP_Booking_#### as Booking 8 | { 9 | key BookingUUID, 10 | TravelUUID, 11 | @Search.defaultSearchElement: true 12 | BookingID, 13 | BookingDate, 14 | @Consumption.valueHelpDefinition: [{ entity : {name: '/DMO/I_Customer', element: 'CustomerID' } }] 15 | @ObjectModel.text.element: ['CustomerName'] 16 | @Search.defaultSearchElement: true 17 | CustomerID, 18 | _Customer.LastName as CustomerName, 19 | @Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Carrier', element: 'AirlineID' }}] 20 | @ObjectModel.text.element: ['CarrierName'] 21 | CarrierID, 22 | _Carrier.Name as CarrierName, 23 | @Consumption.valueHelpDefinition: [ {entity: {name: '/DMO/I_Flight', element: 'ConnectionID'}, 24 | additionalBinding: [ { localElement: 'CarrierID', element: 'AirlineID' }, 25 | { localElement: 'FlightDate', element: 'FlightDate', usage: #RESULT}, 26 | { localElement: 'FlightPrice', element: 'Price', usage: #RESULT }, 27 | { localElement: 'CurrencyCode', element: 'CurrencyCode', usage: #RESULT } ] } ] 28 | ConnectionID, 29 | FlightDate, 30 | @Semantics.amount.currencyCode: 'CurrencyCode' 31 | FlightPrice, 32 | @Consumption.valueHelpDefinition: [{entity: {name: 'I_Currency', element: 'Currency' }}] 33 | CurrencyCode, 34 | LocalLastChangedAt, 35 | 36 | /* associations */ 37 | _Travel : redirected to parent ZC_RAP_Travel_####, 38 | _Customer, 39 | _Carrier, 40 | _Connection, 41 | _Flight 42 | 43 | } -------------------------------------------------------------------------------- /exercises/ex4/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 4 - Metadata Extensions 2 | 3 | ## Introduction 4 | In the previous exercise you've created the travel and the booking projection views of the CDS data model for the travel app (see [Exercise 3](/exercises/ex3/README.md)). 5 | 6 | In this exercise you will enrich your CDS data model projection with UI metadata. This metadata defines e.g. the columns and fields shown on the list report page as well as on the object page in the SAP Fiori elements Travel app. 7 | 8 | Further information can be found here: [Metadata Extensions](https://help.sap.com/viewer/f859579898c7494dbe2449bb7f278dcc/Cloud/en-US/a3ff1dc494a242ef98d1e22670e1546a.html) 9 | 10 | ## Exercise 4.1 - Annotate the Travel Projection View 11 | 12 | 1. Right-click on your Travel BO projection view **`ZC_RAP_Travel_####`** in the Project Explorer and select **New Metadata Extension** from the context menu. 13 | 14 | ![Create Travel MDE](images/travelmde01.png) 15 | 16 | 2. Maintain **`ZC_RAP_Travel_####`** (where `####` is your group ID) as name and a description (e.g. _UI Annotations for ZC\_RAP\_Travel\_####_) and choose _**Next >**_ to continue. 17 | 18 | ![Create Travel MDE](images/travelmde02.png) 19 | 20 | 3. Assign a transport request and choose **Finish** (please note: clicking on **Next** in the _Selection of Transport Request_ step, you get to the optional _Templates_ step in which you can choose from predefined templates). 21 | 22 | Replace the code in the editor with the code provided below and replace all occurrences of `####` with your group ID. 23 | 24 |
 25 |     @Metadata.layer: #CORE
 26 |     @UI: {
 27 |       headerInfo: { typeName: 'Travel',
 28 |                     typeNamePlural: 'Travels',
 29 |                     title: { type: #STANDARD, label: 'Travel', value: 'TravelID' } },
 30 |       presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction:  #DESC }], visualizations: [{type: #AS_LINEITEM}] }] }
 31 | 
 32 |     annotate view ZC_RAP_Travel_#### with
 33 |     {
 34 |       @UI.facet: [ { id:              'Travel',
 35 |                      purpose:         #STANDARD,
 36 |                      type:            #IDENTIFICATION_REFERENCE,
 37 |                      label:           'Travel',
 38 |                      position:        10 },
 39 |                    { id:              'Booking',
 40 |                      purpose:         #STANDARD,
 41 |                      type:            #LINEITEM_REFERENCE,
 42 |                      label:           'Booking',
 43 |                      position:        20,
 44 |                      targetElement:   '_Booking'} ]
 45 | 
 46 |       @UI:{ identification: [{ position: 1, label: 'Travel UUID' }] }
 47 |       TravelUUID;
 48 | 
 49 |       @UI: {  lineItem:       [ { position: 10 } ],
 50 |               identification: [ { position: 10 } ],
 51 |               selectionField: [ { position: 10 } ] }
 52 |       TravelID;
 53 | 
 54 |       @UI: {  lineItem:       [ { position: 20 } ],
 55 |               identification: [ { position: 20 } ],
 56 |               selectionField: [ { position: 20 } ] }
 57 |       AgencyID;
 58 | 
 59 |       @UI: {  lineItem:       [ { position: 30 } ],
 60 |               identification: [ { position: 30 } ],
 61 |               selectionField: [ { position: 30 } ] }
 62 |       CustomerID;
 63 | 
 64 |       @UI: {  lineItem:       [ { position: 40 } ],
 65 |               identification: [ { position: 40 } ] }
 66 |       BeginDate;
 67 | 
 68 |       @UI: {  lineItem:       [ { position: 50 } ],
 69 |               identification: [ { position: 50 } ] }
 70 |       EndDate;
 71 | 
 72 |       @UI: {  lineItem:       [ { position: 60 } ],
 73 |               identification: [ { position: 60 } ] }
 74 |       BookingFee;
 75 | 
 76 |       @UI: {  lineItem:       [ { position: 70 } ],
 77 |               identification: [ { position: 70 } ] }
 78 |       TotalPrice;
 79 | 
 80 |       @UI: {  lineItem:       [ { position: 80 } ],
 81 |               identification: [ { position: 80 } ] }
 82 |       Description;
 83 | 
 84 |       @UI: {  lineItem:       [ { position: 90 }
 85 |     //                          , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' },
 86 |     //                            { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' }
 87 |                               ],
 88 |               identification: [ { position: 90 }
 89 |     //                          , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' },
 90 |     //                            { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' }
 91 |                               ] } 
 92 |       TravelStatus;
 93 | 
 94 |       @UI.hidden: true
 95 |       LastChangedAt;
 96 | 
 97 |       @UI.hidden: true
 98 |       LocalLastChangedAt;
 99 | 
100 |       @UI.selectionField: [{ element: '_Booking.CarrierID', position: 40 }]
101 |       _Booking;
102 |     }
103 |     
104 | 105 | The results looks as follows: 106 | 107 | ![Create Travel MDE](images/travelmde03.png) 108 | 109 | 4. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the changes. 110 | 111 | ## Exercise 4.2 - Annotate the Booking Projection View 112 | 113 | 1. Right-click on your Booking BO projection view **`ZC_RAP_Booking_####`** in the Project Explorer and choose **New Metadata Extension** from the context menu. 114 | 115 | ![Create Booking MDE](images/bookingmde01.png) 116 | 117 | 2. Maintain **`ZC_RAP_Booking_####`** (where `####` is your group ID) as name and a description (e.g. _UI Annotations for ZC\_RAP\_Booking\_####_) and choose **Next >** to continue. 118 | 119 | ![Create Booking MDE](images/bookingmde02.png) 120 | 121 | 3. Assign a transport request and choose **Finish**. Replace the code in the editor with the code provided below and replace all occurrences of `####` with your group ID. 122 | 123 |
124 |     @Metadata.layer: #CORE
125 |     @UI: {
126 |       headerInfo: { typeName: 'Booking',
127 |                     typeNamePlural: 'Bookings',
128 |                     title: { type: #STANDARD, value: 'BookingID' } } }
129 | 
130 |     annotate view ZC_RAP_Booking_#### with
131 |     {
132 |       @UI.facet: [ { id:            'Booking',
133 |                      purpose:       #STANDARD,
134 |                      type:          #IDENTIFICATION_REFERENCE,
135 |                      label:         'Booking',
136 |                      position:      10 }  ]
137 | 
138 |       @UI: { identification: [ { position: 10, label: 'Booking UUID'  } ] }
139 |       BookingUUID;
140 | 
141 |       @UI.hidden: true
142 |       TravelUUID;
143 | 
144 |       @UI: { lineItem:       [ { position: 20 } ],
145 |              identification: [ { position: 20 } ] }
146 |       BookingID;
147 | 
148 |       @UI: { lineItem:       [ { position: 30 } ],
149 |              identification: [ { position: 30 } ] }
150 |       BookingDate;
151 | 
152 |       @UI: { lineItem:       [ { position: 40 } ],
153 |              identification: [ { position: 40 } ] }
154 |       CustomerID;
155 | 
156 |       @UI: { lineItem:       [ { position: 50 } ],
157 |              identification: [ { position: 50 } ] }
158 |       CarrierID;
159 | 
160 |       @UI: { lineItem:       [ { position: 60 } ],
161 |              identification: [ { position: 60 } ] }
162 |       ConnectionID;
163 | 
164 |       @UI: { lineItem:       [ { position: 70 } ],
165 |              identification: [ { position: 70 } ] }
166 |       FlightDate;
167 | 
168 |       @UI: { lineItem:       [ { position: 80 } ],
169 |              identification: [ { position: 80 } ] }
170 |       FlightPrice;
171 | 
172 |       @UI.hidden: true
173 |       LocalLastChangedAt;
174 |     }
175 |     
176 | 177 | 4. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the changes. 178 | 179 | ## Summary 180 | 181 | Now that you've... 182 | - created both metadata extensions for the CDS projection views, 183 | 184 | you can continue with - [Exercise 5 - Business Service](../ex5/README.md) 185 | 186 | ## Appendix 187 | 188 | Find the source code for the CDS views in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 189 | 190 | - [Metadata Extension ZC_RAP_TRAVEL_####](sources/EX4_1_DDLX_ZC_RAP_TRAVEL.txt) 191 | - [Metadata Extension ZC_RAP_BOOKING_####](sources/EX4_2_DDLX_ZC_RAP_BOOKING.txt) 192 | -------------------------------------------------------------------------------- /exercises/ex4/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex4/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex4/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex4/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex4/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex4/images/bookingmde01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/bookingmde01.png -------------------------------------------------------------------------------- /exercises/ex4/images/bookingmde02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/bookingmde02.png -------------------------------------------------------------------------------- /exercises/ex4/images/bookingmde03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/bookingmde03.png -------------------------------------------------------------------------------- /exercises/ex4/images/travelmde01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/travelmde01.png -------------------------------------------------------------------------------- /exercises/ex4/images/travelmde02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/travelmde02.png -------------------------------------------------------------------------------- /exercises/ex4/images/travelmde03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex4/images/travelmde03.png -------------------------------------------------------------------------------- /exercises/ex4/sources/EX4_1_DDLX_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @Metadata.layer: #CORE 2 | @UI: { 3 | headerInfo: { typeName: 'Travel', 4 | typeNamePlural: 'Travels', 5 | title: { type: #STANDARD, label: 'Travel', value: 'TravelID' } }, 6 | presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction: #DESC }], visualizations: [{type: #AS_LINEITEM}] }] } 7 | 8 | annotate view ZC_RAP_Travel_#### with 9 | { 10 | @UI.facet: [ { id: 'Travel', 11 | purpose: #STANDARD, 12 | type: #IDENTIFICATION_REFERENCE, 13 | label: 'Travel', 14 | position: 10 }, 15 | { id: 'Booking', 16 | purpose: #STANDARD, 17 | type: #LINEITEM_REFERENCE, 18 | label: 'Booking', 19 | position: 20, 20 | targetElement: '_Booking'} ] 21 | 22 | @UI:{ identification: [{ position: 1, label: 'Travel UUID' }] } 23 | TravelUUID; 24 | 25 | @UI: { lineItem: [ { position: 10 } ], 26 | identification: [ { position: 10 } ], 27 | selectionField: [ { position: 10 } ] } 28 | TravelID; 29 | 30 | @UI: { lineItem: [ { position: 20 } ], 31 | identification: [ { position: 20 } ], 32 | selectionField: [ { position: 20 } ] } 33 | AgencyID; 34 | 35 | @UI: { lineItem: [ { position: 30 } ], 36 | identification: [ { position: 30 } ], 37 | selectionField: [ { position: 30 } ] } 38 | CustomerID; 39 | 40 | @UI: { lineItem: [ { position: 40 } ], 41 | identification: [ { position: 40 } ] } 42 | BeginDate; 43 | 44 | @UI: { lineItem: [ { position: 50 } ], 45 | identification: [ { position: 50 } ] } 46 | EndDate; 47 | 48 | @UI: { lineItem: [ { position: 60 } ], 49 | identification: [ { position: 60 } ] } 50 | BookingFee; 51 | 52 | @UI: { lineItem: [ { position: 70 } ], 53 | identification: [ { position: 70 } ] } 54 | TotalPrice; 55 | 56 | @UI: { lineItem: [ { position: 80 } ], 57 | identification: [ { position: 80 } ] } 58 | Description; 59 | 60 | @UI: { lineItem: [ { position: 90 } 61 | // , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' }, 62 | // { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } 63 | ], 64 | identification: [ { position: 90 } 65 | // , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' }, 66 | // { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } 67 | ] } 68 | TravelStatus; 69 | 70 | @UI.hidden: true 71 | LastChangedAt; 72 | 73 | @UI.hidden: true 74 | LocalLastChangedAt; 75 | 76 | @UI.selectionField: [{ element: '_Booking.CarrierID', position: 40 }] 77 | _Booking; 78 | } 79 | -------------------------------------------------------------------------------- /exercises/ex4/sources/EX4_2_DDLX_ZC_RAP_BOOKING.txt: -------------------------------------------------------------------------------- 1 | @Metadata.layer: #CORE 2 | @UI: { 3 | headerInfo: { typeName: 'Booking', 4 | typeNamePlural: 'Bookings', 5 | title: { type: #STANDARD, value: 'BookingID' } } } 6 | 7 | annotate view ZC_RAP_Booking_#### with 8 | { 9 | @UI.facet: [ { id: 'Booking', 10 | purpose: #STANDARD, 11 | type: #IDENTIFICATION_REFERENCE, 12 | label: 'Booking', 13 | position: 10 } ] 14 | 15 | @UI: { identification: [ { position: 10, label: 'Booking UUID' } ] } 16 | BookingUUID; 17 | 18 | @UI.hidden: true 19 | TravelUUID; 20 | 21 | @UI: { lineItem: [ { position: 20 } ], 22 | identification: [ { position: 20 } ] } 23 | BookingID; 24 | 25 | @UI: { lineItem: [ { position: 30 } ], 26 | identification: [ { position: 30 } ] } 27 | BookingDate; 28 | 29 | @UI: { lineItem: [ { position: 40 } ], 30 | identification: [ { position: 40 } ] } 31 | CustomerID; 32 | 33 | @UI: { lineItem: [ { position: 50 } ], 34 | identification: [ { position: 50 } ] } 35 | CarrierID; 36 | 37 | @UI: { lineItem: [ { position: 60 } ], 38 | identification: [ { position: 60 } ] } 39 | ConnectionID; 40 | 41 | @UI: { lineItem: [ { position: 70 } ], 42 | identification: [ { position: 70 } ] } 43 | FlightDate; 44 | 45 | @UI: { lineItem: [ { position: 80 } ], 46 | identification: [ { position: 80 } ] } 47 | FlightPrice; 48 | 49 | @UI.hidden: true 50 | LocalLastChangedAt; 51 | } -------------------------------------------------------------------------------- /exercises/ex5/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 5 - Business Service 2 | 3 | ## Introduction 4 | In the previous exercise you've created the metadata extensions for the travel and the booking projection views (see [Exercise 4](/exercises/ex4/README.md) or the Fast track version [Exercises 1-4](/exercises/ex1_4/README.md)). 5 | 6 | In this exercise you will expose your projected CDS data model as OData service using business services – i.e. service definition and service binding. 7 | 8 | Further information can be found here: [Business Service](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/1913ad9f52e64ab5858df00a8d20c4d6.html) 9 | 10 | ## Exercise 5.1 - Create the Service Definition 11 | The service definition specifies the service scope, i.e. the relevant entity sets to be exposed in the service. 12 | 13 | 1. In the Project Explorer, right-click on the Travel BO projection view **`ZC_RAP_TRAVEL_####`** and select **New Service Definition** from the context menu. 14 | 15 | ![Create Service Definition](images/servicedefinition01.png) 16 | 17 | 2. Maintain **`ZUI_RAP_Travel_####`** (where `####` is your group ID) as **name** and a **description** (e.g. _`Serv Definition for Travel App`_ ) in the creation wizard and choose **Next >** to continue. 18 | 19 | ![Create Service Definition](images/servicedefinition02.png) 20 | 21 | 3. Assign a transport request and choose **Finish**. Replace the code in the editor with the code snippet provided below. Do not forget to replace all the occurrences of `####` with your group ID. 22 | 23 |
 24 |     @EndUserText.label: 'Serv Definition for Travel App'
 25 |     define service ZUI_RAP_TRAVEL_#### {
 26 |       expose ZC_RAP_Travel_#### as Travel;
 27 |       expose ZC_RAP_Booking_#### as Booking;
 28 |       expose /DMO/I_Agency as Agency;
 29 |       expose /DMO/I_Customer as Customer;
 30 |       expose /DMO/I_Flight as Flight;
 31 |       expose /DMO/I_Carrier as Carrier;
 32 |       expose /DMO/I_Connection as Connection;
 33 |       expose /DMO/I_Airport as Airport;
 34 |       expose I_Currency as Currency;
 35 |       expose I_Country as country;
 36 |     }
 37 |     
38 | 39 | The service definition will look as follows: 40 | 41 | ![Create Service Definition](images/servicedefinition03.png) 42 | 43 | 6. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the service definition. 44 | 45 | ## Exercise 5.2 - Create the Service Binding 46 | 47 | The service binding binds your service definition to the required protocol. 48 | 49 | 1. Right-click on the just created service definition **`ZUI_RAP_TRAVEL_####`** in the project Explorer and choose **New Service Binding** from the context menu. 50 | 51 | ![Create Service Binding](images/servicebinding01.png) 52 | 53 | 2. Maintain **`ZUI_RAP_TRAVEL_O4_####`** (where `####` is your group ID) as name and a description (e.g. _`OData V4 UI service for SAP Fiori Travel App`_, choose **`OData V4 - UI`** as Binding Type and choose **Next >** to continue. 54 | 55 | ![Create Service Binding](images/servicebinding02.png) 56 | 57 | 3. Assign a transport request and choose **Finish**. The editor opens with the created service binding. 58 | 59 | ![Create Service Binding](images/servicebinding03.png) 60 | 61 | 4. Activate ![activate icon](images/adt_activate.png) the service binding which enables the **Publish** button. Click on **Publish**. 62 | 63 | ![Create Service Binding](images/servicebinding04.png) 64 | 65 | 5. This locally publishes the service binding, providing access authorization to all users with a developer role. On the right-hand-side of the _Service Binding_ editor, the relative service URL and the exposed entity sets as well as associations are shown. 66 | 67 | ![Create Service Binding](images/servicebinding05.png) 68 | 69 | ## Exercise 5.3 - Preview the Travel App 70 | 71 | 1. In the service binding, choose the `Travel` node in _**Entity Set and Association**_ area and either right-click on it and choose _**Open Fiori elements App preview**_ from the context menu or simply double-click on it – or choose the **Preview** button. 72 | 73 | ![Travel App Preview](images/preview01.png) 74 | 75 | Your SAP Fiori elements-based Travel List Report app will open in the browser. You might need to provide your login information (email address / password) to connect to the trial account. 76 | 77 | > Note: In case you are getting an **Application could not be started due to technical issues.**, **Service group '...' not published** error please wait some time and refresh **F5** the browser. It may take a while until the app servers are synchronized. There is no need to e.g. unpublish/publish the service again. 78 | 79 | 2. Press the **Go** button to load the data. 80 | 81 | ![Travel App Preview](images/preview02.png) 82 | 83 | You can now explore the Travel App. 84 | For example, 85 | - Filter bar: Filter the entries by an **`AgencyID`** using the defined value help 86 | - Perform a full text search (e.g. for **`Pan`**) 87 | - Navigate to the detail object page of a travel record in the travel table list. 88 | - Check out the travel object page with its two facets Travel and Booking and navigate to the booking object page. 89 | 90 | ## Summary 91 | 92 | Now that you've... 93 | - created the service definition specifying the scope of the service exposure, 94 | - created an OData V4 service binding and published it locally, and 95 | - used the SAP Fiori Elements App Preview to run the app, 96 | 97 | you can continue with - [Exercise 6 - Business Object Behavior](../ex6/README.md) 98 | 99 | ## Appendix 100 | 101 | Find the source code for the service definition in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 102 | 103 | - [Service Definition ZUI_RAP_TRAVEL_####](sources/EX5_1_SRVD_ZUI_RAP_TRAVEL.txt) 104 | -------------------------------------------------------------------------------- /exercises/ex5/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex5/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex5/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex5/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex5/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex5/images/preview01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/preview01.png -------------------------------------------------------------------------------- /exercises/ex5/images/preview02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/preview02.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicebinding01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicebinding01.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicebinding02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicebinding02.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicebinding03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicebinding03.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicebinding04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicebinding04.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicebinding05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicebinding05.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicedefinition01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicedefinition01.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicedefinition02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicedefinition02.png -------------------------------------------------------------------------------- /exercises/ex5/images/servicedefinition03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex5/images/servicedefinition03.png -------------------------------------------------------------------------------- /exercises/ex5/sources/EX5_1_SRVD_ZUI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @EndUserText.label: 'Serv Definition for Travel App' 2 | define service ZUI_RAP_TRAVEL_#### { 3 | expose ZC_RAP_Travel_#### as Travel; 4 | expose ZC_RAP_Booking_#### as Booking; 5 | expose /DMO/I_Agency as Agency; 6 | expose /DMO/I_Customer as Customer; 7 | expose /DMO/I_Flight as Flight; 8 | expose /DMO/I_Carrier as Carrier; 9 | expose /DMO/I_Connection as Connection; 10 | expose /DMO/I_Airport as Airport; 11 | expose I_Currency as Currency; 12 | expose I_Country as country; 13 | } -------------------------------------------------------------------------------- /exercises/ex6/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex6/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex6/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex6/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex6/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef01.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef02.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef03.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef04.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef05.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef06.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef07.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef08.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef09.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef10.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef11.png -------------------------------------------------------------------------------- /exercises/ex6/images/basebdef12.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/basebdef12.png -------------------------------------------------------------------------------- /exercises/ex6/images/preview01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/preview01.png -------------------------------------------------------------------------------- /exercises/ex6/images/preview02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/preview02.png -------------------------------------------------------------------------------- /exercises/ex6/images/projectionbdef01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/projectionbdef01.png -------------------------------------------------------------------------------- /exercises/ex6/images/projectionbdef02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/projectionbdef02.png -------------------------------------------------------------------------------- /exercises/ex6/images/projectionbdef03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex6/images/projectionbdef03.png -------------------------------------------------------------------------------- /exercises/ex6/sources/EX6_1_BDEF_ZI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | managed; 2 | with draft; 3 | 4 | define behavior for ZI_RAP_Travel_#### alias Travel 5 | implementation in class zbp_i_rap_travel_#### unique 6 | persistent table zrap_atrav_#### 7 | draft table zrap_dtrav_#### 8 | lock master total etag LastChangedAt 9 | etag master LocalLastChangedAt 10 | { 11 | create; 12 | update; 13 | delete; 14 | association _Booking { create; with draft; } 15 | 16 | field ( numbering : managed, readonly ) TravelUUID; 17 | field ( readonly ) TravelId, TotalPrice, TravelStatus; 18 | field ( readonly ) LastChangedAt, LastChangedBy, CreatedAt, CreatedBy, LocalLastChangedAt; 19 | field ( mandatory ) AgencyID, CustomerID; 20 | 21 | mapping for zrap_atrav_#### 22 | { 23 | TravelUUID = travel_uuid; 24 | TravelID = travel_id; 25 | AgencyID = agency_id; 26 | CustomerID = customer_id; 27 | BeginDate = begin_date; 28 | EndDate = end_date; 29 | BookingFee = booking_fee; 30 | TotalPrice = total_price; 31 | CurrencyCode = currency_code; 32 | Description = description; 33 | TravelStatus = overall_status; 34 | CreatedBy = created_by; 35 | CreatedAt = created_at; 36 | LastChangedBy = last_changed_by; 37 | LastChangedAt = last_changed_at; 38 | LocalLastChangedAt = local_last_changed_at; 39 | } 40 | } 41 | 42 | define behavior for ZI_RAP_Booking_#### alias Booking 43 | implementation in class zbp_i_rap_booking_#### unique 44 | persistent table zrap_abook_#### 45 | draft table zrap_dbook_#### 46 | lock dependent by _Travel 47 | etag master LocalLastChangedAt 48 | { 49 | update; 50 | delete; 51 | 52 | association _Travel { with draft; } 53 | 54 | field ( numbering : managed, readonly ) BookingUUID; 55 | field ( readonly ) TravelUUID, BookingId; 56 | field ( readonly ) CreatedBy, LastChangedBy, LocalLastChangedAt; 57 | 58 | mapping for zrap_abook_#### 59 | { 60 | BookingUUID = booking_uuid; 61 | TravelUUID = travel_uuid; 62 | BookingID = booking_id; 63 | BookingDate = booking_date; 64 | CustomerID = customer_id; 65 | CarrierID = carrier_id; 66 | ConnectionID = connection_id; 67 | FlightDate = flight_date; 68 | FlightPrice = flight_price; 69 | CurrencyCode = currency_code; 70 | CreatedBy = created_by; 71 | LastChangedBy = last_changed_by; 72 | LocalLastChangedAt = local_last_changed_at; 73 | } 74 | } -------------------------------------------------------------------------------- /exercises/ex6/sources/EX6_2_BDEF_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | projection; 2 | use draft; 3 | 4 | define behavior for ZC_RAP_Travel_#### alias Travel 5 | use etag 6 | { 7 | use create; 8 | use update; 9 | use delete; 10 | 11 | use association _Booking { create; with draft; } 12 | } 13 | 14 | define behavior for ZC_RAP_Booking_#### alias Booking 15 | use etag 16 | { 17 | use update; 18 | use delete; 19 | 20 | use association _Travel { with draft; } 21 | } -------------------------------------------------------------------------------- /exercises/ex7/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 7 - Actions 2 | 3 | ## Introduction 4 | In the previous exercise you've created the base behavior definition and the behavior definition projection (see [Exercise 6](/exercises/ex6/README.md)). 5 | 6 | In this exercise you will add the actions acceptTravel and rejectTravel that will be offered as buttons in the Fiori app. Both actions will also make use of the instance specific feature control to enable/disable the buttons based on the current travel status. 7 | 8 | You will furthermore add an internal action that is used to recalculate the total price. 9 | 10 | Further information can be found here: [Actions](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/83bad707a5a241a2ae93953d81d17a6b.html) 11 | 12 | > Please note: This exercise, as well as the subsequent ones require the use of the Entity Manipulation Language (EML) which is part of the ABAP language providing type-safe read and modifying access to RAP business objects. Further information can be found here: [Entity Manipulation Language (EML)](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/af7782de6b9140e29a24eae607bf4138.html) 13 | 14 | ## Exercise 7.1 - Base Behavior Definition 15 | 1. Open the base behavior definition **`ZI_RAP_Travel_####`** – where **`####`** is your group ID – of your business object by either double-clicking on it in the _Project Explorer_ or using the shortcut **Ctrl+Shift+A** (_Open ABAP Development Object_). 16 | 17 | 2. Add the following lines into the **Travel** entity, right after the `field` statements. 18 | 19 |
 20 |     action ( features : instance ) acceptTravel result [1] $self;
 21 |     action ( features : instance ) rejectTravel result [1] $self;
 22 |     internal action recalcTotalPrice;
 23 |     
24 | 25 | Your base behavior definition should look as follows: 26 | 27 | ![Actions](images/action01.png) 28 | 29 | 3. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior definition. 30 | 31 | 4. Click on any of the 3 Quick Fix markers to open the Quick Fix context menu. Choose **Add all 3 missing methods of entity zi_rap_travel_#### in local handler class zbp_i_rap_travel_####->lhc_travel**. 32 | 33 | ![Actions](images/action02.png) 34 | 35 | 5. This is to demonstrate how to add method declarations into existing behavior implementation classes when adding more capabilities to the business object. The adjusted behavior implementation class (**Local Types** tab) looks as follows: 36 | 37 | ![Actions](images/action03.png) 38 | 39 | 6. Replace the **entire** code of the behavior implementation class **zbp_i_rap_travel_####** (Local Types tab) with the following coding and replace all occurrences of `####` with your group ID: 40 | 41 | > Find the source code here: [Behavior Implementation Class ZBP_I_RAP_TRAVEL_####](sources/EX7_1_CLAS_ZBP_I_RAP_TRAVEL.txt) 42 | 43 | This implements all four methods and declares the constants for the travel status. 44 | 45 | The **acceptTravel** and **rejectTravel** methods are almost identical. Both make use of the EML to modify the overall status for the provided travel instances. The `keys` table is filled by the framework and contains the keys of all instances the action is executed on. 46 | 47 | The named include `%tky` is the so-called **transactional key**. For draft-enabled BOs it consists of the `%is_draft` indicator followed by the key of the entity (in this example `traveluuid` ). 48 | 49 | In EML the addition **IN LOCAL MODE** is used for business object internal operations. It behaves like a private method call, and e.g. skips the feature and authorization control. 50 | 51 | The result table is filled with the updated instances as defined in the base behavior definition (`result [1] $self;`). This avoids another round trip for UI related use cases to fetch the updated data. 52 | 53 | The **get_features** method implements the instance specific feature control (also called dynamic feature control). In the current example it enables/disables the acceptTravel and rejectTravel actions based on the current travel status. Instance specific capabilities have to be implemented in this method once the related feature is declared with `( features : instance )` in the base behavior definition. Further information can be found here: [Instance Feature Control Implementation: Dynamic Feature Control](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/9ee0a7073fef4f889e85862114b85fdd.html) 54 | 55 | The **recalctotalprice** method is the implementation for the internal action `recalcTotalPrice` that we will use in the next exercise when adding determinations to the behavior definition. The method calculates the total price, summing up all flight prices and adding the booking fee on top. If required, the calculation performs a currency conversion. 56 | 57 | 7. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the class. 58 | 59 | ## Exercise 7.2 - Behavior Definition Projection 60 | Those actions, that need to be available in the exposed service need to be added to the behavior definition projection. In the current example this is required for the actions **acceptTravel** and **rejectTravel**. 61 | 62 | 1. Open the behavior definition projection **`ZC_RAP_Travel_####`** – where **`####`** is your group ID – of your business object by either double-clicking on it in the _Project Explorer_ or using the shortcut **Ctrl+Shift+A** (_Open ABAP Development Object_). 63 | 64 | 2. Add the following lines into the **Travel** entity, right after the `use association _Booking` statement. 65 | 66 |
 67 |     use action acceptTravel;
 68 |     use action rejectTravel;
 69 |     
70 | 71 | Your behavior definition projection should look as follows: 72 | 73 | ![Actions](images/action04.png) 74 | 75 | 3. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior definition. 76 | 77 | ## Exercise 7.3 - Metadata Extension 78 | For the actions to become available as buttons on the Fiori Elements UI you need to add corresponding UI annotations. This is done in the metadata extension for the travel entity. 79 | 80 | 1. Open the metadata extension **`ZC_RAP_TRAVEL_####`** – where **`####`** is your group ID – by either double-clicking on it in the _Project Explorer_ or using the shortcut **Ctrl+Shift+A** (_Open ABAP Development Object_). 81 | 82 | > Please note: If you are carrying out the **FAST TRACK** version of DEV260, then skip step 7.3.2 and go ahead with 7.3.3 directly. 83 | 84 | 2. Scroll down and find the UI annotations for the **`TravelStatus`** element. Remove the comments for both actions for the UI.lineItem as well as the UI.identification annotation. Your metadata extension should look as follows: 85 | 86 | ![Actions](images/action05.png) 87 | 88 | 3. \[FAST TRACK\] Scroll down and find the UI annotations for the **`TravelStatus`** element. Replace the existing **`@UI`** annotation blocks (`@UI.lineItem` and `@UI.identification`) with code snippet provided below to add both actions to the list report page and the object page. 89 | 90 |
 91 |       @UI: {  lineItem:       [ { position: 110 }
 92 |                             , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' },
 93 |                               { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' }
 94 |                           ],
 95 |           identification: [ { position: 110 }
 96 |                             , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' },
 97 |                               { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' }
 98 |                           ] } 
 99 |     
100 | 101 | Your metadata extension should look as follows: 102 | 103 | ![Actions](images/action05ft.png) 104 | 105 | 4. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the metadata extension. 106 | 107 | ## Exercise 7.4 - Preview the Travel App 108 | 109 | 1. Use the service binding to start the app preview. Make sure to launch the **Travel** entity set. In case the browser window is still open it's also sufficient to simply reload (F5) the page. 110 | 111 | > Please note: In the trial environment it might take a while until your changes are reflected. 112 | > You may also, for example, empty your browser cache and trigger a hard reload. 113 | 114 | As a result, you can see that both new actions are available on the _list report_ as well as on the _object page_. 115 | 116 | ![Preview App](images/action06.png) 117 | 118 | Object Page: 119 | 120 | ![Preview App](images/action07.png) 121 | 122 | 2. Feel free to play around with the application – e.g. see how the instance specific feature control enables/disables the buttons dynamically. 123 | 124 | ## Summary 125 | 126 | Now that you've... 127 | - added actions to the base behavior definition, 128 | - implemented the actions and the related instance feature control, 129 | - projected the actions in the behavior definition projection and 130 | - exposed them to the Fiori app, 131 | 132 | you can continue with - [Exercise 8 - Determinations](../ex8/README.md) 133 | 134 | ## Appendix 135 | 136 | Find the source code for the base behavior definition, the behavior implementation and the behavior definition projection in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 137 | 138 | - [Behavior Definition ZI_RAP_TRAVEL_####](sources/EX7_1_BDEF_ZI_RAP_TRAVEL.txt) 139 | - [Behavior Implementation Class ZBP_I_RAP_Travel_####](sources/EX7_1_CLAS_ZBP_I_RAP_TRAVEL.txt) 140 | - [Behavior Definition ZC_RAP_TRAVEL_####](sources/EX7_2_BDEF_ZC_RAP_TRAVEL.txt) 141 | - [Metadata Extension ZC_RAP_TRAVEL_####](sources/EX7_3_DDLX_ZC_RAP_TRAVEL.txt) 142 | -------------------------------------------------------------------------------- /exercises/ex7/images/action01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action01.png -------------------------------------------------------------------------------- /exercises/ex7/images/action02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action02.png -------------------------------------------------------------------------------- /exercises/ex7/images/action03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action03.png -------------------------------------------------------------------------------- /exercises/ex7/images/action04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action04.png -------------------------------------------------------------------------------- /exercises/ex7/images/action05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action05.png -------------------------------------------------------------------------------- /exercises/ex7/images/action05ft.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action05ft.png -------------------------------------------------------------------------------- /exercises/ex7/images/action06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action06.png -------------------------------------------------------------------------------- /exercises/ex7/images/action07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/action07.png -------------------------------------------------------------------------------- /exercises/ex7/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex7/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex7/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex7/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex7/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex7/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex7/sources/EX7_1_BDEF_ZI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | managed; 2 | with draft; 3 | 4 | define behavior for ZI_RAP_Travel_#### alias Travel 5 | implementation in class zbp_i_rap_travel_#### unique 6 | persistent table zrap_atrav_#### 7 | draft table zrap_dtrav_#### 8 | lock master total etag LastChangedAt 9 | etag master LocalLastChangedAt 10 | { 11 | create; 12 | update; 13 | delete; 14 | association _Booking { create; with draft; } 15 | 16 | field ( numbering : managed, readonly ) TravelUUID; 17 | field ( readonly ) TravelId, TotalPrice, TravelStatus; 18 | field ( readonly ) LastChangedAt, LastChangedBy, CreatedAt, CreatedBy, LocalLastChangedAt; 19 | field ( mandatory ) AgencyID, CustomerID; 20 | 21 | action ( features : instance ) acceptTravel result [1] $self; 22 | action ( features : instance ) rejectTravel result [1] $self; 23 | internal action recalcTotalPrice; 24 | 25 | mapping for zrap_atrav_#### 26 | { 27 | TravelUUID = travel_uuid; 28 | TravelID = travel_id; 29 | AgencyID = agency_id; 30 | CustomerID = customer_id; 31 | BeginDate = begin_date; 32 | EndDate = end_date; 33 | BookingFee = booking_fee; 34 | TotalPrice = total_price; 35 | CurrencyCode = currency_code; 36 | Description = description; 37 | TravelStatus = overall_status; 38 | CreatedBy = created_by; 39 | CreatedAt = created_at; 40 | LastChangedBy = last_changed_by; 41 | LastChangedAt = last_changed_at; 42 | LocalLastChangedAt = local_last_changed_at; 43 | } 44 | } 45 | 46 | define behavior for ZI_RAP_Booking_#### alias Booking 47 | implementation in class zbp_i_rap_booking_#### unique 48 | persistent table zrap_abook_#### 49 | draft table zrap_dbook_#### 50 | lock dependent by _Travel 51 | etag master LocalLastChangedAt 52 | { 53 | update; 54 | delete; 55 | 56 | association _Travel { with draft; } 57 | 58 | field ( numbering : managed, readonly ) BookingUUID; 59 | field ( readonly ) TravelUUID, BookingId; 60 | field ( readonly ) CreatedBy, LastChangedBy, LocalLastChangedAt; 61 | 62 | mapping for zrap_abook_#### 63 | { 64 | BookingUUID = booking_uuid; 65 | TravelUUID = travel_uuid; 66 | BookingID = booking_id; 67 | BookingDate = booking_date; 68 | CustomerID = customer_id; 69 | CarrierID = carrier_id; 70 | ConnectionID = connection_id; 71 | FlightDate = flight_date; 72 | FlightPrice = flight_price; 73 | CurrencyCode = currency_code; 74 | CreatedBy = created_by; 75 | LastChangedBy = last_changed_by; 76 | LocalLastChangedAt = local_last_changed_at; 77 | } 78 | } -------------------------------------------------------------------------------- /exercises/ex7/sources/EX7_1_CLAS_ZBP_I_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | CLASS lhc_Travel DEFINITION INHERITING FROM cl_abap_behavior_handler. 2 | PRIVATE SECTION. 3 | 4 | CONSTANTS: 5 | BEGIN OF travel_status, 6 | open TYPE c LENGTH 1 VALUE 'O', " Open 7 | accepted TYPE c LENGTH 1 VALUE 'A', " Accepted 8 | canceled TYPE c LENGTH 1 VALUE 'X', " Cancelled 9 | END OF travel_status. 10 | 11 | METHODS acceptTravel FOR MODIFY 12 | IMPORTING keys FOR ACTION Travel~acceptTravel RESULT result. 13 | 14 | METHODS rejectTravel FOR MODIFY 15 | IMPORTING keys FOR ACTION Travel~rejectTravel RESULT result. 16 | 17 | METHODS get_features FOR FEATURES 18 | IMPORTING keys REQUEST requested_features FOR Travel RESULT result. 19 | 20 | METHODS recalctotalprice FOR MODIFY 21 | IMPORTING keys FOR ACTION travel~recalcTotalPrice. 22 | 23 | ENDCLASS. 24 | 25 | 26 | CLASS lhc_Travel IMPLEMENTATION. 27 | 28 | METHOD acceptTravel. 29 | " Set the new overall status 30 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 31 | ENTITY Travel 32 | UPDATE 33 | FIELDS ( TravelStatus ) 34 | WITH VALUE #( FOR key IN keys 35 | ( %tky = key-%tky 36 | TravelStatus = travel_status-accepted ) ) 37 | FAILED failed 38 | REPORTED reported. 39 | 40 | " Fill the response table 41 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 42 | ENTITY Travel 43 | ALL FIELDS WITH CORRESPONDING #( keys ) 44 | RESULT DATA(travels). 45 | 46 | result = VALUE #( FOR travel IN travels 47 | ( %tky = travel-%tky 48 | %param = travel ) ). 49 | ENDMETHOD. 50 | 51 | 52 | METHOD rejectTravel. 53 | " Set the new overall status 54 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 55 | ENTITY Travel 56 | UPDATE 57 | FIELDS ( TravelStatus ) 58 | WITH VALUE #( FOR key IN keys 59 | ( %tky = key-%tky 60 | TravelStatus = travel_status-canceled ) ) 61 | FAILED failed 62 | REPORTED reported. 63 | 64 | " Fill the response table 65 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 66 | ENTITY Travel 67 | ALL FIELDS WITH CORRESPONDING #( keys ) 68 | RESULT DATA(travels). 69 | 70 | result = VALUE #( FOR travel IN travels 71 | ( %tky = travel-%tky 72 | %param = travel ) ). 73 | ENDMETHOD. 74 | 75 | 76 | METHOD get_features. 77 | " Read the travel status of the existing travels 78 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 79 | ENTITY Travel 80 | FIELDS ( TravelStatus ) WITH CORRESPONDING #( keys ) 81 | RESULT DATA(travels) 82 | FAILED failed. 83 | 84 | result = 85 | VALUE #( 86 | FOR travel IN travels 87 | LET is_accepted = COND #( WHEN travel-TravelStatus = travel_status-accepted 88 | THEN if_abap_behv=>fc-o-disabled 89 | ELSE if_abap_behv=>fc-o-enabled ) 90 | is_rejected = COND #( WHEN travel-TravelStatus = travel_status-canceled 91 | THEN if_abap_behv=>fc-o-disabled 92 | ELSE if_abap_behv=>fc-o-enabled ) 93 | IN 94 | ( %tky = travel-%tky 95 | %action-acceptTravel = is_accepted 96 | %action-rejectTravel = is_rejected 97 | ) ). 98 | ENDMETHOD. 99 | 100 | 101 | METHOD recalctotalprice. 102 | 103 | TYPES: BEGIN OF ty_amount_per_currencycode, 104 | amount TYPE /dmo/total_price, 105 | currency_code TYPE /dmo/currency_code, 106 | END OF ty_amount_per_currencycode. 107 | 108 | DATA: amount_per_currencycode TYPE STANDARD TABLE OF ty_amount_per_currencycode. 109 | 110 | " Read all relevant travel instances. 111 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 112 | ENTITY Travel 113 | FIELDS ( BookingFee CurrencyCode ) 114 | WITH CORRESPONDING #( keys ) 115 | RESULT DATA(travels). 116 | 117 | DELETE travels WHERE CurrencyCode IS INITIAL. 118 | 119 | LOOP AT travels ASSIGNING FIELD-SYMBOL(). 120 | " Set the start for the calculation by adding the booking fee. 121 | amount_per_currencycode = VALUE #( ( amount = -BookingFee 122 | currency_code = -CurrencyCode ) ). 123 | 124 | " Read all associated bookings and add them to the total price. 125 | READ ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 126 | ENTITY Travel BY \_Booking 127 | FIELDS ( FlightPrice CurrencyCode ) 128 | WITH VALUE #( ( %tky = -%tky ) ) 129 | RESULT DATA(bookings). 130 | 131 | LOOP AT bookings INTO DATA(booking) WHERE CurrencyCode IS NOT INITIAL. 132 | COLLECT VALUE ty_amount_per_currencycode( amount = booking-FlightPrice 133 | currency_code = booking-CurrencyCode ) INTO amount_per_currencycode. 134 | ENDLOOP. 135 | 136 | CLEAR -TotalPrice. 137 | LOOP AT amount_per_currencycode INTO DATA(single_amount_per_currencycode). 138 | " If needed do a Currency Conversion 139 | IF single_amount_per_currencycode-currency_code = -CurrencyCode. 140 | -TotalPrice += single_amount_per_currencycode-amount. 141 | ELSE. 142 | /dmo/cl_flight_amdp=>convert_currency( 143 | EXPORTING 144 | iv_amount = single_amount_per_currencycode-amount 145 | iv_currency_code_source = single_amount_per_currencycode-currency_code 146 | iv_currency_code_target = -CurrencyCode 147 | iv_exchange_rate_date = cl_abap_context_info=>get_system_date( ) 148 | IMPORTING 149 | ev_amount = DATA(total_booking_price_per_curr) 150 | ). 151 | -TotalPrice += total_booking_price_per_curr. 152 | ENDIF. 153 | ENDLOOP. 154 | ENDLOOP. 155 | 156 | " write back the modified total_price of travels 157 | MODIFY ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 158 | ENTITY travel 159 | UPDATE FIELDS ( TotalPrice ) 160 | WITH CORRESPONDING #( travels ). 161 | 162 | ENDMETHOD. 163 | 164 | ENDCLASS. -------------------------------------------------------------------------------- /exercises/ex7/sources/EX7_2_BDEF_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | projection; 2 | use draft; 3 | 4 | define behavior for ZC_RAP_Travel_#### alias Travel 5 | use etag 6 | { 7 | use create; 8 | use update; 9 | use delete; 10 | 11 | use association _Booking { create; with draft; } 12 | 13 | use action acceptTravel; 14 | use action rejectTravel; 15 | } 16 | 17 | define behavior for ZC_RAP_Booking_#### alias Booking 18 | use etag 19 | { 20 | use update; 21 | use delete; 22 | 23 | use association _Travel { with draft; } 24 | } -------------------------------------------------------------------------------- /exercises/ex7/sources/EX7_3_DDLX_ZC_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | @Metadata.layer: #CORE 2 | @UI: { 3 | headerInfo: { typeName: 'Travel', 4 | typeNamePlural: 'Travels', 5 | title: { type: #STANDARD, label: 'Travel', value: 'TravelID' } }, 6 | presentationVariant: [{ sortOrder: [{ by: 'TravelID', direction: #DESC }], visualizations: [{type: #AS_LINEITEM}] }] } 7 | 8 | annotate view ZC_RAP_Travel_#### with 9 | { 10 | @UI.facet: [ { id: 'Travel', 11 | purpose: #STANDARD, 12 | type: #IDENTIFICATION_REFERENCE, 13 | label: 'Travel', 14 | position: 10 }, 15 | { id: 'Booking', 16 | purpose: #STANDARD, 17 | type: #LINEITEM_REFERENCE, 18 | label: 'Booking', 19 | position: 20, 20 | targetElement: '_Booking'} ] 21 | 22 | @UI:{ identification: [{ position: 1, label: 'Travel UUID' }] } 23 | TravelUUID; 24 | 25 | @UI: { lineItem: [ { position: 10 } ], 26 | identification: [ { position: 10 } ], 27 | selectionField: [ { position: 10 } ] } 28 | TravelID; 29 | 30 | @UI: { lineItem: [ { position: 20 } ], 31 | identification: [ { position: 20 } ], 32 | selectionField: [ { position: 20 } ] } 33 | AgencyID; 34 | 35 | @UI: { lineItem: [ { position: 30 } ], 36 | identification: [ { position: 30 } ], 37 | selectionField: [ { position: 30 } ] } 38 | CustomerID; 39 | 40 | @UI: { lineItem: [ { position: 40 } ], 41 | identification: [ { position: 40 } ] } 42 | BeginDate; 43 | 44 | @UI: { lineItem: [ { position: 50 } ], 45 | identification: [ { position: 50 } ] } 46 | EndDate; 47 | 48 | @UI: { lineItem: [ { position: 60 } ], 49 | identification: [ { position: 60 } ] } 50 | BookingFee; 51 | 52 | @UI: { lineItem: [ { position: 70 } ], 53 | identification: [ { position: 70 } ] } 54 | TotalPrice; 55 | 56 | @UI: { lineItem: [ { position: 80 } ], 57 | identification: [ { position: 80 } ] } 58 | Description; 59 | 60 | @UI: { lineItem: [ { position: 90 } 61 | , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' }, 62 | { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } 63 | ], 64 | identification: [ { position: 90 } 65 | , { type: #FOR_ACTION, dataAction: 'acceptTravel', label: 'Accept Travel' }, 66 | { type: #FOR_ACTION, dataAction: 'rejectTravel', label: 'Reject Travel' } 67 | ] } 68 | TravelStatus; 69 | 70 | @UI.hidden: true 71 | LastChangedAt; 72 | 73 | @UI.hidden: true 74 | LocalLastChangedAt; 75 | 76 | @UI.selectionField: [{ element: '_Booking.CarrierID', position: 40 }] 77 | _Booking; 78 | } 79 | -------------------------------------------------------------------------------- /exercises/ex8/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 8 - Determinations 2 | 3 | ## Introduction 4 | In the previous exercise you've defined, implemented and exposed actions (see [Exercise 7](/exercises/ex7/README.md)). 5 | 6 | In this exercise you will add determinations to the base behavior definition of the Travel and Booking entity. Determinations allow you to handle side effects of modified entity instances. They are invoked by the framework as soon as a trigger condition at a predefined point in time, the determination time, is fulfilled. Possible triggers are e.g. a field change or the creation of an instance. Determinations times are `on modify` and `on save`. 7 | 8 | Further information can be found here: [Developing Determinations](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/6edb0438d3e14d18b3c403c406fbe209.html) 9 | 10 | > Please note: Determinations have to be idempotent, i.e. they have to produce the same result even if the framework calls them multiple times. 11 | 12 | ## Exercise 8.1 - Base Behavior Definition 13 | 1. Open the base behavior definition **`ZI_RAP_Travel_####`** – where **`####`** is your group ID – of your business object by either double-clicking on it in the _Project Explorer_ or using the shortcut **Ctrl+Shift+A** (_Open ABAP Development Object_). 14 | 15 | 2. Add the following lines into the **Travel** entity, right after the previously defined actions. 16 | 17 |
18 |     determination setInitialStatus    on modify { create; }
19 |     determination calculateTotalPrice on modify { field BookingFee, CurrencyCode; }
20 |     determination calculateTravelID   on save   { create; }
21 |     
22 | 23 | 3. Add the following lines into the **Booking** entity, right after the `field` statements. 24 | 25 |
26 |     determination calculateBookingID  on modify { create; }
27 |     determination calculateTotalPrice on modify { field FlightPrice, CurrencyCode; }
28 |     
29 | 30 | Your **Travel** entity in the base behavior definition should look as follows: 31 | 32 | ![Actions](images/determination01.png) 33 | 34 | Your **Booking** entity in the base behavior definition should look as follows: 35 | 36 | ![Actions](images/determination02.png) 37 | 38 | 39 | 3. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior definition. 40 | 41 | 4. You can again use the Quick Fixes to generate or update the local handler classes in the related behavior implementation classes. This approach would be used in a regular development flow. 42 | 43 | 5. In this exercise we replace the entire code with the prepared one. Open the behavior implementation class **zbp_i_rap_travel_####** for the **Travel** entity. Replace the **entire** code on the **_Local Types tab_** with the following coding and replace all occurrences of `####` with your group ID: 44 | 45 | > Find the source code here: [Behavior Implementation Class ZBP_I_RAP_TRAVEL_####](sources/EX8_1_CLAS_ZBP_I_RAP_TRAVEL.txt) 46 | 47 | This declares and implements three determinations. **setInitialStatus** sets the overall travel status to `Open` when a new travel instance is created. 48 | 49 | The determination **calculateTotalPrice** calls the previously defined internal action `recalcTotalPrice` to update the total price for a travel. It is triggered whenever the fields `BookingFee` or `CurrencyCode` change. 50 | 51 | Determination **calculateTravelID** is used to calculate a semantic key. Please note: This scenario uses a UUID (`traveluuid`) as key for each node of the business object calculated by the framework. The calculation of the semantic key `TravelID` is just used as an example. The implementation does not ensure for gap free or unique travel IDs. 52 | 53 | 6. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the class. 54 | 55 | 7. Open the behavior implementation class **zbp_i_rap_booking_####** for the **Booking** entity. Replace the **entire** code on the **_Local Types tab_** with the following coding and replace all occurrences of `####` with your group ID: 56 | 57 | > Find the source code here: [Behavior Implementation Class ZBP_I_RAP_BOOKING_####](sources/EX8_1_CLAS_ZBP_I_RAP_BOOKING.txt) 58 | 59 | This declares and implements two determinations. **calculateBookingID** calculates a booking id for newly created booking instances - i.e. booking instances that do not yet have a booking id. For this the implementation first uses a read-by-association to read the associated travel header. From the header again a read-by-association takes place to read all existing bookings. With this information an internal `update` table is prepared to fill the booking id for those that don't yet have an id. 60 | 61 | Determination **calculateTotalPrice** is triggered whenever the `FlightPrice` or the `CurrencyCode` of a booking is changed. It calls the internal action `recalcTotalPrice` on travel level to update the total price. 62 | 63 | 8. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the class. 64 | 65 | ## Exercise 8.2 - Preview the Travel App 66 | Determinations neither need to be projected, nor need to be added to the UI metadata. They are considered by the framework right away. 67 | 68 | 1. Use the service binding to start the app preview. Make sure to launch the **Travel** entity set. In case the browser window is still open it's also sufficient to simply reload (F5) the page. 69 | 70 | As a result, when creating a new travel instance you can see the overall status is defaulted to `Open`. When you save the new instance, a travel ID as well as the total price is calculated. 71 | 72 | ![Preview App](images/determination03.png) 73 | 74 | ## Summary 75 | 76 | Now that you've... 77 | - added determinations to the base behavior definition and 78 | - implemented them in the related behavior implementation class, 79 | 80 | you can continue with - [Exercise 9 - Validations](../ex9/README.md) 81 | 82 | ## Appendix 83 | 84 | Find the source code for the base behavior definition, the travel and booking behavior implementation classes in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 85 | 86 | - [Behavior Definition ZI_RAP_TRAVEL_####](sources/EX8_1_BDEF_ZI_RAP_TRAVEL.txt) 87 | - [Behavior Implementation Class ZBP_I_RAP_Travel_####](sources/EX8_1_CLAS_ZBP_I_RAP_TRAVEL.txt) 88 | - [Behavior Implementation Class ZBP_I_RAP_Booking_####](sources/EX8_1_CLAS_ZBP_I_RAP_BOOKING.txt) 89 | -------------------------------------------------------------------------------- /exercises/ex8/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex8/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex8/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex8/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex8/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex8/images/determination01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/determination01.png -------------------------------------------------------------------------------- /exercises/ex8/images/determination02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/determination02.png -------------------------------------------------------------------------------- /exercises/ex8/images/determination03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex8/images/determination03.png -------------------------------------------------------------------------------- /exercises/ex8/sources/EX8_1_BDEF_ZI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | managed; 2 | with draft; 3 | 4 | define behavior for ZI_RAP_Travel_#### alias Travel 5 | implementation in class zbp_i_rap_travel_#### unique 6 | persistent table zrap_atrav_#### 7 | draft table zrap_dtrav_#### 8 | lock master total etag LastChangedAt 9 | etag master LocalLastChangedAt 10 | { 11 | create; 12 | update; 13 | delete; 14 | association _Booking { create; with draft; } 15 | 16 | field ( numbering : managed, readonly ) TravelUUID; 17 | field ( readonly ) TravelId, TotalPrice, TravelStatus; 18 | field ( readonly ) LastChangedAt, LastChangedBy, CreatedAt, CreatedBy, LocalLastChangedAt; 19 | field ( mandatory ) AgencyID, CustomerID; 20 | 21 | action ( features : instance ) acceptTravel result [1] $self; 22 | action ( features : instance ) rejectTravel result [1] $self; 23 | internal action recalcTotalPrice; 24 | 25 | determination setInitialStatus on modify { create; } 26 | determination calculateTotalPrice on modify { field BookingFee, CurrencyCode; } 27 | determination calculateTravelID on save { create; } 28 | 29 | mapping for zrap_atrav_#### 30 | { 31 | TravelUUID = travel_uuid; 32 | TravelID = travel_id; 33 | AgencyID = agency_id; 34 | CustomerID = customer_id; 35 | BeginDate = begin_date; 36 | EndDate = end_date; 37 | BookingFee = booking_fee; 38 | TotalPrice = total_price; 39 | CurrencyCode = currency_code; 40 | Description = description; 41 | TravelStatus = overall_status; 42 | CreatedBy = created_by; 43 | CreatedAt = created_at; 44 | LastChangedBy = last_changed_by; 45 | LastChangedAt = last_changed_at; 46 | LocalLastChangedAt = local_last_changed_at; 47 | } 48 | } 49 | 50 | define behavior for ZI_RAP_Booking_#### alias Booking 51 | implementation in class zbp_i_rap_booking_#### unique 52 | persistent table zrap_abook_#### 53 | draft table zrap_dbook_#### 54 | lock dependent by _Travel 55 | etag master LocalLastChangedAt 56 | { 57 | update; 58 | delete; 59 | 60 | association _Travel { with draft; } 61 | 62 | field ( numbering : managed, readonly ) BookingUUID; 63 | field ( readonly ) TravelUUID, BookingId; 64 | field ( readonly ) CreatedBy, LastChangedBy, LocalLastChangedAt; 65 | 66 | determination calculateBookingID on modify { create; } 67 | determination calculateTotalPrice on modify { field FlightPrice, CurrencyCode; } 68 | 69 | mapping for zrap_abook_#### 70 | { 71 | BookingUUID = booking_uuid; 72 | TravelUUID = travel_uuid; 73 | BookingID = booking_id; 74 | BookingDate = booking_date; 75 | CustomerID = customer_id; 76 | CarrierID = carrier_id; 77 | ConnectionID = connection_id; 78 | FlightDate = flight_date; 79 | FlightPrice = flight_price; 80 | CurrencyCode = currency_code; 81 | CreatedBy = created_by; 82 | LastChangedBy = last_changed_by; 83 | LocalLastChangedAt = local_last_changed_at; 84 | } 85 | } -------------------------------------------------------------------------------- /exercises/ex8/sources/EX8_1_CLAS_ZBP_I_RAP_BOOKING.txt: -------------------------------------------------------------------------------- 1 | CLASS lhc_Booking DEFINITION INHERITING FROM cl_abap_behavior_handler. 2 | PRIVATE SECTION. 3 | 4 | METHODS calculateBookingID FOR DETERMINE ON MODIFY 5 | IMPORTING keys FOR Booking~CalculateBookingID. 6 | 7 | METHODS calculateTotalPrice FOR DETERMINE ON MODIFY 8 | IMPORTING keys FOR Booking~calculateTotalPrice. 9 | 10 | ENDCLASS. 11 | 12 | CLASS lhc_Booking IMPLEMENTATION. 13 | 14 | METHOD calculateBookingID. 15 | DATA max_bookingid TYPE /dmo/booking_id. 16 | DATA update TYPE TABLE FOR UPDATE ZI_RAP_Travel_####\\Booking. 17 | 18 | " Read all travels for the requested bookings. 19 | " If multiple bookings of the same travel are requested, the travel is returned only once. 20 | READ ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 21 | ENTITY Booking BY \_Travel 22 | FIELDS ( TravelUUID ) 23 | WITH CORRESPONDING #( keys ) 24 | RESULT DATA(travels). 25 | 26 | " Process all affected Travels. Read respective bookings, determine the max-id and update the bookings without ID. 27 | LOOP AT travels INTO DATA(travel). 28 | READ ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 29 | ENTITY Travel BY \_Booking 30 | FIELDS ( BookingID ) 31 | WITH VALUE #( ( %tky = travel-%tky ) ) 32 | RESULT DATA(bookings). 33 | 34 | " Find max used BookingID in all bookings of this travel 35 | max_bookingid ='0000'. 36 | LOOP AT bookings INTO DATA(booking). 37 | IF booking-BookingID > max_bookingid. 38 | max_bookingid = booking-BookingID. 39 | ENDIF. 40 | ENDLOOP. 41 | 42 | " Provide a booking ID for all bookings that have none. 43 | LOOP AT bookings INTO booking WHERE BookingID IS INITIAL. 44 | max_bookingid += 10. 45 | APPEND VALUE #( %tky = booking-%tky 46 | BookingID = max_bookingid 47 | ) TO update. 48 | ENDLOOP. 49 | ENDLOOP. 50 | 51 | " Update the Booking ID of all relevant bookings 52 | MODIFY ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 53 | ENTITY Booking 54 | UPDATE FIELDS ( BookingID ) WITH update 55 | REPORTED DATA(update_reported). 56 | 57 | reported = CORRESPONDING #( DEEP update_reported ). 58 | 59 | ENDMETHOD. 60 | 61 | METHOD calculateTotalPrice. 62 | 63 | " Read all travels for the requested bookings. 64 | " If multiple bookings of the same travel are requested, the travel is returned only once. 65 | READ ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 66 | ENTITY Booking BY \_Travel 67 | FIELDS ( TravelUUID ) 68 | WITH CORRESPONDING #( keys ) 69 | RESULT DATA(travels) 70 | FAILED DATA(read_failed). 71 | 72 | " Trigger calculation of the total price 73 | MODIFY ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 74 | ENTITY Travel 75 | EXECUTE recalcTotalPrice 76 | FROM CORRESPONDING #( travels ) 77 | REPORTED DATA(execute_reported). 78 | 79 | reported = CORRESPONDING #( DEEP execute_reported ). 80 | 81 | ENDMETHOD. 82 | 83 | ENDCLASS. -------------------------------------------------------------------------------- /exercises/ex8/sources/EX8_1_CLAS_ZBP_I_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | CLASS lhc_Travel DEFINITION INHERITING FROM cl_abap_behavior_handler. 2 | PRIVATE SECTION. 3 | 4 | CONSTANTS: 5 | BEGIN OF travel_status, 6 | open TYPE c LENGTH 1 VALUE 'O', " Open 7 | accepted TYPE c LENGTH 1 VALUE 'A', " Accepted 8 | canceled TYPE c LENGTH 1 VALUE 'X', " Cancelled 9 | END OF travel_status. 10 | 11 | METHODS CalculateTravelID FOR DETERMINE ON SAVE 12 | IMPORTING keys FOR travel~CalculateTravelID. 13 | 14 | METHODS setInitialStatus FOR DETERMINE ON MODIFY 15 | IMPORTING keys FOR Travel~setInitialStatus. 16 | 17 | METHODS acceptTravel FOR MODIFY 18 | IMPORTING keys FOR ACTION Travel~acceptTravel RESULT result. 19 | 20 | METHODS rejectTravel FOR MODIFY 21 | IMPORTING keys FOR ACTION Travel~rejectTravel RESULT result. 22 | 23 | METHODS get_features FOR FEATURES 24 | IMPORTING keys REQUEST requested_features FOR Travel RESULT result. 25 | 26 | METHODS recalctotalprice FOR MODIFY 27 | IMPORTING keys FOR ACTION travel~recalcTotalPrice. 28 | 29 | METHODS calculateTotalPrice FOR DETERMINE ON MODIFY 30 | IMPORTING keys FOR Travel~calculateTotalPrice. 31 | 32 | ENDCLASS. 33 | 34 | 35 | CLASS lhc_Travel IMPLEMENTATION. 36 | 37 | METHOD CalculateTravelID. 38 | " Please note that this is just an example for calculating a field during onSave. 39 | " This approach does NOT ensure for gap free or unique travel IDs! It just helps to provide a readable ID. 40 | " The key of this business object is a UUID, calculated by the framework. 41 | 42 | " check if TravelID is already filled 43 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 44 | ENTITY Travel 45 | FIELDS ( TravelID ) WITH CORRESPONDING #( keys ) 46 | RESULT DATA(travels). 47 | 48 | " remove lines where TravelID is already filled. 49 | DELETE travels WHERE TravelID IS NOT INITIAL. 50 | 51 | " anything left ? 52 | CHECK travels IS NOT INITIAL. 53 | 54 | " Select max travel ID 55 | SELECT SINGLE 56 | FROM zrap_atrav_#### 57 | FIELDS MAX( travel_id ) AS travelID 58 | INTO @DATA(max_travelid). 59 | 60 | " Set the travel ID 61 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 62 | ENTITY Travel 63 | UPDATE 64 | FROM VALUE #( FOR travel IN travels INDEX INTO i ( 65 | %tky = travel-%tky 66 | TravelID = max_travelid + i 67 | %control-TravelID = if_abap_behv=>mk-on ) ) 68 | REPORTED DATA(update_reported). 69 | 70 | reported = CORRESPONDING #( DEEP update_reported ). 71 | ENDMETHOD. 72 | 73 | 74 | METHOD setInitialStatus. 75 | " Read relevant travel instance data 76 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 77 | ENTITY Travel 78 | FIELDS ( TravelStatus ) WITH CORRESPONDING #( keys ) 79 | RESULT DATA(travels). 80 | 81 | " Remove all travel instance data with defined status 82 | DELETE travels WHERE TravelStatus IS NOT INITIAL. 83 | CHECK travels IS NOT INITIAL. 84 | 85 | " Set default travel status 86 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 87 | ENTITY Travel 88 | UPDATE 89 | FIELDS ( TravelStatus ) 90 | WITH VALUE #( FOR travel IN travels 91 | ( %tky = travel-%tky 92 | TravelStatus = travel_status-open ) ) 93 | REPORTED DATA(update_reported). 94 | 95 | reported = CORRESPONDING #( DEEP update_reported ). 96 | ENDMETHOD. 97 | 98 | 99 | METHOD acceptTravel. 100 | " Set the new overall status 101 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 102 | ENTITY Travel 103 | UPDATE 104 | FIELDS ( TravelStatus ) 105 | WITH VALUE #( FOR key IN keys 106 | ( %tky = key-%tky 107 | TravelStatus = travel_status-accepted ) ) 108 | FAILED failed 109 | REPORTED reported. 110 | 111 | " Fill the response table 112 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 113 | ENTITY Travel 114 | ALL FIELDS WITH CORRESPONDING #( keys ) 115 | RESULT DATA(travels). 116 | 117 | result = VALUE #( FOR travel IN travels 118 | ( %tky = travel-%tky 119 | %param = travel ) ). 120 | ENDMETHOD. 121 | 122 | 123 | METHOD rejectTravel. 124 | " Set the new overall status 125 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 126 | ENTITY Travel 127 | UPDATE 128 | FIELDS ( TravelStatus ) 129 | WITH VALUE #( FOR key IN keys 130 | ( %tky = key-%tky 131 | TravelStatus = travel_status-canceled ) ) 132 | FAILED failed 133 | REPORTED reported. 134 | 135 | " Fill the response table 136 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 137 | ENTITY Travel 138 | ALL FIELDS WITH CORRESPONDING #( keys ) 139 | RESULT DATA(travels). 140 | 141 | result = VALUE #( FOR travel IN travels 142 | ( %tky = travel-%tky 143 | %param = travel ) ). 144 | ENDMETHOD. 145 | 146 | 147 | METHOD get_features. 148 | " Read the travel status of the existing travels 149 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 150 | ENTITY Travel 151 | FIELDS ( TravelStatus ) WITH CORRESPONDING #( keys ) 152 | RESULT DATA(travels) 153 | FAILED failed. 154 | 155 | result = 156 | VALUE #( 157 | FOR travel IN travels 158 | LET is_accepted = COND #( WHEN travel-TravelStatus = travel_status-accepted 159 | THEN if_abap_behv=>fc-o-disabled 160 | ELSE if_abap_behv=>fc-o-enabled ) 161 | is_rejected = COND #( WHEN travel-TravelStatus = travel_status-canceled 162 | THEN if_abap_behv=>fc-o-disabled 163 | ELSE if_abap_behv=>fc-o-enabled ) 164 | IN 165 | ( %tky = travel-%tky 166 | %action-acceptTravel = is_accepted 167 | %action-rejectTravel = is_rejected 168 | ) ). 169 | ENDMETHOD. 170 | 171 | 172 | METHOD recalctotalprice. 173 | 174 | TYPES: BEGIN OF ty_amount_per_currencycode, 175 | amount TYPE /dmo/total_price, 176 | currency_code TYPE /dmo/currency_code, 177 | END OF ty_amount_per_currencycode. 178 | 179 | DATA: amount_per_currencycode TYPE STANDARD TABLE OF ty_amount_per_currencycode. 180 | 181 | " Read all relevant travel instances. 182 | READ ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 183 | ENTITY Travel 184 | FIELDS ( BookingFee CurrencyCode ) 185 | WITH CORRESPONDING #( keys ) 186 | RESULT DATA(travels). 187 | 188 | DELETE travels WHERE CurrencyCode IS INITIAL. 189 | 190 | LOOP AT travels ASSIGNING FIELD-SYMBOL(). 191 | " Set the start for the calculation by adding the booking fee. 192 | amount_per_currencycode = VALUE #( ( amount = -BookingFee 193 | currency_code = -CurrencyCode ) ). 194 | 195 | " Read all associated bookings and add them to the total price. 196 | READ ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 197 | ENTITY Travel BY \_Booking 198 | FIELDS ( FlightPrice CurrencyCode ) 199 | WITH VALUE #( ( %tky = -%tky ) ) 200 | RESULT DATA(bookings). 201 | 202 | LOOP AT bookings INTO DATA(booking) WHERE CurrencyCode IS NOT INITIAL. 203 | COLLECT VALUE ty_amount_per_currencycode( amount = booking-FlightPrice 204 | currency_code = booking-CurrencyCode ) INTO amount_per_currencycode. 205 | ENDLOOP. 206 | 207 | CLEAR -TotalPrice. 208 | LOOP AT amount_per_currencycode INTO DATA(single_amount_per_currencycode). 209 | " If needed do a Currency Conversion 210 | IF single_amount_per_currencycode-currency_code = -CurrencyCode. 211 | -TotalPrice += single_amount_per_currencycode-amount. 212 | ELSE. 213 | /dmo/cl_flight_amdp=>convert_currency( 214 | EXPORTING 215 | iv_amount = single_amount_per_currencycode-amount 216 | iv_currency_code_source = single_amount_per_currencycode-currency_code 217 | iv_currency_code_target = -CurrencyCode 218 | iv_exchange_rate_date = cl_abap_context_info=>get_system_date( ) 219 | IMPORTING 220 | ev_amount = DATA(total_booking_price_per_curr) 221 | ). 222 | -TotalPrice += total_booking_price_per_curr. 223 | ENDIF. 224 | ENDLOOP. 225 | ENDLOOP. 226 | 227 | " write back the modified total_price of travels 228 | MODIFY ENTITIES OF ZI_RAP_Travel_#### IN LOCAL MODE 229 | ENTITY travel 230 | UPDATE FIELDS ( TotalPrice ) 231 | WITH CORRESPONDING #( travels ). 232 | 233 | ENDMETHOD. 234 | 235 | METHOD calculateTotalPrice. 236 | 237 | MODIFY ENTITIES OF zi_rap_travel_#### IN LOCAL MODE 238 | ENTITY travel 239 | EXECUTE recalcTotalPrice 240 | FROM CORRESPONDING #( keys ) 241 | REPORTED DATA(execute_reported). 242 | 243 | reported = CORRESPONDING #( DEEP execute_reported ). 244 | 245 | ENDMETHOD. 246 | 247 | ENDCLASS. -------------------------------------------------------------------------------- /exercises/ex9/README.md: -------------------------------------------------------------------------------- 1 | # Exercise 9 - Validations 2 | 3 | ## Introduction 4 | In the previous exercise you've defined and implemented determinations (see [Exercise 8](/exercises/ex8/README.md)). 5 | 6 | In this exercise you will add validations to the base behavior definition. Validations allow you to check the data consistency of an instance. It's implicitly invoked by the framework as soon as a trigger condition at a predefined point in time is fulfilled. Validations can return messages to the consumer and reject inconsistent instance data from being saved. 7 | 8 | Further information can be found here: [Developing Validations](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/171e26c36cca42699976887b4c8a83bf.html) 9 | 10 | ## Exercise 9.1 - Message Class 11 | In the behavior implementations, you will make use of your own _T100_ messages, raised by an own exception class. 12 | Therefore, you will first create the message class **`ZRAP_MSG_####`** to define your own `T100` messages and the exception class **`ZCM_RAP_####`**, where **`####`** is your group ID. 13 | 14 | 1. Right-click on your package and choose _**New > Other ABAP Repository Object**_. 15 | 16 | ![Create the Message Class](images/validation01.png) 17 | 18 | 2. In the creation wizard, filter the entries with **`message`** and choose **`Message Class`**. Then choose **Next >**. 19 | 20 | ![Create the Message Class](images/validation02.png) 21 | 22 | 3. Maintain **`ZRAP_MSG_####`** as **name**, where **`####`** is your group ID, and a **description** (e.g. **`RAP messages`**) and choose **Next >**. 23 | 24 | ![Create the Message Class](images/validation03.png) 25 | 26 | 4. Assign a transport request and click **Finish**. The new message class editor opens. Create five messages with the numbers **001** to **005** and the short texts provided below. 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 |
001 Begin date &1 must not be after end date &2 for travel &3
002 Begin date &1 must be on or after system date
003 Customer &1 unknown
004 Agency &1 unknown
005 You are not authorized to perform this activity
36 | 37 | Your message class should look as follows: 38 | 39 | ![Create the Message Class](images/validation04.png) 40 | 41 | 5. Save ![save icon](images/adt_save.png) the new message class to activate it. 42 | 43 | ## Exercise 9.2 - Exception Class 44 | 45 | 1. Right-click on your package **`ZRAP_TRAVEL_####`** and choose _**New > ABAP Class**_. 46 | 47 | ![Create the Exception Class](images/validation05.png) 48 | 49 | 2. Maintain **`ZCM_RAP_####`** (where **`####`** is your group ID) as **name** and a **description** (e.g. **`RAP Messages`**). 50 | 51 | Maintain **`CX_STATIC_CHECK`** as **Superclass** and then add **`IF_ABAP_BEHV_MESSAGE`** under **Interfaces**. 52 | 53 | Choose **Next >**. 54 | 55 | ![Create the Exception Class](images/validation06.png) 56 | 57 | 3. Assign a transport request and choose **Finish**. The ABAP class skeleton is generated and displayed in the editor. 58 | 59 | ![Create the Exception Class](images/validation07.png) 60 | 61 | 4. Replace the **entire** code of the exception class with the following coding and replace all occurrences of `####` with your group ID: 62 | 63 | > Note: In case you are using letters in your group ID, make sure to perform the replacement with **capital** letters. 64 | 65 | > Find the source code here: [Exception Class ZCM_RAP_####](sources/EX9_2_CLAS_ZCM_RAP.txt) 66 | 67 | This defines five message constants for the five T100 messages the were defined before. It also specifies required variables for storing the message parameters. For parameters of type NUMC we perform an alpha conversion to remove leading zeros. 68 | 69 | 5. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the exception class. 70 | 71 | ## Exercise 9.3 - Behavior Definition - Validation 72 | 1. Open the base behavior definition **`ZI_RAP_Travel_####`** – where **`####`** is your group ID – of your business object by either double-clicking on it in the _Project Explorer_ or using the shortcut **Ctrl+Shift+A** (_Open ABAP Development Object_). 73 | 74 | 2. Add the following lines into the **Travel** entity, right after the previously defined determinations. 75 | 76 |
 77 |     validation validateAgency   on save { field AgencyID; create; }
 78 |     validation validateCustomer on save { field CustomerID; create; }
 79 |     validation validateDates    on save { field BeginDate, EndDate; create; }
 80 |     
81 | 82 | Your base behavior definition should look as follows: 83 | 84 | ![Actions](images/validation08.png) 85 | 86 | 3. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior definition. 87 | 88 | 4. You can again use the Quick Fixes to update the local handler class in the behavior implementation class. This approach would be used in a regular development flow. 89 | 90 | 5. In this exercise we replace the entire code with the prepared one. Open the behavior implementation class **zbp_i_rap_travel_####** for the **Travel** entity. Replace the **entire** code on the **_Local Types tab_** with the following coding and replace all occurrences of `####` with your group ID: 91 | 92 | > Find the source code here: [Behavior Implementation Class ZBP_I_RAP_TRAVEL_####](sources/EX9_3_CLAS_ZBP_I_RAP_TRAVEL.txt) 93 | 94 | This declares and implements three validations. 95 | 96 | The validations **validateAgency** and **validateCustomer** are very similar. They use the EML to read the `AgencyIDs` / `CustomerIDs` for the provided keys, building a distinct internal table of the IDs. This table is checked against the corresponding value help table (`/dmo/agency` / `/dmo/customer`). Values that don't exist are invalid. For such travel keys a corresponding entry in the **`FAILED`** changing parameter is made. This declares the instance as inconsistent. 97 | 98 | In addition a corresponding message is added to the **`REPORTED`** changing parameter, making use of the previously implemented exception class. The message added to the reported parameter can be used by consumers (e.g. a Fiori Elements UI) to inform the end-user about the identified problem. 99 | 100 | Messages can be raised as so-called _state messages_, belonging to the current state of the instance. If the state changes, they need to be removed from the message buffer. This is typically done at the beginning of a validation, by adding an entry to the reported parameter with the current transactional key `%tky` but with no message. 101 | 102 | Validation **validateDates** follows the same pattern. It validates the `BeginDate` and the `EndDate`. Either if the EndDate is earlier than the BeginDate or if the BeginDate is earlier than the system date, the travel instance is considered as inconsistent. In that case the `%tky` is added to the failed parameter and a corresponding message is added to the reported parameter, explaining the problem. 103 | 104 | Further information about message handling can be found here: [Messages](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/ac74189b5cae49c1b091f04393bac069.html) 105 | 106 | 6. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior implementation class. 107 | 108 | ## Exercise 9.4 - Behavior Definition - Draft Determine Action Prepare 109 | Before draft instances become active, they are checked by the validations and determinations that are specified for the draft determine action prepare in the behavior definition. In our example we want all validations to be executed and thus we need to assign all of them to the special draft action `draft determine action Prepare`. 110 | 111 | Further information can be found here: [Preparing Draft Instances for Activation](https://help.sap.com/viewer/923180ddb98240829d935862025004d6/Cloud/en-US/8eb32c2936904f95acffaec95ab1edd5.html) 112 | 113 | 1. In the base behavior definition **`ZI_RAP_Travel_####`** – where **`####`** is your group ID – add the following lines into the **Travel** entity, right after the previously defined validations. 114 | 115 |
116 |     draft determine action Prepare  {
117 |       validation validateAgency;
118 |       validation validateCustomer;
119 |       validation validateDates;
120 |     }
121 |     
122 | 123 | Your base behavior definition should look as follows: 124 | 125 | ![Actions](images/validation09.png) 126 | 127 | 3. Save ![save icon](images/adt_save.png) and activate ![activate icon](images/adt_activate.png) the behavior definition. 128 | 129 | ## Exercise 9.5 - Preview the Travel App 130 | 1. Use the service binding to start the app preview. Make sure to launch the **Travel** entity set. In case the browser window is still open it's also sufficient to simply reload (F5) the page. 131 | 132 | As a result, when **saving** a travel instance with inconsistent data you can see corresponding error messages. 133 | 134 | ![Preview App](images/validation10.png) 135 | 136 | In case you are getting an **Unspecified provider error occurred. See Error Context and Call Stack.** error, please ignore it. 137 | 138 | ![Error_Popup](images/validation11.png) 139 | 140 | This is a known backend problem that will be fixed with the upcoming release. 141 | 142 | ## Summary 143 | 144 | Now that you've... 145 | - defined T-100 messages, 146 | - created an exception class, 147 | - added validations to the base behavior definition, 148 | - implemented them in the behavior implementation class and 149 | - assigned them to the draft determine action prepare, 150 | 151 | you can continue with - [Exercise 10 - Authorizations (optional)](../ex10/README.md) 152 | 153 | ## Appendix 154 | 155 | Find the source code for the exception class, the base behavior definition and the travel behavior implementation class in the [sources](sources) folder. Don't forget to replace the placeholder `####` with your group ID. 156 | 157 | - [Exception Class ZCM_RAP_####](sources/EX9_2_CLAS_ZCM_RAP.txt) 158 | - [Behavior Definition ZI_RAP_TRAVEL_####](sources/EX9_4_BDEF_ZI_RAP_TRAVEL.txt) 159 | - [Behavior Implementation Class ZBP_I_RAP_Travel_####](sources/EX9_3_CLAS_ZBP_I_RAP_TRAVEL.txt) 160 | -------------------------------------------------------------------------------- /exercises/ex9/images/adt_activate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/adt_activate.png -------------------------------------------------------------------------------- /exercises/ex9/images/adt_activate_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/adt_activate_all.png -------------------------------------------------------------------------------- /exercises/ex9/images/adt_open_object.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/adt_open_object.png -------------------------------------------------------------------------------- /exercises/ex9/images/adt_save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/adt_save.png -------------------------------------------------------------------------------- /exercises/ex9/images/adt_save_all.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/adt_save_all.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation01.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation02.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation02.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation03.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation03.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation04.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation04.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation05.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation05.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation06.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation06.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation07.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation07.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation08.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation08.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation09.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation09.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation10.png -------------------------------------------------------------------------------- /exercises/ex9/images/validation11.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/exercises/ex9/images/validation11.png -------------------------------------------------------------------------------- /exercises/ex9/sources/EX9_2_CLAS_ZCM_RAP.txt: -------------------------------------------------------------------------------- 1 | CLASS zcm_rap_#### DEFINITION 2 | PUBLIC 3 | INHERITING FROM cx_static_check 4 | FINAL 5 | CREATE PUBLIC . 6 | 7 | PUBLIC SECTION. 8 | 9 | INTERFACES if_t100_dyn_msg . 10 | INTERFACES if_t100_message . 11 | INTERFACES if_abap_behv_message. 12 | 13 | CONSTANTS: 14 | BEGIN OF date_interval, 15 | msgid TYPE symsgid VALUE 'ZRAP_MSG_####', 16 | msgno TYPE symsgno VALUE '001', 17 | attr1 TYPE scx_attrname VALUE 'BEGINDATE', 18 | attr2 TYPE scx_attrname VALUE 'ENDDATE', 19 | attr3 TYPE scx_attrname VALUE 'TRAVELID', 20 | attr4 TYPE scx_attrname VALUE '', 21 | END OF date_interval . 22 | CONSTANTS: 23 | BEGIN OF begin_date_before_system_date, 24 | msgid TYPE symsgid VALUE 'ZRAP_MSG_####', 25 | msgno TYPE symsgno VALUE '002', 26 | attr1 TYPE scx_attrname VALUE 'BEGINDATE', 27 | attr2 TYPE scx_attrname VALUE '', 28 | attr3 TYPE scx_attrname VALUE '', 29 | attr4 TYPE scx_attrname VALUE '', 30 | END OF begin_date_before_system_date . 31 | CONSTANTS: 32 | BEGIN OF customer_unknown, 33 | msgid TYPE symsgid VALUE 'ZRAP_MSG_####', 34 | msgno TYPE symsgno VALUE '003', 35 | attr1 TYPE scx_attrname VALUE 'CUSTOMERID', 36 | attr2 TYPE scx_attrname VALUE '', 37 | attr3 TYPE scx_attrname VALUE '', 38 | attr4 TYPE scx_attrname VALUE '', 39 | END OF customer_unknown . 40 | CONSTANTS: 41 | BEGIN OF agency_unknown, 42 | msgid TYPE symsgid VALUE 'ZRAP_MSG_####', 43 | msgno TYPE symsgno VALUE '004', 44 | attr1 TYPE scx_attrname VALUE 'AGENCYID', 45 | attr2 TYPE scx_attrname VALUE '', 46 | attr3 TYPE scx_attrname VALUE '', 47 | attr4 TYPE scx_attrname VALUE '', 48 | END OF agency_unknown . 49 | CONSTANTS: 50 | BEGIN OF unauthorized, 51 | msgid TYPE symsgid VALUE 'ZRAP_MSG_####', 52 | msgno TYPE symsgno VALUE '005', 53 | attr1 TYPE scx_attrname VALUE '', 54 | attr2 TYPE scx_attrname VALUE '', 55 | attr3 TYPE scx_attrname VALUE '', 56 | attr4 TYPE scx_attrname VALUE '', 57 | END OF unauthorized . 58 | 59 | METHODS constructor 60 | IMPORTING 61 | severity TYPE if_abap_behv_message=>t_severity DEFAULT if_abap_behv_message=>severity-error 62 | textid LIKE if_t100_message=>t100key OPTIONAL 63 | previous TYPE REF TO cx_root OPTIONAL 64 | begindate TYPE /dmo/begin_date OPTIONAL 65 | enddate TYPE /dmo/end_date OPTIONAL 66 | travelid TYPE /dmo/travel_id OPTIONAL 67 | customerid TYPE /dmo/customer_id OPTIONAL 68 | agencyid TYPE /dmo/agency_id OPTIONAL 69 | . 70 | 71 | DATA begindate TYPE /dmo/begin_date READ-ONLY. 72 | DATA enddate TYPE /dmo/end_date READ-ONLY. 73 | DATA travelid TYPE string READ-ONLY. 74 | DATA customerid TYPE string READ-ONLY. 75 | DATA agencyid TYPE string READ-ONLY. 76 | 77 | PROTECTED SECTION. 78 | PRIVATE SECTION. 79 | ENDCLASS. 80 | 81 | 82 | 83 | CLASS zcm_rap_#### IMPLEMENTATION. 84 | 85 | 86 | METHOD constructor ##ADT_SUPPRESS_GENERATION. 87 | CALL METHOD super->constructor 88 | EXPORTING 89 | previous = previous. 90 | CLEAR me->textid. 91 | IF textid IS INITIAL. 92 | if_t100_message~t100key = if_t100_message=>default_textid. 93 | ELSE. 94 | if_t100_message~t100key = textid. 95 | ENDIF. 96 | 97 | me->if_abap_behv_message~m_severity = severity. 98 | 99 | me->begindate = begindate. 100 | me->enddate = enddate. 101 | me->travelid = |{ travelid ALPHA = OUT }|. 102 | me->customerid = |{ customerid ALPHA = OUT }|. 103 | me->agencyid = |{ agencyid ALPHA = OUT }|. 104 | ENDMETHOD. 105 | ENDCLASS. -------------------------------------------------------------------------------- /exercises/ex9/sources/EX9_4_BDEF_ZI_RAP_TRAVEL.txt: -------------------------------------------------------------------------------- 1 | managed; 2 | with draft; 3 | 4 | define behavior for ZI_RAP_Travel_#### alias Travel 5 | implementation in class zbp_i_rap_travel_#### unique 6 | persistent table zrap_atrav_#### 7 | draft table zrap_dtrav_#### 8 | lock master total etag LastChangedAt 9 | etag master LocalLastChangedAt 10 | { 11 | create; 12 | update; 13 | delete; 14 | association _Booking { create; with draft; } 15 | 16 | field ( numbering : managed, readonly ) TravelUUID; 17 | field ( readonly ) TravelId, TotalPrice, TravelStatus; 18 | field ( readonly ) LastChangedAt, LastChangedBy, CreatedAt, CreatedBy, LocalLastChangedAt; 19 | field ( mandatory ) AgencyID, CustomerID; 20 | 21 | action ( features : instance ) acceptTravel result [1] $self; 22 | action ( features : instance ) rejectTravel result [1] $self; 23 | internal action recalcTotalPrice; 24 | 25 | determination setInitialStatus on modify { create; } 26 | determination calculateTotalPrice on modify { field BookingFee, CurrencyCode; } 27 | determination calculateTravelID on save { create; } 28 | 29 | validation validateAgency on save { field AgencyID; create; } 30 | validation validateCustomer on save { field CustomerID; create; } 31 | validation validateDates on save { field BeginDate, EndDate; create; } 32 | 33 | draft determine action Prepare { 34 | validation validateAgency; 35 | validation validateCustomer; 36 | validation validateDates; 37 | } 38 | 39 | mapping for zrap_atrav_#### 40 | { 41 | TravelUUID = travel_uuid; 42 | TravelID = travel_id; 43 | AgencyID = agency_id; 44 | CustomerID = customer_id; 45 | BeginDate = begin_date; 46 | EndDate = end_date; 47 | BookingFee = booking_fee; 48 | TotalPrice = total_price; 49 | CurrencyCode = currency_code; 50 | Description = description; 51 | TravelStatus = overall_status; 52 | CreatedBy = created_by; 53 | CreatedAt = created_at; 54 | LastChangedBy = last_changed_by; 55 | LastChangedAt = last_changed_at; 56 | LocalLastChangedAt = local_last_changed_at; 57 | } 58 | } 59 | 60 | define behavior for ZI_RAP_Booking_#### alias Booking 61 | implementation in class zbp_i_rap_booking_#### unique 62 | persistent table zrap_abook_#### 63 | draft table zrap_dbook_#### 64 | lock dependent by _Travel 65 | etag master LocalLastChangedAt 66 | { 67 | update; 68 | delete; 69 | 70 | association _Travel { with draft; } 71 | 72 | field ( numbering : managed, readonly ) BookingUUID; 73 | field ( readonly ) TravelUUID, BookingId; 74 | field ( readonly ) CreatedBy, LastChangedBy, LocalLastChangedAt; 75 | 76 | determination calculateBookingID on modify { create; } 77 | determination calculateTotalPrice on modify { field FlightPrice, CurrencyCode; } 78 | 79 | mapping for zrap_abook_#### 80 | { 81 | BookingUUID = booking_uuid; 82 | TravelUUID = travel_uuid; 83 | BookingID = booking_id; 84 | BookingDate = booking_date; 85 | CustomerID = customer_id; 86 | CarrierID = carrier_id; 87 | ConnectionID = connection_id; 88 | FlightDate = flight_date; 89 | FlightPrice = flight_price; 90 | CurrencyCode = currency_code; 91 | CreatedBy = created_by; 92 | LastChangedBy = last_changed_by; 93 | LocalLastChangedAt = local_last_changed_at; 94 | } 95 | } -------------------------------------------------------------------------------- /images/app_overview.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/images/app_overview.png -------------------------------------------------------------------------------- /presentation/DEV260.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SAP-archive/teched2020-DEV260/35de9528f5f0391297bd068c4e6884af04970897/presentation/DEV260.pdf --------------------------------------------------------------------------------