100% found this document useful (1 vote)
156 views33 pages

Sm30 Vs Rap Abap Rap Post

Uploaded by

Cihan SAMSA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
156 views33 pages

Sm30 Vs Rap Abap Rap Post

Uploaded by

Cihan SAMSA
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Experimenting with ABAP RAP Post 2 :SM30 vs RAP: How to

Modernize Data Maintenance in S/4HANA

Table of Contents
Experimenting with ABAP RAP Post 2 :SM30 vs RAP: How to Modernize Data Maintenance
in S/4HANA................................................................................................................. 1
The Right Path to Learn RAP ........................................................................................................ 2
Upcoming SAP event : Devtoberfest ............................................................................................ 2
Link to my previous post ............................................................................................................. 2

How to generate ABAP Repository Objects in ABAP Cloud System ................................ 2


Create claim table zhr_claim_hdr ................................................................................................ 3
Create sample ABAP Class ......................................................................................................... 3
Run the class method ................................................................................................................. 5
Database Table - Data Preview .................................................................................................... 6
Generate ABAP Repository Objects ............................................................................................. 6
Select Generator ........................................................................................................................ 7
Configure Generator ................................................................................................................. 10
Preview OData V4 Service ......................................................................................................... 15
Publish the service ................................................................................................................... 15
Final Output............................................................................................................................. 15
Create new object .................................................................................................................... 16
Generated Classes ................................................................................................................... 16
Metadata Extension.................................................................................................................. 17
Root View Entity ....................................................................................................................... 21
Root View entity with provider contract transactional query ........................................................ 22
Behavior Definition Root View Entity .......................................................................................... 23
Access Control Root View Entity................................................................................................ 24
Access Control-Projection ........................................................................................................ 24
Projection Behavior Definition ................................................................................................... 24
Service Definition ..................................................................................................................... 25
Service Bindings ...................................................................................................................... 25

How to generate ABAP Repository Objects in S/4HANA System (Not Cloud) ................ 25
Generated Class ...................................................................................................................... 26
Database table ........................................................................................................................ 26
Draft Table ............................................................................................................................... 27
Metadata Extension.................................................................................................................. 27
Root View Entity ....................................................................................................................... 29
Root View Entity Provider Contract Transactional Query ............................................................. 30
Behavior Definition for Root View Entity ..................................................................................... 31
Behavior Definition for Projection View ...................................................................................... 32
Service Definition ..................................................................................................................... 32
Service Binding ........................................................................................................................ 32

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
The Right Path to Learn RAP

Dear young ABAP Champions,

When it comes to learning RAP, don’t waste time relying on AI tools like ChatGPT or
Gemini for this experiment – I tried it myself and it didn’t work. Instead, trust the official
SAP resources and practice hands-on.

Follow the official GitHub tutorials here:


ABAP RAP100 GitHub Exercises

And if you want to go deeper and truly master RAP, I highly recommend this SAP Press
book:
ABAP RESTful Application Programming Model

Upcoming SAP event : Devtoberfest


https://community.sap.com/t5/devtoberfest-blog-posts/devtoberfest-2025-
welcome/ba-p/14182817

Link to my previous post


https://lnkd.in/p/efi8Qe3j

How to generate ABAP Repository Objects in ABAP Cloud System

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Create claim table zhr_claim_hdr

@EndUserText.label : 'Claim HDR'


