Create Data Model and Lock Object in SAP BTP, ABAP Environment
- How to create an ABAP package
- How to create a domain
- How to create a table
- How to create a data definition
- How to create a lock object
Prerequisites
- You need a SAP BTP, ABAP environment license.
- ADT version 2.96 or higher
In this tutorial, wherever XXX
appears, use a number (e.g. 000
).
- Step 1
-
Go to ADT and right-click on
ZLOCAL
, select the menu path New > ABAP Package. -
Create your package:
- Name:
Z_ROOM_XXX
- Description:
My Package XXX
Click Next>.
- Name:
-
Click Next>.
-
Click Finish.
-
- Step 2
-
Right-click on Favorite Packages and select Add Package…
-
Search for
Z_ROOM_XXX
, select it and click OK.
-
- Step 3
-
Right-click on
Z_ROOM_XXX
, select the menu path New > Other ABAP Repository Object -
Search for Domain, select it and click Next>.
-
Create your domain:
- Name:
Z_LOCA_DOM_XXX
- Description:
Location
Click Next>.
- Name:
-
Click Finish.
-
Enhance your domain with following information:
- Data Type:
CHAR
- Length: 3
- Output Length: 3
Save and activate.
- Data Type:
-
- Step 4
-
Right-click on
Z_ROOM_XXX
, select the menu path New > Other ABAP Repository Object -
Search for Data Element, select it and click Next>.
-
Create your data element:
- Name:
Z_LOCA_DTEL_XXX
- Description:
Location
Click Next>.
- Name:
-
Click Finish.
-
Enhance your data element with following information:
- Category: Domain
- Type Name:
Z_LOCA_DOM_XXX
Save and activate.
-
- Step 5
-
Right-click on
Z_ROOM_XXX
, select the menu path New > Other ABAP Repository Object -
Search for Database Table, select it and click Next>.
-
Create your database table:
- Name:
ZROOM_XXX
- Description:
Room XXX
Click Next>.
- Name:
-
Click Finish.
-
Create your data table with following coding:
ABAPCopy@EndUserText.label : 'Room XXX' @AbapCatalog.enhancementCategory : #NOT_EXTENSIBLE @AbapCatalog.tableCategory : #TRANSPARENT @AbapCatalog.deliveryClass : #A @AbapCatalog.dataMaintenance : #LIMITED define table zroom_xxx { key client : abap.clnt not null; key id : abap.char(20) not null; @EndUserText.label : 'Seats' seats : abap.dec(3,0); location : z_loca_dtel_xxx; hasbeamer : abap_boolean; hasvideo : abap_boolean; userrating : abap.char(2); lastchangeddatetime : tzntstmpl; lastchangedbyuser : syuname; }
Save and activate.
-
- Step 6
-
Right-click on
Z_ROOM_XXX
, select the menu path New > Other ABAP Repository Object -
Search for Data Definition, select it and click Next>.
-
Create your data definition:
- Name:
Z_I_ROOM_XXX
- Description:
Room XXX
Click Next>.
- Name:
-
Click Finish.
-
Create your data definition with following coding:
ABAPCopy@AbapCatalog.sqlViewName: 'Z_M_ROOM_XXX' @AbapCatalog.compiler.compareFilter: true @AbapCatalog.preserveKey: true @AccessControl.authorizationCheck: #CHECK @EndUserText.label: 'Room XXX' @Search.searchable @UI.headerInfo: { typeName: 'Room', typeNamePlural: 'Rooms' , title : { value: 'ID' } } define root view Z_I_ROOM_XXX as select from zroom_xxx as room association [0..1] to I_BusinessUserBasic as _SAPSysAdminDataChangeUser on _SAPSysAdminDataChangeUser.UserID = room.lastchangedbyuser { @UI.facet: [ { type: #COLLECTION, position: 1, id: 'ROOM', label: 'Room' }, { type: #IDENTIFICATION_REFERENCE, position: 1, parentId: 'ROOM', label: 'General Information'}] @EndUserText: { label: 'ID' } @Search: { defaultSearchElement: true } @UI: { lineItem: [{ position: 1 }], identification: [{ position: 1 }] } key room.id, @EndUserText: { label: 'Seats' } @UI: { lineItem: [{ position: 3 }], identification: [{ position: 2 }] } room.seats, @EndUserText: { label: 'Location' } @UI: { lineItem: [{ position: 4 }], identification: [{ position: 3 }] } room.location, @EndUserText: { label: 'Has Beamer' } @UI: { lineItem: [{ position: 5 }], identification: [{ position: 4 }] } room.hasbeamer, @EndUserText: { label: 'Has Video' } @UI: { lineItem: [{ position: 7 }], identification: [{ position: 5 }] } room.hasvideo, @EndUserText: { label: 'User Rating' } @UI: { lineItem: [{ position: 8 }], identification: [{ position: 6 }] } userrating, @EndUserText: { label: 'Last Changed On' } @UI: { identification: [{ position: 7 }] } room.lastchangeddatetime, @EndUserText: { label: 'Last Changed By' } @UI: { identification: [{ position: 8 }], textArrangement: #TEXT_ONLY } room.lastchangedbyuser, @UI.hidden: true _SAPSysAdminDataChangeUser }
Save and activate.
-
- Step 7
-
Right-click on
Z_ROOM_XXX
, select the menu path New > Other ABAP Repository Object -
Search for Lock Object, select it and click Next>.
-
Create your database table:
- Name:
EZROOMXXX
- Description:
LOCK
Click Next>.
- Name:
-
Click Finish.
-
Enhance your lock object with following information:
- Lock Mode: Write Lock
Save and activate.
-
- Step 8
How should the name of your lock object begin?