Sei sulla pagina 1di 3

-----------------------------------------------------------------------------------

---------
-----------------------------------------------------------------------------------
---------
-----------------------------------------------------------------------------------
---------
Example CDS views
Scenario : Fiori element
Created by : Anubhav Oberoy (http://www.onlinefioritrainings.com)
Pre-requisite: SAP NW 7.4
Data Model: EPM Data model for demo scenario, Run tcode SEPM_DG to generate data in
demo tables
Dev Tools: Eclipse with ADT and SAP Web IDE Full Stack
-----------------------------------------------------------------------------------
---------
-----------------------------------------------------------------------------------
---------
-----------------------------------------------------------------------------------
---------

@AbapCatalog.sqlViewName: 'ZCDS_I_BUPA_V'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Business Partnerts for EPM'
@VDM: {
viewType: #BASIC
}
@Analytics: {
dataCategory: #DIMENSION,
dataExtraction: { enabled: true }
}
@ObjectModel: {
representativeKey: 'node_key'
}
define view ZCDS_I_BUPA as select from snwd_bpa
association[1] to snwd_ad as _Addresses on $projection.address_guid =
_Addresses.node_key
{
key node_key,
bp_role,
address_guid,
bp_id,
company_name,
_Addresses
}

-----------------------------------------------------------------------------------
---------
@AbapCatalog.sqlViewName: 'ZCDS_I_PROD_TEXT'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Product Texts'
@Analytics:{
dataExtraction: {
enabled: true
}
}
@VDM: {
viewType: #BASIC
}
define view ZCDS_I_PROD_TEXTS as select from snwd_texts {
key node_key,
parent_key as ProductId,
language,
@EndUserText: {
label: 'Product Name'
}
text
}

-----------------------------------------------------------------------------------
---------
@AbapCatalog.sqlViewName: 'ZCDS_I_PROD'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'CDS view for Master Data, Basic, Interface View'

@VDM:{
viewType: #BASIC
}
@ObjectModel: {
representativeKey: 'NodeKey'
}

@Analytics.dataCategory: #DIMENSION
@Analytics.dataExtraction.enabled: true

define view ZCDS_I_PRODUCTS as select from snwd_pd


association[1..*] to ZCDS_I_PROD_TEXTS as _ProductTexts on
$projection.desc_guid = _ProductTexts.ProductId
{
key node_key as NodeKey,
product_id as ProductId,
category as Category,
desc_guid,
_ProductTexts
}

-----------------------------------------------------------------------------------
---------
@AbapCatalog.sqlViewName: 'ZCDSCOSHDR'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Header view'
define view ZCDS_CO_SALES_HDR as select from snwd_so
association[1] to ZCDS_I_BUPA as _Customers
on $projection.buyer_guid = _Customers.node_key
{
key node_key,
so_id,
buyer_guid,
currency_code,
gross_amount,
overall_status,
case overall_status
when 'P' then 'Paid'
when 'D' then 'Delivered'
when 'N' then 'New'
end as OrderStatus,
/* Associations */
//ZCDS_I_BUPA
_Customers.company_name,
_Customers.bp_id,
_Customers._Addresses.country
}

-----------------------------------------------------------------------------------
---------
@AbapCatalog.sqlViewName: 'ZCDSSOANUBHAV'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Anubhav''s Sales Order CDS for Fiori Elements'
@VDM.viewType: #CONSUMPTION
@OData.publish: true

define view ZCDS_SO_ANUBHAV as select from snwd_so_i as item


association [1] to ZCDS_I_PRODUCTS as _Products
on $projection.product_guid = _Products.NodeKey
association[1] to ZCDS_CO_SALES_HDR as _Header
on $projection.parent_key = _Header.node_key

{
key _Header.node_key as HeaderId,
key node_key as ItemKey,
parent_key,
item.so_item_pos as ItemPos,
@Semantics: {amount.currencyCode: 'CurrencyCode'}
@DefaultAggregation: #SUM
gross_amount as GrossAmount,
@Semantics: {currencyCode: true}
currency_code as CurrencyCode,
product_guid,
/* Associations */
//ZCDS_I_PRODUCTS
_Products._ProductTexts[1:language = 'E'].text as ProdText,
_Products.Category,
_Header.node_key,
_Header.so_id,
_Header.buyer_guid,
_Header.currency_code,
_Header.gross_amount,
_Header.overall_status,
_Header.OrderStatus,
_Header.company_name,
_Header.bp_id,
_Header.country

-----------------------------------------------------------------------------------
---------

Potrebbero piacerti anche