@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zhr_claim_hdr {

key client : abap.clnt not null;


key claim_id : abap.numc(10) not null;
employee_id : abap.char(10);
claim_type : abap.char(4);
claim_date : abap.dats;
description : abap.char(100);
@Semantics.amount.currencyCode : 'zhr_claim_hdr.currency_code'
amount : abap.curr(15,2);
currency_code : /dmo/currency_code;
status : abap.char(1);
approver_id : abap.char(12);
created_by : abp_creation_user;
created_at : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;

Create sample ABAP Class


CLASS zcl_demo_claim DEFINITION
PUBLIC

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES: if_oo_adt_classrun.
METHODS:
demo_insert_500_claims.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_demo_claim IMPLEMENTATION.


METHOD if_oo_adt_classrun~main.
demo_insert_500_claims( ).
ENDMETHOD.
METHOD demo_insert_500_claims.
DATA: lv_index TYPE i,
lv_claim_id TYPE int2,
lv_amount TYPE p DECIMALS 2,
lt_claims TYPE STANDARD TABLE OF zhr_claim_hdr.

DO 500 TIMES.
lv_index = sy-index.
lv_claim_id = lv_index. " claim_id = 0000000001 … 0000000500
lv_amount = ( 100 + ( lv_index MOD 50 ) * 10 ). " amount varies
CONVERT DATE sy-datum TIME sy-uzeit INTO TIME STAMP DATA(lv_ts) TIME ZONE sy-zonlo.

APPEND VALUE #(
client = sy-mandt
claim_id = lv_claim_id
employee_id = |E{ lv_index }|
claim_type = COND #(
WHEN lv_index MOD 3 = 0 THEN 'TRVL'
WHEN lv_index MOD 3 = 1 THEN 'MEAL'
ELSE 'HOTL' )
claim_date = sy-datum - lv_index
description = |Demo Claim { lv_index }|
amount = lv_amount
currency_code = 'EUR'
status = 'N'
approver_id = 'MANAGER1'
created_by = sy-uname
created_at = lv_ts
) TO lt_claims.
ENDDO.
delete from zhr_claim_hdr.
" Bulk insert for performance
INSERT zhr_claim_hdr FROM TABLE @lt_claims.
IF sy-subrc = 0.

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
commit work.
cl_demo_output=>display( 'Insert success' ).
ELSE.
rollback work.
cl_demo_output=>display( 'Insert failed' ).
ENDIF.
ENDMETHOD.

ENDCLASS.

Run the class method

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Database Table - Data Preview

Generate ABAP Repository Objects

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Select Generator

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
The below objects are generated automatically based on the database table.

• SAP object node type


• SAP object type
• Service binding
• Service definition
• Access control
• RAP projection behavior definition
• RAP behavior definition
• Data definition for CDS projection view entity
• Data definition for CDS view entity
• Metadata extension
• Database table for draft table
• ABAP class for ABAP behavior pool

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Configure Generator

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
Preview OData V4 Service

Publish the service

Final Output

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Create new object

Generated Classes
Class 1

class ZBP_C_HRCLAIM_HDR0001 definition


public
abstract
final
for behavior of ZC_HRCLAIM_HDR0001 .

public section.
protected section.
private section.
ENDCLASS.

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
CLASS ZBP_C_HRCLAIM_HDR0001 IMPLEMENTATION.
ENDCLASS.

Class 2

class ZBP_R_HRCLAIM_HDR0001 definition


public
abstract
final
for behavior of ZR_HRCLAIM_HDR0001 .

public section.
protected section.
private section.
ENDCLASS.

CLASS ZBP_R_HRCLAIM_HDR0001 IMPLEMENTATION.


ENDCLASS.

