You are on page 1of 34

Application Development with

CDS + BOPF + ODATA + Fiori


Elements ( SAPUI5 )

Purpose

This blog will focus on End-to-End development of an


application using

1. CDS (Core Data Services)


Interface and Consumption View
BOPF Generation
2. BOPF (Business Object Processing Framework)
Business Processing Logic ( CRUD Operations )
3. OData (Open Data Protocol)
Exposure of Data
4. SAPUI5 / Fiori Elements
Front End Development

Requirement

Build a Phone Book Application which helps to manage contacts.


The initial version will support only basic features such as
Create, Edit, Delete and Copy contacts. It will list all
contacts in initial view with contact information such as
First & Last Name, E-Mail ID. When the user clicks on any
record then detail view will display all basic information
along with different telephone numbers for the selected
contact.

Step By Step Guide

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

Create Interface Views (CDS)


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

In this step, we will create basic views for our DB table.


These views can later be used by other CDS views or any DB
fetch.

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

Installing ABAP Development Tools for Eclipse


Work with Core Data Services
CDS Annotations
Header Interface View

@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
}

Item Interface View

@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
}

Category Interface View

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
}

Value Help View

@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

First, Item Transactional View was created without any


association to header view/node, then Header Transactional
View was created with an association to the item view/node.
Later, the Association to header was updated in the item view.
Item Transactional View

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

-- Business Object Model - Item Data


@ObjectModel:{
writeActivePersistence: 'Z2812_PB_D_ITEM',
draftEnabled: true,
writeDraftPersistence: 'Z2812_PB_D_ITM_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
@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
}

Header Transactional View

Object Model Annotations used in View will auto generate


Business Object and dependent node such as message, Lock and

@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
}

For more detail on Object Model Annotations, please refer to


SAP Help.

<< Top

Access Control (CDS)

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.

Create an Access Control object ‘Z2812_I_PB_HEAD‘ (I practice


to create the access control with the same name as the DDL
Source. It helps to easily identify the CDS View used inside
the access control).
@EndUserText.label: 'Mapping Role - Z2812_I_PB_HEAD'
@MappingRole: true
define role Z2812_I_Pb_Head {
grant
select
on
-- CDS View
Z2812_I_PB_HEAD
where
-- Authorization Object
( ) = aspect pfcg_auth( Z2812_AUTH,
ACTVT = '03' );
}

No CDS element is specified in the above example. CDS access


control prevents data from being read in full if the current
user does not have at least an authorization for the
authorization object with the activity “03”. You can also
restrict data with control over specific fields, refer below
link for more details.
Read More about PFCG_AUTH

The below control statement used in CDS View triggers the


check using using access control.

@AccessControl.authorizationCheck: #CHECK
Similarly, create access control for all the required views
with the required authorization.

<< Top

Consumption View (CDS)

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

In order to consume CDS in OData Services and User Interface


development, we have to create a consumption-based CDS view on
top or Basic or Interface view.

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
}

-- Business Object Model


@ObjectModel:{
compositionRoot : true,
transactionalProcessingDelegated : true,
createEnabled : true,
updateEnabled : true,
deleteEnabled : true,
draftEnabled : true,
semanticKey : ['pb_head_uuid'],
usageType: {
serviceQuality : #D,
sizeCategory : #L,
dataClass : #TRANSACTIONAL
}
}

-- Presentation Variant for UI


@UI.presentationVariant: [{
sortOrder: [{
by : 'pb_id',
direction : #DESC
}],
groupBy : ['pb_id'],
requestAtLeast : ['pb_id', 'pb_owner',
'pb_first_name',
'pb_last_name', 'pb_full_name',
'pb_email_id',
'pb_created_at','pb_changed_at']
}]

-- Header Info
@UI.headerInfo: {
typeName : 'Contact',
typeNamePlural : 'Contacts',
title.value : 'pb_id',
description.value : 'pb_full_name'
}

define view Z2812_C_PB_HEAD_ND as select from


Z2812_I_PB_HEAD_ND as headData
-- Associtaion to Item Data
association[0..*] to Z2812_C_PB_ITEM_ND as _itemData on
$projection.pb_head_uuid = _itemData.pb_head_uuid
{

-- Header & Item Facets


@UI.facet: [
-- Header Presentation on Object Page
{
purpose: #HEADER,
position: 10,
importance: #HIGH ,
type: #FIELDGROUP_REFERENCE,
targetQualifier: 'nameInfo'
},
{
purpose: #HEADER,
position: 20,
importance: #HIGH ,
type: #DATAPOINT_REFERENCE,
targetQualifier: 'pb_email_id'
},
-- Detail Presentation of Object Page
{
purpose: #STANDARD,
id: 'DetailInformation',
importance: #HIGH,
type: #COLLECTION,
position: 10
},
{
purpose: #STANDARD,
label:'i18n>generalInfo',
importance: #HIGH,
type: #IDENTIFICATION_REFERENCE,
parentId: 'DetailInformation',
position: 10,
targetQualifier: 'generalInfo'
},
{
purpose: #STANDARD,
label:'i18n>contactInfo',
importance: #HIGH,
type: #FIELDGROUP_REFERENCE,
parentId: 'DetailInformation',
position: 20,
targetQualifier: 'contactInfo'
},
{
purpose: #STANDARD,
label:'i18n>adminInfo',
importance: #HIGH,
type: #FIELDGROUP_REFERENCE,
parentId: 'DetailInformation',
position: 30,
targetQualifier: 'adminInfo'
}

]
//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
}
}

