0% found this document useful (0 votes)
213 views5 pages

Analytical CDS Queries

The document defines several ABAP CDS views and a table function for integrating data from different systems. The views include: 1) ZOFT_I_BUPA - Basic view for business partners integrating data from SNWD_BPA and SNWD_AD tables. 2) ZOFT_I_PROD_TEXT - Basic view for product text data from SNWD_TEXTS table. 3) ZOFT_I_PRODUCT - Basic view for product dimension data integrating SNWD_PD, ZOFT_I_PROD_TEXT and ZOFT_I_BUPA views. 4) ZOFT_I_SALES - Basic

Uploaded by

Saimurali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
213 views5 pages

Analytical CDS Queries

The document defines several ABAP CDS views and a table function for integrating data from different systems. The views include: 1) ZOFT_I_BUPA - Basic view for business partners integrating data from SNWD_BPA and SNWD_AD tables. 2) ZOFT_I_PROD_TEXT - Basic view for product text data from SNWD_TEXTS table. 3) ZOFT_I_PRODUCT - Basic view for product dimension data integrating SNWD_PD, ZOFT_I_PROD_TEXT and ZOFT_I_BUPA views. 4) ZOFT_I_SALES - Basic

Uploaded by

Saimurali
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

@AbapCatalog.

sqlViewName: 'ZI_BUPA'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Bussiness Partner, Interface View, Basic'
@VDM.viewType: #BASIC
@Analytics: { dataCategory: #DIMENSION,
dataExtraction.enabled: true }
define view ZOFT_I_BUPA as select from snwd_bpa as bp
association[0..1] to snwd_ad as _Address on $projection.AddressGuid =
_Address.node_key {
key node_key as AddressKey,
address_guid as AddressGuid,
bp_id as BpId,
company_name as CompanyName,
_Address
}

@AbapCatalog.sqlViewName: 'ZOFT_PROD_TXT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Interface View, basic view, Dimension data'