Metadata Extension
@Metadata.layer: #CORE
@UI.headerInfo.title.type: #STANDARD
@UI.headerInfo.title.value: 'ClaimID'
@UI.headerInfo.description.type: #STANDARD
@UI.headerInfo.description.value: 'ClaimID'
annotate view ZC_HRCLAIM_HDR0001 with
{
@EndUserText.label: 'ClaimID'
@UI.facet: [ {
label: 'General Information',
id: 'GeneralInfo',
purpose: #STANDARD,
position: 10 ,
type: #IDENTIFICATION_REFERENCE
}]
@UI.identification: [ {
position: 10 ,
label: 'ClaimID'
}]
@UI.lineItem: [ {
position: 10 ,
label: 'ClaimID'
}]
@UI.selectionField: [ {
position: 10
}]
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
ClaimID;

@EndUserText.label: 'EmployeeID'
@UI.identification: [ {
position: 20 ,
label: 'EmployeeID'
}]
@UI.lineItem: [ {
position: 20 ,
label: 'EmployeeID'
}]
@UI.selectionField: [ {
position: 20
}]
EmployeeID;

@EndUserText.label: 'ClaimType'
@UI.identification: [ {
position: 30 ,
label: 'ClaimType'
}]
@UI.lineItem: [ {
position: 30 ,
label: 'ClaimType'
}]
@UI.selectionField: [ {
position: 30
}]
ClaimType;

@EndUserText.label: 'ClaimDate'
@UI.identification: [ {
position: 40 ,
label: 'ClaimDate'
}]
@UI.lineItem: [ {
position: 40 ,
label: 'ClaimDate'
}]
@UI.selectionField: [ {
position: 40
}]
ClaimDate;

@EndUserText.label: 'Description'
@UI.identification: [ {
position: 50 ,
label: 'Description'
}]
@UI.lineItem: [ {
position: 50 ,

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
label: 'Description'
}]
@UI.selectionField: [ {
position: 50
}]
Description;

@EndUserText.label: 'Amount'
@UI.identification: [ {
position: 60 ,
label: 'Amount'
}]
@UI.lineItem: [ {
position: 60 ,
label: 'Amount'
}]
@UI.selectionField: [ {
position: 60
}]
Amount;

@EndUserText.label: 'Status'
@UI.identification: [ {
position: 70 ,
label: 'Status'
}]
@UI.lineItem: [ {
position: 70 ,
label: 'Status'
}]
@UI.selectionField: [ {
position: 70
}]
Status;

@EndUserText.label: 'ApproverID'
@UI.identification: [ {
position: 80 ,
label: 'ApproverID'
}]
@UI.lineItem: [ {
position: 80 ,
label: 'ApproverID'
}]
@UI.selectionField: [ {
position: 80
}]
ApproverID;

@UI.identification: [ {
position: 90

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
}]
@UI.lineItem: [ {
position: 90
}]
@UI.selectionField: [ {
position: 90
}]
CreatedBy;

@UI.identification: [ {
position: 100
}]
@UI.lineItem: [ {
position: 100
}]
@UI.selectionField: [ {
position: 100
}]
CreatedAt;

@UI.identification: [ {
position: 110
}]
@UI.lineItem: [ {
position: 110
}]
@UI.selectionField: [ {
position: 110
}]
LocalLastChangedBy;

@UI.identification: [ {
position: 120
}]
@UI.lineItem: [ {
position: 120
}]
@UI.selectionField: [ {
position: 120
}]
LocalLastChangedAt;

@UI.identification: [ {
position: 130
}]
@UI.lineItem: [ {
position: 130
}]
@UI.selectionField: [ {
position: 130
}]

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
LastChangedAt;

@EndUserText.label: '_BaseEntity'
@UI.identification: [ {
position: 140 ,
label: '_BaseEntity'
}]
@UI.lineItem: [ {
position: 140 ,
label: '_BaseEntity'
}]
@UI.selectionField: [ {
position: 140
}]
_BaseEntity;
}

Root View Entity


@AccessControl.authorizationCheck: #MANDATORY
@Metadata.allowExtensions: true
@ObjectModel.sapObjectNodeType.name: 'ZHRCLAIM_HDR1'
@EndUserText.label: '###GENERATED Core Data Service Entity'
define root view entity ZR_HRCLAIM_HDR0001
as select from ZHR_CLAIM_HDR
{
key claim_id as ClaimID,
employee_id as EmployeeID,
claim_type as ClaimType,
claim_date as ClaimDate,
description as Description,
@Semantics.amount.currencyCode: 'CurrencyCode'
amount as Amount,
@Consumption.valueHelpDefinition: [ {
entity.name: 'I_CurrencyStdVH',
entity.element: 'Currency',
useForValidation: true
}]
currency_code as CurrencyCode,
status as Status,
approver_id as ApproverID,
@Semantics.user.createdBy: true
created_by as CreatedBy,
@Semantics.systemDateTime.createdAt: true
created_at as CreatedAt,
@Semantics.user.localInstanceLastChangedBy: true
local_last_changed_by as LocalLastChangedBy,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
@Semantics.systemDateTime.lastChangedAt: true
last_changed_at as LastChangedAt
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
}

Root View entity with provider contract transactional query