define view Z2812_C_PB_ITEM_ND as select from


Z2812_I_PB_ITEM_ND as itemData
-- Category Description
association[0..1] to Z2812_I_PB_CATG_TXT as _categoryText on
$projection.pb_category = _categoryText.pb_category
and
$projection.pb_category_desc = _categoryText.pb_category_desc
-- Association to Header
association [1..1] to Z2812_C_PB_HEAD_ND as _headData on
$projection.pb_head_uuid = _headData.pb_head_uuid
{
//item
@UI.hidden: true
key pb_item_uuid,
@UI.hidden: true
pb_head_uuid,
@UI.lineItem.position: 10
@UI.textArrangement: #TEXT_FIRST
@Consumption.valueHelp: '_categoryText'
@ObjectModel.text.element: ['pb_category_desc']
@Semantics.text: true
pb_category,
@UI.hidden: true
pb_category_desc,
@UI.lineItem.position: 20
@Semantics.telephone.type: [#CELL]
pb_telephone,
@UI.lineItem.position: 30
@Semantics.systemDateTime.createdAt: true
@ObjectModel.readOnly: true
pb_created_at,
@UI.lineItem.position: 40
@Semantics.systemDate.lastChangedAt: true
@ObjectModel.readOnly: true
pb_changed_at,
/* Associations */
//header
@ObjectModel.association.type: [#TO_COMPOSITION_ROOT,
#TO_COMPOSITION_PARENT]
_headData,
@Consumption.filter.hidden: true
_categoryText
}

Important Links

Get Started with SAP S/4 HANA Core Data Services


CDS Annottaions (UI, Object Model, Search etc)

<< Top

Display CDS View data via ALV


IDA – Part 1

Directly Display CDS DATA

Step 1 – Data Declarations

Step 2 – Create ALV IDA for CDS View


Step 3 – Get Reference of Full-screen API

Step 4 – Display Data

Output

Useful Links

Part 2: Display CDS Data with restrictions


ALV IDA – Important Interfaces, Classes, Methods
Sample Code

*&------------------------------------------------------------
--------*
*& Report Z2812_CDS_DIRECT
*&------------------------------------------------------------
--------*
REPORT z2812_cds_direct.

DATA: go_alv_ida TYPE REF TO if_salv_gui_table_ida,


go_fullscreen TYPE REF TO if_salv_gui_fullscreen_ida.

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.

" Display Data


go_fullscreen->display( ).
Display CDS View data via ALV
IDA – Part 2

Display CDS Data with restrictions

Step – 1 Data Declarations and Selection Screen

Step 2 – Create ALV IDA for CDS View

Step 3 – Create IDA Ranges for Select Options and


Selection Parameters
Step 4 – Set CDS View Parameters

Step 5 – Get Reference of Full-screen API

Step 6 – Display
Output

Selection Screen

Execution result

Displaying ALV IDA in Custom Container

Refer Demo Program SALV_IDA_DISPLAY_DATA by SAP

ALV IDA Display Options, Event Handling

Refer Demo Programs by SAP


– SALV_IDA_DISPLAY_OPTIONS
– SALV_IDA_DISPLAY_OPTIONS_FS

Useful Links

Part 1: Directly Display CDS Data


ALV IDA – Important Interfaces, Classes, Methods

Sample Code

*&------------------------------------------------------------
---------*
*& Report Z2812_CDS_RESTRICTION
*&------------------------------------------------------------
---------*
REPORT z2812_cds_restriction.
DATA: gv_sdate TYPE sbook-order_date.

PARAMETERS: p_aircod TYPE sbook-carrid,


p_fldat TYPE sbook-fldate,
p_connid TYPE sbook-connid.

SELECT-OPTIONS: s_bdate FOR gv_sdate.

DATA: go_alv_ida TYPE REF TO if_salv_gui_table_ida,


go_fullscreen TYPE REF TO if_salv_gui_fullscreen_ida,
go_range TYPE REF TO cl_salv_range_tab_collector,
gr_connid TYPE RANGE OF sbook-connid.

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'
).

" Create Instance of Range Collector


go_range = NEW #( ).

" Add Ranges for Field( Booking Date - Select-Optiion )


go_range->add_ranges_for_name(
EXPORTING
iv_name = 'ORDER_DATE'
it_ranges = s_bdate[] ).

" Add Ranges for Field( Connection ID - Slection


Parameter )
gr_connid = VALUE #( ( sign = 'I' option = 'EQ' low =
p_connid ) ).
go_range->add_ranges_for_name(
EXPORTING
iv_name = 'CONNID'
it_ranges = gr_connid[]
).
" Get All Ranges
go_range->get_collected_ranges(
IMPORTING
et_named_ranges = DATA(lt_named_ranges) ).

" Set Select Options for IDA


go_alv_ida->set_select_options(
EXPORTING
it_ranges = lt_named_ranges
).

" Set View Parameters ( Defined in CDS View )


go_alv_ida->set_view_parameters(
it_parameters = VALUE #(
( name = 'P_CARRID' value =
p_aircod )
( name = 'P_FLIGHTBEFOREDATE' value
= p_fldat )
)
).
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.

" Display Data


go_fullscreen->display( ).

ALV IDA (Integrated Data


Access) – Important
Interfaces, Classes, Methods

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

Classes & Methods

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

Directly Display CDS Data


Display CDS Data with restrictions

You might also like