ABAP on Cloud – 8 – Behavior Definition and Service Definition and Binding & Output

6
7894
ABAP on Cloud Part 8

ABAP on Cloud along with RESTful ABAP Programming (RAP) is one hot cake and every ABAP Developer wants to get its small piece and flavor. We have tried to break down the course in logical units so that it is not that overwhelming and even the newbie can understand the new path of ABAP Cloud.

Love, support and amazing response from our patrons has pushed us to venture more and share more. What has been very intriguing is how the CDS behaves and what makes it do so? Finally, how do we see it behave? This article is the heart of this whole series. Do go through it gradually and do the hands on along with us.

What we must do now is to keep the Metadata Extension topic aside, which we left in the last article since its impact and the real value is felt in when a Fiori Application is running. It would be fun to visualize numerous moving parts when a Fiori Application is fully operational.

What is Behavioral Definition?

The next artifact in line to be created is the Behavior Definition.
Observe the patterns of a dog behaves.

We closely see that we have clearly defined what action is being performed by a dog. One chew, one jump, biting, etc.

Apply same in our case. We need to decide how the root CDS view should behave according to the business requirement. Textbook definitions :

A business object behavior definition (behavior definition for short) is an ABAP repository object (a source text artifact) that represents the behavior of the business object in the context of ABAP RAP.

The transactional behavior of a CDS entity is modeled using Behavior Definition Language (BDL).

A root entity can have at most one behavior definition, in which the behavior of the child entities may need to be specified too. Conversely, a behavior definition has precisely one root entity.

The implementation of a behavior definition can be made in both a single ABAP class (a behavior pool) or spread across any number of ABAP classes (behavior pools). This means that any number of behavior pools can be assigned to a behavior definition (a 1:n relation).

STEP 1:

Right click on the Interface View and Click on “New Behavior Definition”.

STEP 2:

Choose the package and MOST IMPORTANTLY the “Implementation Type”.

Observe that we have taken into consideration the Managed Scenario for the ease of demonstration. In the upcoming articles how and when to utilize the Unmanaged Scenario, pros and cons of both shall be discussed in detail.

STEP 3:

Choose the default Transport Request and Click on “Finish”.

STEP 4:

Following screen is seen. Un-comment line number 5, where we specify in this case “lock master”. Activate the behavior definition.

Shortcut to uncomment a line : Ctrl + 7
Shortcut to activate : Ctrl + F3

We see below effect and no errors.

In the above example we have defined that we would be making use of the Create / Update / Delete operations in our Fiori Application or through a Web API.

WHAT should be remembered is that when we create an Unmanaged Behavior Definition, each of the operation shall be exclusively coded using EML – Entity Manipulation Language.

Here, we are keeping it simple and asking system to bother on how to manage the basic CRUD operations.

We shall dig into these further as and when Unmanaged Behavior Definition is discussed.

That is about behavior definition creation steps. Next, we create the service definition.

STEP 5:

Right Click on Root View or Interface View and click on “New Service Definition”.

STEP 6:

Fill in the required details like name of the service definition. In this case it is “Z_I_EMP_DTLS_SD”, where SD – Service Definition and the rest prefix is the main root view.

STEP 7:

Complete the creation of service by selecting the default TR and then “Next” and finally “Finish” with default template of exposing the root view.

STEP 8:

Right click on the service definition just now we created in Step 7, which is under service definition.
Choose the option “New Service Binding”.

Important thing here to keep the right service definition. Double check and then proceed.

STEP 9:

Provide the name “Z_I_EMP_DTLS_SB” , where SB stands for Service Binding.

Point to be noted and observed is the drop down in the Binding Type.

Remember this point when we shall come back and observe the usage of the other “ODATA V2 – Web API” when we shall create an External API to be consumed by the Non-SAP applications or systems.

STEP 10:

Click on “Next” and choose the default TR.
A new screen, a screen that one would be conventionally used hereon and that screen which often gets used is as below:

Click on “Activate” and wait for few seconds.

WOW !!! Done !!! Well Done !!! One Step away from seeing the hard work done from all this while.

Observe the screen below:

Select the Entity and then click on Preview. Remember it is JUST Preview.

We have an amazing tool which is the BUILT-IN Preview of Fiori App inside Eclipse IDE. This enables us to know how the behavior of the CDS Root Entity is and how the Fiori Elements are placed in the standard Fiori Layout.

