Skip to Content

Create Behavior Definition for Managed Scenario

test
0 %
Create Behavior Definition for Managed Scenario
Details

Create Behavior Definition for Managed Scenario

October 15, 2020
Created by
September 6, 2019
Create behavior definition and implementation for managed scenario.

You will learn

  • How to create behavior definition
  • How to create behavior implementation
  • How to create behavior definition for projection view

Prerequisites

  • You have created an SAP Cloud Platform ABAP environment trial user or
  • You have created a developer user in an SAP Cloud Platform ABAP Environment system.
  • You have downloaded Eclipse Photon or Oxygen and installed ABAP Development Tools (ADT). See https://tools.hana.ondemand.com/#abap.

In this tutorial, wherever XXX appears, use a number (e.g. 000).


Step 1: Create behavior definition
  1. Right-click on your data definition ZI_TRAVEL_M_XXX and select New Behavior Definition

    Create behavior definition

  2. Check your behavior definition. Your implementation type is managed.

    Click Next >.

    Create behavior definition

  3. Click Finish to use your transport request.

    Create behavior definition

  4. Replace your code with following.

    managed implementation in class ZCL_BP_I_TRAVEL_M_XXX unique;
    
    define behavior for ZI_TRAVEL_M_XXX alias Travel
    persistent table ztravel_xxx
    etag master last_changed_at
    lock master
    {
    
      // semantic key is calculated in a determination
      field ( readonly ) travel_id;
    
      // administrative fields (read only)
      field ( readonly ) last_changed_at, last_changed_by, created_at, created_by;
    
      // mandatory fields that are required to create a travel
      field ( mandatory ) agency_id, overall_status, booking_fee, currency_code;
    
      // mandatory fields that are required to create a travel
      field ( mandatory ) Begin_Date, End_Date, Customer_ID;
    
      // standard operations for travel entity
      create;
      update;
      delete;
    }  
    
  5. Save and activate.

    save and activate

    A warning will appear first, but after the creation of the behavior implementation it will disappear.

    Now the behavior definition is created and determines the create, update and delete functionality for travel booking.

Log on to answer question
Step 2: Create behavior definition for projection view
  1. Right-click on your data definition ZC_TRAVEL_M_XXX and select New Behavior Definition.

    Create behavior definition for projection view

  2. Check your behavior definition. Your implementation type is projection.

    Click Next >.

    Create behavior definition for projection view

  3. Click Finish to use your transport request.

    Create behavior definition for projection view

  4. Replace your code with following:

    projection;
    
    define behavior for ZC_TRAVEL_M_XXX alias TravelProcessor
    use etag
    {
      use create;
      use update;
      use delete;
    }
    
  5. Save and activate.

    save and activate

  6. Now switch to your service binding and double click on TravelProcessor.

    Create behavior definition for projection view

  7. Refresh your browser and check your result.

    The create and delete button appears on the UI because of the managed scenario.
    You can create and edit travel bookings or you’ re able to delete existing ones.

    Please note that the semantic key Travel ID is not calculated yet. We will do this in the next tutorial.

    Create behavior definition for projection view

Log on to answer question
Step 3: Test yourself
How do you recognize the behavior definition for your projection view?
×

Next Steps

Back to top