Week 3 Unit 2: Defining the Basic Business Object Behavior
In the present hands-on exercise, you will project the transactional capabilities that we want to enable in our app by creating the business object behavior projection and test your enhanced Travel app.
You can watch week 3 unit 3: Creating the Business Object Behavior Projection on the openSAP platform.
Hints and Tips
Speed up the typing by making use of the Code Completion feature (shortcut Ctrl+Space) and the prepared code snippets provided. 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.A great overview of ADT shortcuts can be found here: Useful ADT Shortcuts
Please note that the placeholder
####used in object names in the exercise description must be replaced with the suffix of your choice during the exercises. The suffix can contain a maximum of 4 characters (numbers and letters). The screenshots in this document have been taken with the suffix1234and systemD20. Your system id will beTRL.
Please note that the ADT dialogs and views may change in the future due to software updates.
Follow the instructions below.
Now you will create the behavior projection ZC_RAP_TRAVEL_#### (where #### is your chosen suffix) for the projected composition model.
-
Right-click on the root CDS view
ZC_RAP_TRAVEL_####in the Project Explorer and choose New Behavior Definition. -
The New Behavior Definition wizard is shown. The Name of the behavior definition has to be the identical name as the root CDS view. That’s the reason why the name can’t be changed.
Adjust the proposed Description if you like, ensure that the Implementation Type is set to Projection and choose Next > to continue.
Project, Package and Root Entity have been assigned automatically. -
Assign a transport request and choose Finish.
A skeleton for the new behavior projection for all entities – i.e. the travel entity
ZC_RAP_Travel_####and the booking entityZC_RAP_Booking_####in the present scenario – is generated based on the chosen implementation and displayed in the appropriate editor.Short explanation:
projectionis specified at the top since the proper implementation type is specified in the underlying behavior definition.- All operations and associations defined in the underlying behavior definition at the creation time are automatically exposed in the projection using the keyword
use.
Now, you will adjust the behavior projection.
-
First, define an alias for the travel and the booking entity in the
define behavior forstatement. Use the commented statementalias <alias_name>for that.
For the travel entity:alias Travel
For the booking entity:
alias Booking
-
Enable the optimistic lock – i.e. the ETag handling – for both entities.
For that, add the statement below afterdefine behavior forstatement line.use etag
-
Recap of the adjustments
Your behavior projection will look as follows.Below is the corresponding code snippet, where
####to be replaced with your chosen suffix.projection; define behavior for ZC_RAP_Travel_#### alias Travel use etag { use create; use update; use delete; use association _Booking { create; } } define behavior for ZC_RAP_Booking_#### alias Booking use etag { use update; use delete; use association _Travel; }
-
Start the Travel app in your service binding
ZUI_RAP_TRAVEL_O2_####(where####is your chosen suffix) or refresh (F5) it in the browser. Provide your ABAP user credentials if requested.
In the trial environment it might take a while until your changes are reflected.As a result, you can see that now, the create, update and delete operations are enabled.
Press Go on the UI to load the back-end data. -
Feel free to play around with your application – e.g. create, delete or update/edit travel and booking entities.
The Edit button is always available on the relevant Object Page.
You have completed the exercise!
In this unit, you have learned how to create the behavior projection for our managed Travel business object, projecting the behavior for the travel and booking entities.
You can find the source code of the created CDS behavior projection in the sources folder:
Do not forget to replace all the occurrences of #### with your chosen suffix in the copied source code.
Week 3 Unit 4: Understanding Entity Manipulation Language (EML)








