Sample example for managed scenario in RAP.
Create a table in RAP.
Refer - Steps to implement Basic RAP Example
We will create a simple table: Students table.
* Student ID.
* Student Name.
* Student Location
* Student Branch.
* Student Fee.
Step 1: Open ADT.
Step 2: Connect to SAP BTP by service key.
Step 3: Create a Table with following fields.
* Right click -- New-- Other ABAP repository object-- Dictionary-- database table.
* Click on next and give table name (ZTL_AB_RAP_STUD) and description (Student Details).
* Click on next and select TR and finish.
@EndUserText.label : 'Student table'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table ztl_ab_rap_stud {
key client : abap.clnt not null;
key id : abap.char(10) not null;
name : abap.char(20);
location : abap.char(20);
branch : abap.char(30);
fee : abap.cuky;
}
Step 4: Check and activate.
-------------------------------------------------------------------------------
Create Interface Entity
Step1: Right click -- New -- Other ABAP repository object -- Core data services -- Data definition.
Step 2: Give name and description.
Step 3: Click on next select package, select template as define view entity and finish.
Step 4: Write Code.
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Interface entity view for student'
@Metadata.ignorePropagatedAnnotations: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define root view entity ZI_AB_RAP_STUD as select from ztl_ab_rap_stud
{
key id as Id,
name as Name,
location as Location,
branch as Branch,
fee as Fee
}
Step 5: check and activate.
---------------------------------------------------------------------------
Create Consumption view
Step1: Right click -- New -- Other ABAP repository object -- Core data services -- Data definition.
Step 2: Give name and description.
Step 3: Click on next select package, select template as define view entity and finish.
Step 4: Write Code.
@AbapCatalog.viewEnhancementCategory: [#NONE]
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Consumption view for student'
@Metadata.ignorePropagatedAnnotations: true
@Metadata.allowExtensions: true
@ObjectModel.usageType:{
serviceQuality: #X,
sizeCategory: #S,
dataClass: #MIXED
}
define root view entity ZC_AB_RAP_STUD as
projection on ZI_AB_RAP_STUD as Student
{
@EndUserText.label: 'Student ID'
key Id,
@EndUserText.label: 'Student Name'
Name,
@EndUserText.label: 'Student Location'
Location,
@EndUserText.label: 'Student Branch'
Branch,
@EndUserText.label: 'Student Fee'
Fee
}
Step 5: check and activate.
-----------------------------------------------------------------------------
Create meta data extension
Step 1: Right click -- New -- Meta data extension.
Step 2: Give name, description and extended entity and extended entity name is ZC_AB_RAP_STUD.
Step 3: Click on next select package, select annotate view and click on finish.
Step 4: Write code.
@Metadata.layer: #CORE
@UI: {
headerInfo:
{
typeName: 'Student',
typeNamePlural: 'Students',
title: {
type: #STANDARD,
label: 'Student',
value: 'id'
}
}
}
annotate view ZC_AB_RAP_STUD
with
{
@UI.facet:
[{
id : 'Student',
purpose: #STANDARD,
type: #IDENTIFICATION_REFERENCE,
label: 'Student',
position: 10
}]
@UI:
{
lineItem: [{ position: 10 , label : 'Student ID'}],
identification: [{ position: 10 , label : 'Student ID' }],
selectionField: [{ position: 10 }]
}
Id;
@UI:
{
lineItem: [{ position: 20 , label : 'Student Name'}],
identification: [{ position: 20 , label : 'Student Name' }],
selectionField: [{ position: 20 }]
}
Name;
@UI:
{
lineItem: [{ position: 30 , label : 'Student Loc'}],
identification: [{ position: 30 , label : 'Student Loc' }]
}
Location;
@UI:
{
lineItem: [{ position: 40 , label : 'Student Branch'}],
identification: [{ position: 40 , label : 'Student Branch' }]
}
Branch;
@UI:
{
lineItem: [{ position: 50 , label : 'Student Fee'}],
identification: [{ position: 50 , label : 'Student Fee' }]
}
Fee;
}
Step 5: check and activate.
----------------------------------------------------------------------------------
Create behavior definition for Interface.
Step 1: Right click -- New -- Behavior definition.
Step 2: Give description and root entity.
Step 3: Write Code.
managed implementation in class zbp_i_ab_rap_stud unique;
strict ( 2 );
define behavior for ZI_AB_RAP_STUD alias Student
persistent table ztl_ab_rap_stud
lock master
authorization master ( instance )
//etag master <field_name>
{
create ( authorization : global );
update;
delete;
mapping for ztl_ab_rap_stud
{
Id = id;
Name = name;
Location = location;
Branch = branch;
Fee = fee;
}
}
Step 4: Double click on class and activate the class.
Step 5: check and activate.
----------------------------------------------------------------------------------------
Create behavior definition for consumption.
Step 1: Right click -- New -- Behavior definition.
Step 2: Give name and description.
Step 3: Write Code.
projection;
strict ( 2 );
define behavior for ZC_AB_RAP_STUD alias Student
{
use create;
use update;
use delete;
}
Step 4: check and activate.
-------------------------------------------------------------------------------------------------------------------------
Create Service definition for consumption.
Step 1: Right click on consumption view - new service definition.
Step 2: Give name and description of service.
Step 3: Check and activate.
@EndUserText.label: 'Service definition for Student'
define service Zsd_ab_rap_stud {
expose ZC_AB_RAP_STUD;
}
--------------------------------------------------------------------------------------------------------------
Create Service binding for service definition.
Step 1: Right click on service definition.
Step 2: Give name and description and binding type as Odata v2 -UI.
Step 3: Check and activate and publish.
Step 4: Select entity set and click on preview.
-----------------------------------------------------------------------------------------------------
Create
* Click on create and create new entries.
Update
* Select the entry and click on edit and update the records.
Delete
* Select the record and click on delete.
********************************Thank You*****************************
Comments
Post a Comment