@Metadata.allowExtensions: true
@Metadata.ignorePropagatedAnnotations: true
@Endusertext: {
Label: '###GENERATED Core Data Service Entity'
}
@Objectmodel: {
Sapobjectnodetype.Name: 'ZHRCLAIM_HDR1'
}
@AccessControl.authorizationCheck: #MANDATORY
define root view entity ZC_HRCLAIM_HDR0001
provider contract TRANSACTIONAL_QUERY
as projection on ZR_HRCLAIM_HDR0001
association [1..1] to ZR_HRCLAIM_HDR0001 as _BaseEntity on $projection.CLAIMID =
_BaseEntity.CLAIMID
{
key ClaimID,
EmployeeID,
ClaimType,
ClaimDate,
Description,
@Semantics: {
Amount.Currencycode: 'CurrencyCode'
}
Amount,
@Consumption: {
Valuehelpdefinition: [ {
Entity.Element: 'Currency',
Entity.Name: 'I_CurrencyStdVH',
Useforvalidation: true
}]
}
CurrencyCode,
Status,
ApproverID,
@Semantics: {
User.Createdby: true
}
CreatedBy,
@Semantics: {
Systemdatetime.Createdat: true
}
CreatedAt,
@Semantics: {
User.Localinstancelastchangedby: true
}
LocalLastChangedBy,
@Semantics: {
Systemdatetime.Localinstancelastchangedat: true

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
}
LocalLastChangedAt,
@Semantics: {
Systemdatetime.Lastchangedat: true
}
LastChangedAt,
_BaseEntity
}

Behavior Definition Root View Entity


