Sample example for managed scenario in RAP.
Refer - Steps to implement Basic RAP Example
Create a table in RAP.
We will create a simple table: Students table.
* Student ID.
* Student Name.
* Student Interview Location.
* Student Interview Date
* Student selected or not.
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_STUS) and description (Student interview details).
* Click on next and select TR and finish.
Step 4: Mention the field names.
@EndUserText.label : 'Student interview details'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table ztl_ab_rap_stus {
key client : abap.clnt not null;
key student_id : abap.char(10) not null;
student_name : abap.char(30);
student_i_loc : abap.char(20);
student_i_date : abap.datn;
student_status : abap_boolean;
}
Step 5: 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_STUS
as select from ztl_ab_rap_stus
{
key student_id as StudentId,
student_name as StudentName,
student_i_loc as StudentILoc,
student_i_date as StudentIDate,
student_status as StudentStatus
}
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_STUS
as projection on ZI_AB_RAP_STUS as Student
{
key StudentId,
StudentName,
StudentILoc,
StudentIDate,
StudentStatus
}
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_STUS (or right click on consumption view and create meta data extension).
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: 'StudentId'
}
}
}
annotate view ZC_AB_RAP_STUS
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 }]
}
StudentId;
@UI:
{
lineItem: [{ position: 20 , label : 'Student Name'}],
identification: [{ position: 20 , label : 'Student Name' }],
selectionField: [{ position: 20 }]
}
StudentName;
@UI:
{
lineItem: [{ position: 30 , label : 'Student Interview Loc'}],
identification: [{ position: 30 , label : 'Student Interview Loc' }]
}
StudentILoc;
@UI:
{
lineItem: [{ position: 40 , label : 'Student Interview Date'}],
identification: [{ position: 40 , label : 'Student Interview Date' }]
}
StudentIDate;
@UI:
{
lineItem: [{ position: 50 , label : 'Student Interview Status'}],
identification: [{ position: 50 , label : 'Student Interview Status' }]
}
StudentStatus;
}
Step 5: check and activate.
----------------------------------------------------------------------------------
Create behavior definition for Interface.
Step 1: Right click on interface view -- New Behavior definition.
Step 2: Give description.
Step 3: Write Code.
managed implementation in class zbp_i_ab_rap_stus unique;
strict ( 2 );
define behavior for ZI_AB_RAP_STUS alias Student
persistent table ztl_ab_rap_stus
lock master
authorization master ( instance )
//etag master <field_name>
{
create ( authorization : global );
update;
delete;
mapping for ztl_ab_rap_stus
{
StudentId = student_id;
StudentName = student_name;
StudentILoc = student_i_loc;
StudentIDate = student_i_date;
StudentStatus = student_status;
}
// field ( readonly ) StudentId;
}
Step 4: check and activate.
Step 5: Double click on class and activate the class.
----------------------------------------------------------------------------------------
Create behavior definition for consumption.
Step 1: Right click on consumption view -- New Behavior definition.
Step 2: Give description.
Step 3: Write Code.
projection;
strict ( 2 );
define behavior for ZC_AB_RAP_STUS 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.
@EndUserText.label: 'Service definition for Student'
define service Zsd_ab_rap_stus
{
expose ZC_AB_RAP_STUS;
}
Step 3: Check and activate.
--------------------------------------------------------------------------------------------------------------
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