0% found this document useful (0 votes)
317 views

16 CDS Table Function and Analytic Query

This document contains definitions for several ABAP CDS views and table functions. It defines views for invoices, invoice items, and products that join various tables. It also defines an analytic consumption view for invoices that can be used for reporting. Additionally, it contains a definition for a table function implemented via SQLScript that is used to join tables from different systems.

Uploaded by

rameshnaidu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
317 views

16 CDS Table Function and Analytic Query

This document contains definitions for several ABAP CDS views and table functions. It defines views for invoices, invoice items, and products that join various tables. It also defines an analytic consumption view for invoices that can be used for reporting. Additionally, it contains a definition for a table function implemented via SQLScript that is used to join tables from different systems.

Uploaded by

rameshnaidu
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

@AbapCatalog.

sqlViewName: 'ZIJANINVOICESF'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Invoices Interface Basic Facts'

@VDM.viewType: #BASIC
@Analytics.dataCategory: #FACT
@Analytics.dataExtraction.enabled: true
@ObjectModel.representativeKey: 'NodeKey'
define view ZI_JAN_INVOICES as select from snwd_so_inv_item as Items
association[1] to ZI_JAN_PRODUCT as _Product on
$projection.ProductId = _Product.NodeKey
association[1] to ZI_JAN_INVHEADER as _Header on
$projection.ParentKey = _Header.NodeKey
{
key node_key as NodeKey,
parent_key as ParentKey,
gross_amount as GrossAmount,
tax_amount as TaxAmount,
currency_code as CurrencyCode,
product_guid as ProductId,
_Product,
_Header
}

@AbapCatalog.sqlViewName: 'ZICOINVOICE'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Composite View, Interface for Invoice'
@VDM.viewType: #COMPOSITE
@Analytics.dataExtraction.enabled: true
@Analytics.dataCategory: #CUBE
define view ZI_JAN_INVOICE_CO
with parameters
@Consumption.hidden: true
@Environment.systemField: #SYSTEM_LANGUAGE
p_lang : abap.lang
as select from ZI_JAN_INVOICES {
//ZI_JAN_INVOICES
key NodeKey,
key _Header._Buyer.CompanyName as Customer,
key _Product._productText[1:Language = $parameters.p_lang].ProductText as
Product,
key _Header._Buyer._Addresses.country as Country,
@Semantics.amount.currencyCode: 'CurrencyCode'
@DefaultAggregation: #SUM
GrossAmount,
@Semantics.amount.currencyCode: 'CurrencyCode'
@DefaultAggregation: #MAX
TaxAmount,
@Semantics.currencyCode: true
CurrencyCode

}
@AbapCatalog.sqlViewName: 'ZCJANINVANA'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Analytic Query, Consumption View'

@VDM.viewType: #CONSUMPTION
@Analytics.query: true
@OData.publish: true
define view ZC_JAN_INVOICE_ANALYTIC with parameters
@Environment.systemField: #SYSTEM_LANGUAGE
@Consumption.hidden: true
p_lang : abap.lang
as select from ZI_JAN_INVOICE_CO(
p_lang: $parameters.p_lang ) {
//ZI_JAN_INVOICE_CO
key NodeKey,
@AnalyticsDetails: { query.axis: #ROWS }
@Consumption.filter: { mandatory: false, selectionType: #INTERVAL }
key Customer,
key Product,
key Country,
@AnalyticsDetails:{query.axis: #COLUMNS}
@DefaultAggregation: #SUM
GrossAmount,
@AnalyticsDetails:{query.axis: #COLUMNS}
@DefaultAggregation: #MAX
TaxAmount,
@DefaultAggregation: #FORMULA
@AnalyticsDetails.query.axis: #COLUMNS
@EndUserText.label: 'Wallah'
GrossAmount - TaxAmount as SomeAmount,
@AnalyticsDetails: {query.axis: #COLUMNS}
@Consumption.filter: { mandatory: true, selectionType: #SINGLE }

CurrencyCode
}

@AbapCatalog.sqlViewName: 'ZCDSJANFAULT'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Showcase issue with cds'
define view ZCDS_JAN_FAULTY as select from crmd_partner as partner
association[1] to but000 as _Bp on $projection.partner_no = _Bp.partner_guid
{
//partner
key partner_guid as PartnerKey,
partner_fct,
partner_no,
_Bp.name1_text,
_Bp.partner_guid
}

@EndUserText.label: 'SQL Script code called by CDS View'


define table function ZCDS_JAN_TF_FAULTY
with parameters
@Environment.systemField: #CLIENT
p_clnt : abap.clnt
returns {
client : abap.clnt;
partner_no : crmt_partner_no;
partner_fct : crmt_partner_fct;
name1_text : bu_name1tx;
partner_guid : bu_partner_guid;

}
implemented by method zcl_jan_cds_tf=>get_erp_crm_partner;

CLASS zcl_jan_cds_tf DEFINITION


PUBLIC
FINAL
CREATE PUBLIC .

PUBLIC SECTION.
INTERFACES if_amdp_marker_hdb.
CLASS-METHODS : get_erp_crm_partner for table function ZCDS_JAN_TF_FAULTY.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.

CLASS zcl_jan_cds_tf IMPLEMENTATION.


METHOD get_erp_crm_partner by DATABASE FUNCTION FOR HDB LANGUAGE SQLSCRIPT
OPTIONS READ-ONLY
USING crmd_partner but000.

return select x.client, x.partner_no, x.partner_fct, y.name1_text,


y.partner_guid
from crmd_partner as x inner join but000 as y on
x.partner_no = y.partner_guid;

ENDMETHOD.

ENDCLASS.

You might also like