managed implementation in class ZBP_R_HRCLAIM_HDR0001 unique;
strict ( 2 );
with draft;
extensible;
define behavior for ZR_HRCLAIM_HDR0001 alias ZrHrclaimHdr0001
persistent table ZHR_CLAIM_HDR
extensible
draft table ZHRCLIM_HDR001_D
etag master LocalLastChangedAt
lock master total etag LastChangedAt
authorization master( global )
{
field ( mandatory : create )
ClaimID;

field ( readonly )
CreatedBy,
CreatedAt,
LocalLastChangedBy,
LocalLastChangedAt,
LastChangedAt;

field ( readonly : update )


ClaimID;

create;
update;
delete;

draft action Activate optimized;


draft action Discard;
draft action Edit;
draft action Resume;
draft determine action Prepare;

mapping for ZHR_CLAIM_HDR corresponding extensible


{
ClaimID = claim_id;
EmployeeID = employee_id;
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
ClaimType = claim_type;
ClaimDate = claim_date;
Description = description;
Amount = amount;
CurrencyCode = currency_code;
Status = status;
ApproverID = approver_id;
CreatedBy = created_by;
CreatedAt = created_at;
LocalLastChangedBy = local_last_changed_by;
LocalLastChangedAt = local_last_changed_at;
LastChangedAt = last_changed_at;
}

Access Control Root View Entity


@EndUserText.label: 'ZR_HRCLAIM_HDR0001'
@MappingRole: true
define role ZR_HRCLAIM_HDR0001 {
grant select on ZR_HRCLAIM_HDR0001
where TRUE;
}

Access Control-Projection
@EndUserText.label: 'ZC_HRCLAIM_HDR0001'
@MappingRole: true
define role ZC_HRCLAIM_HDR0001 {
grant select on ZC_HRCLAIM_HDR0001
where INHERITING CONDITIONS FROM ENTITY ZR_HRCLAIM_HDR0001 REPLACING { ROOT
WITH _BaseEntity };
}

Projection Behavior Definition


projection implementation in class ZBP_C_HRCLAIM_HDR0001 unique;
strict ( 2 );
extensible;
use draft;
use side effects;
define behavior for ZC_HRCLAIM_HDR0001 alias ZcHrclaimHdr0001
extensible
use etag
{
use create;
use update;
use delete;

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
use action Edit;
use action Activate;
use action Discard;
use action Resume;
use action Prepare;

}
Inbound Service

Service Definition
@EndUserText: {
label: 'Service Definition for ZC_HRCLAIM_HDR0001'
}
@ObjectModel: {
leadingEntity: {
name: 'ZC_HRCLAIM_HDR0001'
}
}
define service ZUI_ZHRCLAIM_HDR2_O4 provider contracts odata_v4_ui {
expose ZC_HRCLAIM_HDR0001;
}

Service Bindings

How to generate ABAP Repository Objects in S/4HANA System (Not


Cloud)
After generating the ABAP repository objects, I noticed that several steps were missing.
Therefore, manual code adjustments are often necessary in an S/4HANA on-premise
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
system, but not in the S/4HANA Cloud system. (You can compare the objects below
with those in an advanced system.)

Generated Class
class ZBP_R_HR_CLAIM_HDR definition
public
abstract
final
for behavior of ZR_HR_CLAIM_HDR .

public section.
protected section.
private section.
ENDCLASS.

CLASS ZBP_R_HR_CLAIM_HDR IMPLEMENTATION.


ENDCLASS.

Database table
@EndUserText.label : 'Claim HDR'
@AbapCatalog.enhancement.category : #NOT_EXTENSIBLE
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zhr_claim_hdr {

key client : abap.clnt not null;


key claim_id : abap.numc(10) not null;
employee_id : abap.char(10);
claim_type : abap.char(4);
claim_date : abap.dats;
description : abap.char(100);
@Semantics.amount.currencyCode : 'zhr_claim_hdr.currency_code'
amount : abap.curr(15,2);
currency_code : /dmo/currency_code;
status : abap.char(1);
approver_id : abap.char(12);
created_by : abp_creation_user;
created_at : abp_creation_tstmpl;
local_last_changed_by : abp_locinst_lastchange_user;
local_last_changed_at : abp_locinst_lastchange_tstmpl;
last_changed_at : abp_lastchange_tstmpl;

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Draft Table
@EndUserText.label : '##GENERATED ZHR_CLAIM_HDR'
@AbapCatalog.enhancement.category : #EXTENSIBLE_ANY
@AbapCatalog.tableCategory : #TRANSPARENT
@AbapCatalog.deliveryClass : #A
@AbapCatalog.dataMaintenance : #RESTRICTED
define table zhr_claim_hdr_d {

key mandt : mandt not null;


key claimid : abap.numc(10) not null;
employeeid : abap.char(10);
claimtype : abap.char(4);
claimdate : abap.dats;
description : abap.char(100);
@Semantics.amount.currencyCode : 'zhr_claim_hdr_d.currencycode'
amount : abap.curr(15,2);
currencycode : /dmo/currency_code;
status : abap.char(1);
approverid : abap.char(12);
createdby : abp_creation_user;
createdat : abp_creation_tstmpl;
locallastchangedby : abp_locinst_lastchange_user;
locallastchangedat : abp_locinst_lastchange_tstmpl;
lastchangedat : abp_lastchange_tstmpl;
"%admin" : include sych_bdl_draft_admin_inc;

Metadata Extension
@Metadata.layer: #CORE
@UI: {
headerInfo: {
typeName: 'ZC_HR_CLAIM_HDR',
typeNamePlural: 'ZC_HR_CLAIM_HDRs'
}
}
annotate view ZC_HR_CLAIM_HDR with
{
@UI.facet: [ {
id: 'idIdentification',
type: #IDENTIFICATION_REFERENCE,
label: 'ZC_HR_CLAIM_HDR',
position: 10
}]
@UI.lineItem: [ {
position: 10 ,
importance: #MEDIUM,
label: 'ClaimID'
}]
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
@UI.identification: [ {
position: 10 ,
label: 'ClaimID'
}]
ClaimID;

@UI.lineItem: [ {
position: 20 ,
importance: #MEDIUM,
label: 'EmployeeID'
}]
@UI.identification: [ {
position: 20 ,
label: 'EmployeeID'
}]
EmployeeID;

@UI.lineItem: [ {
position: 30 ,
importance: #MEDIUM,
label: 'ClaimType'
}]
@UI.identification: [ {
position: 30 ,
label: 'ClaimType'
}]
ClaimType;

@UI.lineItem: [ {
position: 40 ,
importance: #MEDIUM,
label: 'ClaimDate'
}]
@UI.identification: [ {
position: 40 ,
label: 'ClaimDate'
}]
ClaimDate;

@UI.lineItem: [ {
position: 50 ,
importance: #MEDIUM,
label: 'Description'
}]
@UI.identification: [ {
position: 50 ,
label: 'Description'
}]
Description;

@UI.lineItem: [ {

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
position: 60 ,
importance: #MEDIUM,
label: 'Amount'
}]
@UI.identification: [ {
position: 60 ,
label: 'Amount'
}]
Amount;

@UI.lineItem: [ {
position: 70 ,
importance: #MEDIUM,
label: ''
}]
@UI.identification: [ {
position: 70 ,
label: ''
}]
CurrencyCode;

@UI.lineItem: [ {
position: 80 ,
importance: #MEDIUM,
label: 'Status'
}]
@UI.identification: [ {
position: 80 ,
label: 'Status'
}]
Status;

@UI.lineItem: [ {
position: 90 ,
importance: #MEDIUM,
label: 'ApproverID'
}]
@UI.identification: [ {
position: 90 ,
label: 'ApproverID'
}]
ApproverID;

@UI.hidden: true
LocalLastChangedAt;
}

Root View Entity


@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: '##GENERATED ZHR_CLAIM_HDR'
� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –
SM30 vs RAP
define root view entity ZR_HR_CLAIM_HDR
as select from zhr_claim_hdr
{
key claim_id as ClaimID,
employee_id as EmployeeID,
claim_type as ClaimType,
claim_date as ClaimDate,
description as Description,
@Semantics.amount.currencyCode: 'CurrencyCode'
amount as Amount,
currency_code as CurrencyCode,
status as Status,
approver_id as ApproverID,
@Semantics.user.createdBy: true
created_by as CreatedBy,
@Semantics.systemDateTime.createdAt: true
created_at as CreatedAt,
@Semantics.user.localInstanceLastChangedBy: true
local_last_changed_by as LocalLastChangedBy,
@Semantics.systemDateTime.localInstanceLastChangedAt: true
local_last_changed_at as LocalLastChangedAt,
@Semantics.systemDateTime.lastChangedAt: true
last_changed_at as LastChangedAt

Root View Entity Provider Contract Transactional Query


@AccessControl.authorizationCheck: #CHECK
@Metadata.allowExtensions: true
@EndUserText.label: 'Projection View for ZR_HR_CLAIM_HDR'
@ObjectModel.semanticKey: [ 'ClaimID' ]
define root view entity ZC_HR_CLAIM_HDR
provider contract transactional_query
as projection on ZR_HR_CLAIM_HDR
{
key ClaimID,
EmployeeID,
ClaimType,
ClaimDate,
Description,
Amount,
CurrencyCode,
Status,
ApproverID,
LocalLastChangedAt

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Behavior Definition for Root View Entity
managed implementation in class ZBP_R_HR_CLAIM_HDR unique;
strict ( 2 );
with draft;

define behavior for ZR_HR_CLAIM_HDR


persistent table zhr_claim_hdr
draft table ZHR_CLAIM_HDR_D
etag master LocalLastChangedAt
lock master total etag LastChangedAt
authorization master( global )

{
field ( mandatory : create )
ClaimID;

field ( readonly )
CreatedAt,
CreatedBy,
LastChangedAt,
LocalLastChangedAt,
LocalLastChangedBy;

field ( readonly : update )


ClaimID;

create;
update;
delete;

draft action Edit;


draft action Activate optimized;
draft action Discard;
draft action Resume;
draft determine action Prepare;

mapping for ZHR_CLAIM_HDR


{
ClaimID = claim_id;
EmployeeID = employee_id;
ClaimType = claim_type;
ClaimDate = claim_date;
Description = description;
Amount = amount;
CurrencyCode = currency_code;
Status = status;
ApproverID = approver_id;
CreatedBy = created_by;
CreatedAt = created_at;

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
LocalLastChangedBy = local_last_changed_by;
LocalLastChangedAt = local_last_changed_at;
LastChangedAt = last_changed_at;
}
}

Behavior Definition for Projection View


projection;
strict ( 2 );
use draft;

define behavior for ZC_HR_CLAIM_HDR


use etag

{
use create;
use update;
use delete;

use action Edit;


use action Activate;
use action Discard;
use action Resume;
use action Prepare;
}

Service Definition
@EndUserText.label: 'Service definition for ZC_HR_CLAIM_HDR'
define service ZUI_HR_CLAIM_HDR_O4 {
expose ZC_HR_CLAIM_HDR;
}

Service Binding

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP
Thank you for reading! Please always learn from experienced SAP architects and dive
deeper into the concepts. RAP is still new, and there are many architectural frameworks
behind it. To truly master it, rely on the official SAP documentation and trusted
resources.

Next, I’ll continue with the Leave Application example. Apologies for the delay — I’ve
been busy with my current project, but I’m sharing this post in between.

Happy Learning!

� PrepReady by Maheswari Angamuthu | � Experimenting with ABAP RAP Post 2 –


SM30 vs RAP

You might also like