@ObjectModel:{ dataCategory: #TEXT, semanticKey: ['TextId'] }


@VDM.viewType: #BASIC
@Analytics.dataExtraction.enabled: true

define view ZOFT_I_PROD_TEXT as select from snwd_texts {


//snwd_texts
key node_key as TextId,
parent_key as ProductGuid,
language,
text
}

@AbapCatalog.sqlViewName: 'ZOFT_PRODS'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Interface View, Dimension Data, Products'

@VDM.viewType: #BASIC --1. View type for VDM in S4HANA


@Analytics:{ dataCategory: #DIMENSION, dataExtraction:{enabled: true} } --2. Used
by analytical tool
@ObjectModel: {representativeKey: 'ProductId'} --3. key for the view data

define view ZOFT_I_PRODUCT as select from snwd_pd


association[1] to ZOFT_I_PROD_TEXT as _Texts on $projection.desc_guid =
_Texts.ProductGuid --on demand join with text and supplier
association[1] to ZOFT_I_BUPA as _Supplier on $projection.supplier_guid =
_Supplier.AddressKey {
key node_key as ProductId,
product_id as ProductNo,
category,
desc_guid,
supplier_guid,
_Texts,
_Supplier
}

@AbapCatalog.sqlViewName: 'ZOFT_SALES'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Interface View, Facts, Sales Data'

@VDM.viewType: #BASIC
@Analytics:{ dataCategory: #CUBE, dataExtraction:{enabled: true}}
@ObjectModel:{representativeKey: 'ItemKey'}

define view ZOFT_I_SALES as select from snwd_so_i as items


association[1] to ZOFT_I_PRODUCT as _Product on $projection.ProductId =
_Product.ProductId
association[1] to snwd_so as _Header on $projection.parent_key = _Header.node_key{
key node_key as ItemKey,
parent_key as OrderGuid,
product_guid as ProductId,
@Semantics.currencyCode: true
currency_code as Currency,
@Semantics.amount.currencyCode: 'Currency'
@DefaultAggregation: #SUM
gross_amount as GrossAmount,
net_amount as NetAmount,
@DefaultAggregation: #SUM
@Semantics.amount.currencyCode: 'Currency'
tax_amount as TaxAmount,
_Product

@AbapCatalog.sqlViewName: 'ZOFTC_SALES'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Data Analytics'
@VDM.viewType: #COMPOSITE
@Analytics.dataCategory: #CUBE
define view ZOFT_C_SALES_DATA as select from ZOFT_I_SALES {
//ZOFT_I_SALES
key ItemKey,
key OrderGuid,
key ProductId,
key _Product.category as Category,
key _Product._Texts.text as ProductName,
key _Product._Supplier.CompanyName as Supplier,
@Semantics.currencyCode: true

Currency,
@Semantics.amount.currencyCode: 'Currency'
@DefaultAggregation: #SUM
GrossAmount,
@Semantics.amount.currencyCode: 'Currency'
@DefaultAggregation: #MAX
NetAmount

/* Associations */
//ZOFT_I_SALES

@AbapCatalog.sqlViewName: 'ZOFTC_SQUERY'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Sales Analytical Query'

@VDM.viewType: #CONSUMPTION
@Analytics.query: true

define view ZOFT_C_SALES_QUERY as select from ZOFT_C_SALES_DATA {


//ZOFT_C_SALES_DATA
key ItemKey,
key OrderGuid,
key ProductId,
key Category,
@EndUserText.label: 'Anubhav'
key ProductName,
@AnalyticsDetails.query.axis: #ROWS
key Supplier,
@AnalyticsDetails.query.axis: #ROWS
Currency,
@AnalyticsDetails.query.axis: #COLUMNS
GrossAmount,
@AnalyticsDetails.query.axis: #COLUMNS
NetAmount
}

@AbapCatalog.sqlViewName: 'ZCDSISSUE'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Limitation with CDS'
define view ZCDS_ISSUE as select from crmd_partner
association[1] to but000 as _Bupa on $projection.partner_no = _Bupa.partner_guid
{
//crmd_partner
key client,
key partner_guid,
guid,
compressed,
attributes,
kind_of_entry,
cust_attr_db,
cust_rel_db,
partner_fct,
partner_no,
display_type,
no_type,
mainpartner,
relation_partner,
addr_nr,
addr_np,
addr_type,
addr_origin,
std_bp_address,
addr_operation,
calendar,
disabled,
error_flag,
partner_src_sys,
partner_dummy,
comp_prd_db
}

@EndUserText.label: 'Demo CDS table function'


define table function ZOFT_CDS_TAB_FUNC
with parameters
@Environment.systemField: #CLIENT
p_clnt : abap.clnt
returns {
client : abap.clnt;
PARTNER_NO : crmt_partner_no;
PARTNER_FCT: crmt_partner_fct;
NO_TYPE: crmt_partner_no_type;
PARTNER_GUID: bu_partner_guid;
ADDRCOMM: bu_addrcomm;
VALID_TO: bu_bp_valid_to;
}
implemented by method zcl_oft_cds_table_function=>get_partner_crm_erp;

CLASS zcl_oft_cds_table_function DEFINITION


PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
INTERFACEs if_amdp_marker_hdb.
class-methods : get_partner_crm_erp for table function ZOFT_CDS_TAB_FUNC.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_oft_cds_table_function IMPLEMENTATION.

method get_partner_crm_erp by DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT


OPTIONS READ-ONLY
using but000 crmd_partner.
return select a.client, a.PARTNER_NO, a.PARTNER_FCT, a.NO_TYPE,
b.PARTNER_GUID, b.ADDRCOMM, b.VALID_TO
from crmd_partner as a inner join but000 as b on
a.partner_no = b.partner_guid
where a.client = :p_clnt;
endmethod.
ENDCLASS.

You might also like