Skip to Content

Create Behavior Definition for Managed Scenario

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
mervey45Merve TemelMarch 17, 2022
Created by
mervey45
September 6, 2019
Contributors
mervey45
mervey45

Prerequisites

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

  • Step 1
    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.

      ABAP
      Copy
      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.

  • Step 2
    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:

      ABAP
      Copy
      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 activate your service binding again.

      Create behavior definition for projection view
    7. Double-click on TravelProcessor to start your preview.

      Create behavior definition for projection view
    8. Refresh your browser and check your result.

      HINT: If you don’t see the create and delete buttons, then please unpublish your service binding, activate and publish it again.
      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
  • Step 3

    How do you recognize the behavior definition for your projection view?

Back to top