Description
In the 𝗥𝗘𝗦𝗧𝗳𝘂𝗹 𝗔𝗕𝗔𝗣 𝗣𝗿𝗼𝗴𝗿𝗮𝗺𝗺𝗶𝗻𝗴 𝗠𝗼𝗱𝗲𝗹 (𝗥𝗔𝗣), a 𝗕𝗲𝗵𝗮𝘃𝗶𝗼𝗿 𝗗𝗲𝗳𝗶𝗻𝗶𝘁𝗶𝗼𝗻 describes the behavior of a 𝗕𝘂𝘀𝗶𝗻𝗲𝘀𝘀 𝗢𝗯𝗷𝗲𝗰𝘁 (𝗕𝗢)—in other words, which operations are allowed on it.
- The 𝗕𝘂𝘀𝗶𝗻𝗲𝘀𝘀 𝗢𝗯𝗷𝗲𝗰𝘁 (𝗕𝗢) has the same name as its 𝗿𝗼𝗼𝘁 𝗲𝗻𝘁𝗶𝘁𝘆.
- The 𝗥𝗔𝗣 𝗳𝗿𝗮𝗺𝗲𝘄𝗼𝗿𝗸 𝗮𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗰𝗮𝗹𝗹𝘆 𝗴𝗲𝗻𝗲𝗿𝗮𝘁𝗲𝘀 the required code for standard 𝗖𝗥𝗨𝗗 (𝗖𝗿𝗲𝗮𝘁𝗲, 𝗥𝗲𝗮𝗱, 𝗨𝗽𝗱𝗮𝘁𝗲, 𝗗𝗲𝗹𝗲𝘁𝗲) operations for the BO.
- Based on the 𝗯𝗲𝗵𝗮𝘃𝗶𝗼𝗿 𝗱𝗲𝗳𝗶𝗻𝗶𝘁𝗶𝗼𝗻, the RAP framework determines whether the scenario is 𝗺𝗮𝗻𝗮𝗴𝗲𝗱 or 𝘂𝗻𝗺𝗮𝗻𝗮𝗴𝗲𝗱.
- A 𝗕𝘂𝘀𝗶𝗻𝗲𝘀𝘀 𝗢𝗯𝗷𝗲𝗰𝘁 can have only one 𝗕𝗲𝗵𝗮𝘃𝗶𝗼𝗿 𝗗𝗲𝗳𝗶𝗻𝗶𝘁𝗶𝗼𝗻.
Steps
- Go to root Entity >> Right Click >> New Behavior Definition

2. Choose Implementation Type(Managed or Unmanaged ) and Click Next. Behavior definition will be created with all the entities.

3. Provide valid alias names.
managed implementation in class zbp_ha_sa_travel1 unique;strict ( 2 );define behavior for ZHA_SA_TRAVEL1 alias Travel//persistent table <???>lock masterauthorization master ( instance )//etag master <field_name>{ create ( authorization : global ); update; delete; field ( readonly ) TravelId; association _Booking { create; }}define behavior for zha_sa_booking1 alias Bookinglock dependent by _Travelauthorization dependent by _Travel//etag master <field_name>{ update; delete; field ( readonly ) TravelId, BookingId; association _Travel; association _BookingSupplement { create; }}define behavior for zha_sabooksuppl1 alias BookingSupplpersistent table /dmo/booksuppl_mlock dependent by _Travelauthorization dependent by _Travel//etag master <field_name>{ update; delete; field ( readonly ) TravelId, BookingId, BookingSupplementId; association _Travel; association _Booking;}
4. Provide the table names, data will be written by RAP in this table.
//Create BDEFdefine behavior for ZHA_SA_TRAVEL1 alias Travelpersistent table /dmo/travel_mlock masterauthorization master ( instance )//etag master <field_name>{ create ( authorization : global ); update; delete; field ( readonly ) TravelId; association _Booking { create; }}
We have a class in behavior definition zbp_ha_sa_travel1 where you can optionally write code.
Also, if you noticed “strict ( 2 );” Keyword which indicates strict SAP guidelines needs to be followed for the development, else errors will be appear at the time of activation.
“Lock master” handles the lock-unlock.
“authorization master(instance) handles the security of data”
authorization master( instance )
“etag master is the timestap field”
etag master LastChangedAt
5. This is managed scenario, so we are asking the RAP to autogenerate crud data.
managed implementation in class zbp_ha_sa_travel unique;strict ( 2 );define behavior for ZHA_SA_TRAVEL alias Travelpersistent table /dmo/travel_mlock masterauthorization master ( instance )etag master LastChangedAt{//Create BDEF create ( authorization : global ); update; delete; //field ( readonly ) TravelId; association _Booking { create; }}define behavior for ZHA_SA_BOOKING alias Bookingpersistent table /dmo/booking_mlock dependent by _Travelauthorization dependent by _Traveletag master LastChangedAt{ update; delete; field ( readonly ) TravelId; association _Travel; association _BookingSupplement { create; }}define behavior for ZHA_SA_BOOKSUPPL alias BookingSupplpersistent table /dmo/booksuppl_mlock dependent by _Travelauthorization dependent by _Travel//etag master <field_name>{ update; delete; field ( readonly ) TravelId, BookingId; association _Travel; association _Booking;}
All the code will be generated once we activate the BDEF.
6. Create Behavior Definition Projection Layer

projection;strict ( 2 );define behavior for zha_sa_travel_proj //alias <alias_name>{ use create; use update; use delete; use association _Booking { create; }}define behavior for zha_sa_booking_proj //alias <alias_name>{ use update; use delete; use association _Travel; use association _BookingSupplement { create; }}define behavior for zha_sa_booksuppl_proj //alias <alias_name>{ use update; use delete; use association _Travel; use association _Booking;}
7. Provide the alias names for all the entities
projection;strict ( 2 );define behavior for zha_sa_travel_proj alias Travel{ use create; use update; use delete; use association _Booking { create; }}define behavior for zha_sa_booking_proj alias Booking{ use update; use delete; use association _Travel; use association _BookingSupplement { create; }}define behavior for zha_sa_booksuppl_proj alias BookingSuppl{ use update; use delete; use association _Travel; use association _Booking;}
Save and Activate
7. Run the FIORI Application


As you can see Create Button is available now.
New lines can be created clicking upon the Create button

8. Create the implementation class, at least basic implementation we need to display data.

CLASS lhc_Travel DEFINITION INHERITING FROM cl_abap_behavior_handler. PRIVATE SECTION. METHODS get_instance_authorizations FOR INSTANCE AUTHORIZATION IMPORTING keys REQUEST requested_authorizations FOR Travel RESULT result. METHODS get_global_authorizations FOR GLOBAL AUTHORIZATION IMPORTING REQUEST requested_authorizations FOR Travel RESULT result.ENDCLASS.CLASS lhc_Travel IMPLEMENTATION. METHOD get_instance_authorizations. ENDMETHOD. METHOD get_global_authorizations. ENDMETHOD.ENDCLASS.
Save and activate
Before(No data displayed)

After:( Data is visible, also you can see delete button is enabled once we select any line)

We will continue the RAP journey in the next article.
Thanks for reading!

Leave a Reply