STEP 11:

Provide the email ID and password that is being used in the SCP Trial Account.

Click on “Log On”.

STEP 12:

Yo Beauty!! But wait.
OOPS !!! No Data ???

Click on “GO”. Give the Green Signal for seeing the results. DO it !

Amazing we are seeing the contents of the table.

STEP 13:

Let’s try other CRUD Operation – Create in this Article 🙂 & Update and Delete in Next Article.

Create:
Click on Create Button.

Something is NOT RIGHT ???? Observe the <Unnamed Object>

Well we have done no mistake. Enter the details and see the magic.

Recall in Metadata Extension, what we have mentioned. Click Here.

Likewise we have many things to know and discuss.
Keep faith and confidence that we shall one day create an Fiori App 🙂 Just ONE 🙂
Keep supporting, but before that:

Reminder:
We shall have a tracker along with article number to understand our progress in the article series. This will help us manage the things better and track where we stand. Thumbs Up ?

Sl. No.ArticleLinkArtifact/Summary
1ABAP on Cloud – 1 – IntroductionClick Here 
2ABAP on Cloud – 2 – ABAP Trial Instance on CloudClick HereTrial Account 
3ABAP on Cloud – 3 – Eclipse Set-up for ABAP CloudClick HereEclipse with ADT
4ABAP on Cloud – 4 – Your First ABAP Cloud ProjectClick HereABAP Cloud Project
ABAP Cloud Package
5ABAP on Cloud – 5 – Introduction to RESTFul ABAP ProgrammingClick HereCDS and Introduction
6ABAP on Cloud – 6 – DB Creation and Root View in ABAP CloudClick HereDB Table with Fields
Domain / Data Element
Root Interface View
7ABAP on Cloud – 7 – Insert Records through Class and Create Metadata ExtensionClick HereNew ABAP Class in Cloud
Metadata Extension
8ABAP on Cloud – 8 – Behavior Definition and Service Definition and Binding & OutputThis ArticleBehavior Definition
Service Definition
Service Binding
Service Preview
 PENDING Explanation of CDS Types
 PENDING Explanation of Metadata Extension
 PENDING How to Create a Fiori App
 PENDING Extending Fiori App
 PENDING Unmanaged Behavior Definition
And MORE and MORE…..

Comment Please!!

Please follow our LinkedIn Page, LinkedIn Group, Facebook Page, Twitter and Instagram.

Save our number +1-646-727-9273 and send us a Whatsapp message ‘LEARN’ to be part of our Learning Community.

All ABAP on Cloud Tutorials

Also, Check ABAP Programming for SAP Fiori Tutorials

6 COMMENTS

  1. Hi Ruthvik,

    These articles are really good! It has helped me a lot.

    Please help me out with the below issue.

    I’m unable to find the New Service Definition option when I right click on root view.
    I’m using eclipse 2020-06 with latest version of ADT.

    I have also searched the Other ABAP repository search, but unable to find the option to create New Service Definition.

    Thanks,
    Divya

  2. Hi,
    I have tried the the above article but in service binding i am get the error “The message content is not acceptable” and further it is not proceeding . Could you help if you have faced similar issues.

    Thanks,
    Basuvaraj.P

  3. Amazing Article. It really helped me a lot in understanding the SCP concepts.

    I have followed all the steps explained in this and previous articles. I am able to preview initial fiori screen. When I click on ‘GO’ button it is fetching and displaying the data from my root view. However, when I try to navigate to any record(display one record) by clicking on it, I am getting error “The requested data is not found”. I am getting the same error when I try to create any new record. Could you please help, what could be the issue.

    Thanks in advance 🙂

    • Hi Niharika,

      Thanks for your appreciation!!!
      You need to do two things to get the “page when clicking on navigation enabled row”.
      The page that loads is known as Object Page.

      STEP ONE: Please check your Metadata Extension. The code should contain the Identification Reference along with fields that are to be displayed on UI is chosen .

      STEP TWO: Please check your Metadata Extension. The Facet must be in place.

      Also, just in case you have the UI elements in Root View itself, then check above two things in Root View CDS.

      For detailed description read the Article 9 :
      https://sapyard.com/abap-on-cloud-9-experimenting-with-metadata-extension-and-crud-operations/

      Thanks,
      Ruthvik.

LEAVE A REPLY

Please enter your comment!
Please enter your name here