Professional Documents
Culture Documents
Purpose
Requirement
1. Design / Prototype
2. Create Dictionary Objects
3. Create Interface View (CDS)
4. Business Object Generation (CDS – Object Model
Annotations )
5. Generated Business Object
6. BOPF – Development
Determination
Validation
Action
Alternative Key
7. Test BOPF Object using BOBT
8. Access Control (CDS)
9. Consumption View (CDS)
10. OData Service Generation and Registration
11. Test OData Service using SAP Gateway Client
12. UI development
Note: This blog will not get into basic steps of installing
ADT and connecting backend system to ADT or How to create CDS
views. You can refer to below links for the same, in case this
is your first-hand experience with ADT & CDS
@AbapCatalog.sqlViewName: 'Z2812IPBHEAD'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@ObjectModel:{
usageType:{
sizeCategory: #L,
serviceQuality: #X,
dataClass: #TRANSACTIONAL
}
}
@VDM.viewType: #BASIC
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book Header Inerface View'
define view Z2812_I_PB_HEAD
as select from z2812_pb_d_head as headData {
//z2812_pb_header
key pb_head_uuid,
pb_id,
pb_owner,
pb_first_name,
pb_last_name,
pb_email_id,
pb_created_at,
pb_changed_at
}
@AbapCatalog.sqlViewName: 'Z2812IPBITEM'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@ObjectModel:{
usageType:{
sizeCategory: #L,
serviceQuality: #X,
dataClass: #TRANSACTIONAL
}
}
@VDM.viewType: #BASIC
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book Item Inerface View'
define view Z2812_I_PB_ITEM
as select from z2812_pb_d_item as itemData{
//z2812_pb_item
key pb_item_uuid,
pb_head_uuid,
pb_category,
pb_telephone,
pb_created_at,
pb_changed_at
}
Basic View
@AbapCatalog.sqlViewName: 'Z2812IPBCATG'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@ObjectModel:{
usageType: {
serviceQuality: #B,
sizeCategory: #S,
dataClass: #MASTER
}
}
@VDM.viewType: #BASIC
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book Category Interface View'
define view Z2812_I_PB_CATG as select from z2812_pb_d_catg{
//z2812_pb_d_catg
key pb_category,
key pb_spras,
pb_category_desc
}
@AbapCatalog.sqlViewName: 'Z2812IPBCATVH'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@ClientHandling.algorithm: #SESSION_VARIABLE
@ObjectModel:{
dataCategory: #VALUE_HELP,
representativeKey: 'PB_CATEGORY',
usageType: {
sizeCategory: #S,
serviceQuality: #B,
dataClass: #MASTER
}
}
@VDM.viewType: #BASIC
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book Category Value Help View'
define view Z2812_I_PB_CATG_VH as select from Z2812_I_PB_CATG
{
//Z2812_I_PB_CATG
key pb_category,
pb_category_desc
} where pb_spras = $session.system_language
Text View
@AbapCatalog.sqlViewName: 'Z2812IPBCTGTXT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@ObjectModel:{
dataCategory: #TEXT,
representativeKey: 'PB_CATEGORY',
usageType: {
sizeCategory: #S,
serviceQuality: #B,
dataClass: #MASTER
}
}
@VDM.viewType: #BASIC
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book CategoryText View'
define view Z2812_I_PB_CATG_TXT as select from Z2812_I_PB_CATG
{
//Z2812_I_PB_CATG
key pb_category,
pb_category_desc
} where pb_spras = $session.system_language
Note: Value Help and Text view are not categories of views.
These are just typed and used for better understanding.
Different types of views are Basic, Composite, Consumption,
Extension, Structure, Transactional
<< Top
Business Object Generation
(CDS – Object Model
Annotations )
1. Design / Prototype
2. Create Dictionary Objects
3. Create Interface View (CDS)
4. Business Object Generation (CDS – Object Model
Annotations)
5. Generated Business Object
6. BOPF – Development
Determination
Validation
Action
Alternative Key
7. Test BOPF Object using BOBT
8. Access Control (CDS)
9. Consumption View (CDS)
10. OData Service Generation and Registration
11. Test OData Service using SAP Gateway Client
12. UI development
Draft table name is proposed and system will auto generate the
table.
@AbapCatalog.sqlViewName: 'Z2812IPBITEMND'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@VDM.viewType: #TRANSACTIONAL
@EndUserText.label: 'Phone Book Item Transactional - Node
View'
define view Z2812_I_PB_ITEM_ND
as select from Z2812_I_PB_ITEM as itemData
-- Category Description
left outer join Z2812_I_PB_CATG_TXT as _categoryText
on _categoryText.pb_category =
itemData.pb_category
-- Association to Header
association [1..1] to Z2812_I_PB_HEAD_ND as _headData
on $projection.pb_head_uuid =
_headData.pb_head_uuid
{
//itemData
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
key pb_item_uuid,
@ObjectModel.readOnly: true
pb_head_uuid,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
@ObjectModel.mandatory: true
itemData.pb_category,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_category_desc,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
@ObjectModel.mandatory: true
pb_telephone,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_created_at,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_changed_at,
@ObjectModel.association.type: [#TO_COMPOSITION_PARENT,
#TO_COMPOSITION_ROOT]
_headData
}
@AbapCatalog.sqlViewName: 'Z2812IPBHEADND'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
-- Business Object Model - Header Data
@ObjectModel:{
modelCategory: #BUSINESS_OBJECT,
transactionalProcessingEnabled: true,
compositionRoot: true,
semanticKey: ['PB_ID'],
alternativeKey: [{
id: 'PB_ID',
uniqueness: #UNIQUE_IF_NOT_INITIAL,
element: ['PB_ID']
}],
writeActivePersistence: 'Z2812_PB_D_HEAD',
draftEnabled: true,
writeDraftPersistence: 'Z2812_PB_D_HDR_D',
createEnabled: true,
updateEnabled: true,
deleteEnabled: true,
entityChangeStateId: 'PB_CHANGED_AT',
lifecycle.enqueue.expiryBehavior: #RELATIVE_TO_LAST_CHANGE,
lifecycle.enqueue.expiryInterval: 'PT60M',
usageType: {
serviceQuality: #D,
sizeCategory: #L,
dataClass: #TRANSACTIONAL
}
}
@VDM.viewType: #TRANSACTIONAL
@Metadata.ignorePropagatedAnnotations: true
@EndUserText.label: 'Phone Book Head Transactional - Node View
- BO'
define view Z2812_I_PB_HEAD_ND
as select from Z2812_I_PB_HEAD as headData
association [0..*] to Z2812_I_PB_ITEM_ND as _itemData
on $projection.pb_head_uuid =
_itemData.pb_head_uuid
{
//headData
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
key pb_head_uuid,
@ObjectModel.readOnly: true
@ObjectModel.mandatory: true
pb_id,
@ObjectModel.readOnly: true
@ObjectModel.mandatory: true
pb_owner,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_first_name,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_last_name,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_email_id,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_created_at,
@ObjectModel.readOnly: 'EXTERNAL_CALCULATION'
pb_changed_at,
@ObjectModel.association.type: [#TO_COMPOSITION_CHILD]
_itemData
}
<< Top
1. Design / Prototype
2. Create Dictionary Objects
3. Create Interface View (CDS)
4. Business Object Generation (CDS – Object Model
Annotations )
5. Generated Business Object
6. BOPF – Development
Determination
Validation
Action
Alternative Key
7. Test BOPF Object using BOBT
8. Access Control (CDS)
9. Consumption View (CDS)
10. OData Service Generation and Registration
11. Test OData Service using SAP Gateway Client
12. UI development
DCL Source
With the help of Core Data Services, we can also define and
generate DCL (Data Control Language) Source. It is used to
restrict access to data.
@AccessControl.authorizationCheck: #CHECK
Similarly, create access control for all the required views
with the required authorization.
<< Top
1. Design / Prototype
2. Create Dictionary Objects
3. Create Interface View (CDS)
4. Business Object Generation (CDS – Object Model
Annotations )
5. Generated Business Object
6. BOPF – Development
Determination
Validation
Action
Alternative Key
7. Test BOPF Object using BOBT
8. Access Control (CDS)
9. Consumption View (CDS)
10. OData Service Generation and Registration
11. Test OData Service using SAP Gateway Client
12. UI development
Note: You can create the Header and Item Node with then
implement the association with each other in each node. Later
you can code all the annotation as required.
Header Node
Highlights
VDM.viewType is Consumption
Mark the CDS view as consumption based
ObjectModel.transactionalProcessingDelegated is true
Specifies that Transactional Processing is
delegated to the associated transactional view
UI.presentationVariant
Set the features for List Page
UI.headerInfo
Update the info for entity
Like Plural Description will be displayed on the
list
Title and Type will be displayed on the navigation
to Object page
UI.facet
Collection of different UI elements, help to
design Object Page Header and Detail view
UI.lineitem
Set the entity attribute feature and behaviour in
Line Item
Search
Helps to mark default search and another search to
displayed as part of Standard Layout on List Page
For more detail refer the link at the bottom of this page
@AbapCatalog.sqlViewName : 'Z2812CHEADND'
@AbapCatalog.compiler.compareFilter : true
@AbapCatalog.preserveKey : true
@AccessControl.authorizationCheck : #CHECK
@AccessControl.personalData.blocking: #REQUIRED
@EndUserText.label : 'Phone Book Header
Consumption - Node View'
@VDM.viewType : #CONSUMPTION
@Search.searchable : true
@Metadata.allowExtensions : true
@ClientHandling: {
algorithm : #SESSION_VARIABLE,
type : #CLIENT_DEPENDENT
}
-- Header Info
@UI.headerInfo: {
typeName : 'Contact',
typeNamePlural : 'Contacts',
title.value : 'pb_id',
description.value : 'pb_full_name'
}
]
//headData
@UI.hidden: true
key pb_head_uuid,
-- Phone Book ID
@Search: {
defaultSearchElement: true,
ranking: #HIGH,
fuzzinessThreshold: 0.8
}
@UI.lineItem: [{position: 10}]
@UI.identification: [{position: 10}]
pb_id,
-- Owner
@UI.hidden: true
pb_owner,
-- First Name
@Search: {
ranking: #HIGH,
fuzzinessThreshold: 0.6
}
@UI.fieldGroup:[{
qualifier: 'nameInfo',
position: 10,
importance: #HIGH
},
{
qualifier: 'contactInfo',
groupLabel: 'i18n>contactInfo',
position: 10,
importance: #HIGH
}]
pb_first_name,
-- Last Name
@Search: {
ranking: #HIGH,
fuzzinessThreshold: 0.6
}
@UI.fieldGroup:[{
qualifier: 'nameInfo',
position: 20,
importance: #HIGH
},
{
qualifier: 'contactInfo',
position: 20,
importance: #HIGH
}]
pb_last_name,
-- Full Name
@UI.lineItem: [{label: '{i18n>fullName}',
position: 20}]
@ObjectModel.readOnly: true
pb_full_name,
-- E-Mail ID
@UI.fieldGroup:[
{
qualifier: 'contactInfo',
position: 30,
importance: #HIGH
}]
@UI.dataPoint.targetValueElement: 'pb_email_id'
@UI.lineItem: [{position: 30}]
pb_email_id,
-- Creation Timestamp
@ObjectModel.readOnly: true
@Semantics.systemDateTime.createdAt: true
@UI.lineItem: [{position: 40}]
@UI.fieldGroup:[{
qualifier: 'adminInfo',
groupLabel: 'i18n>adminInfo',
position: 10,
importance: #HIGH
}]
pb_created_at,
-- Change Timestamp
@ObjectModel.readOnly: true
@Semantics.systemDateTime.lastChangedAt: true
@UI.lineItem: [{position: 50}]
@UI.fieldGroup:[{
qualifier: 'adminInfo',
position: 20,
importance: #HIGH
}]
pb_changed_at,
/* Associations */
//Item Data
@ObjectModel.association.type: #TO_COMPOSITION_CHILD
_itemData
}
Item Node
@AbapCatalog.sqlViewName : 'Z2812CITEMND'
@AbapCatalog.compiler.compareFilter : true
@AbapCatalog.preserveKey : true
@AccessControl.authorizationCheck : #CHECK
@AccessControl.personalData.blocking: #REQUIRED
@VDM.viewType : #CONSUMPTION
@Metadata.allowExtensions : true
@EndUserText.label : 'Phone Book Item
Consumption - Node View'
@ClientHandling:{
algorithm : #SESSION_VARIABLE,
type : #CLIENT_DEPENDENT
}
@ObjectModel:{
createEnabled : true,
deleteEnabled : true,
updateEnabled : true,
transactionalProcessingDelegated : true,
usageType:{
sizeCategory : #L,
serviceQuality : #D,
dataClass : #TRANSACTIONAL
}
}
Important Links
<< Top
Output
Useful Links
*&------------------------------------------------------------
--------*
*& Report Z2812_CDS_DIRECT
*&------------------------------------------------------------
--------*
REPORT z2812_cds_direct.
START-OF-SELECTION.
TRY.
" Create 'ALV with IDA' for Core Data Services(CDS)
go_alv_ida = cl_salv_gui_table_ida=>create_for_cds_view(
iv_cds_view_name =
'Z2812_CUSTOMER_BOOKINGS'
).
CATCH cx_root INTO DATA(lo_root).
DATA(lv_text) = lo_root->get_text( ).
WRITE:/ lv_text.
LEAVE TO LIST-PROCESSING.
ENDTRY.
END-OF-SELECTION.
TRY.
" Activate Fullscreen modus (interface)
go_fullscreen = go_alv_ida->fullscreen( ).
CATCH cx_salv_ida_contract_violation INTO DATA(lo_error).
lv_text = lo_error->get_text( ).
WRITE:/ lv_text.
LEAVE TO LIST-PROCESSING.
ENDTRY.
Step 6 – Display
Output
Selection Screen
Execution result
Useful Links
Sample Code
*&------------------------------------------------------------
---------*
*& Report Z2812_CDS_RESTRICTION
*&------------------------------------------------------------
---------*
REPORT z2812_cds_restriction.
DATA: gv_sdate TYPE sbook-order_date.
START-OF-SELECTION.
TRY.
" Create 'ALV with IDA' for Core Data Services(CDS)
go_alv_ida = cl_salv_gui_table_ida=>create_for_cds_view(
iv_cds_view_name =
'Z2812_CUSTBOOK_PARAMETER'
).
END-OF-SELECTION.
TRY.
" Activate Fullscreen modus (interface)
go_fullscreen = go_alv_ida->fullscreen( ).
CATCH cx_salv_ida_contract_violation INTO DATA(lo_error).
lv_text = lo_error->get_text( ).
WRITE:/ lv_text.
LEAVE TO LIST-PROCESSING.
ENDTRY.
Interfaces
1. IF_SALV_GUI_TABLE_IDA
ALV with integrated data access (ALV with IDA)
2. IF_SALV_GUI_FULLSCREEN_IDA
IDA ALV: Fullscreen API
3. IF_SALV_GUI_MODEL_IDA_API
Model API: Select Options, Authorization, Layout
etc
4. IF_SALV_GUI_TABLE_DISPLAY_OPT
IDA ALV: Table Display Options API
5. IF_SALV_GUI_TOOLBAR_IDA
IDA API Toolbar Manipulation Object
6. IF_SALV_GUI_TYPES_IDA
ALV IDA API : Public data types
7. IF_SALV_SERVICE_TYPES
Common types for ALV Service Tools
1. CL_SALV_GUI_TABLE_IDA
ALV with integrated data access (IDA): Factory
1. CREATE_FOR_CDS_VIEW
Create ‘ALV with IDA’ for Core Data
Services(CDS)
2. CL_SALV_GUI_GRID_CONTROLER_IDA
ALV IDA Controler for SAP GUI ALV
1. IF_SALV_GUI_TABLE_IDA~FULLSCREEN
Activate Fullscreen modus (interface)
2. IF_SALV_GUI_TABLE_IDA~SET_VIEW_PARAMETERS
Set values for placeholder variables
in the database view
3. IF_SALV_GUI_TABLE_IDA~SET_SELECT_OPTIONS
Set selections for database access
4. IF_SALV_GUI_TABLE_IDA~DISPLAY_OPTIONS
Handling of Display Options
(interface)
5. IF_SALV_GUI_TABLE_IDA~TOOLBAR
Change ALV toolbar (interface)
6. IF_SALV_GUI_TABLE_IDA~REFRESH
New query run, selected rows deleted,
Scroll to first row
3. CL_SALV_RANGE_TAB_COLLECTOR
Class for collecting range tables for multiple
fields
1. ADD_RANGES_FOR_NAME
Add ranges for Field or Column Name
2. GET_COLLECTED_RANGES
Get all of the collected ranges
4. CL_SALV_GUI_GRID_MODEL_IDA
ALV IDA Adapter for SAP GUI ALV
Useful Links