SAP FIORI PREDeFINED - Standard Fiori Apps Custom CDS View Using Predefined Virtual Data Model
SAP FIORI PREDeFINED - Standard Fiori Apps Custom CDS View Using Predefined Virtual Data Model
The example Consumption View in this blog is Analytic Query supposed to be used in Fiori
Multidimensional Reporting, SAC and BusinessObjects, but predefined VDM and custom CDS
View can be used for OData based Fiori app, ABAP program, data source to BW, etc.
But before considering Extend View, please check if the fields can be extended with Custom
Fields and Logic, which could add fields with graphical Fiori app.
2020/9/19 added:
It would take long time, e.g. 2 hours, to activate Extend VIew for the CDS View which is used
in many other view. In the case, firstly, it is expected to check if extension would be possible
with Custom Fields and Logic as explained later. Even if it is not possible, then it might be
better to create another new custom CDS view to add the fields. e.g. I have added a custom
field in EKKO (Purchase doc header table) and want to add it in the custom CDS view using
I_PurchaseOrder as a source. In the case, instead of creating Extend View for
I_PurchaseOrder, Join EKKO again in the Custom CDS VIew. In the case, the activation time
for the custom CDS view should be much shorter, and in the case, the join of EKKO would
not happen twice as internally select statement is optimized. (Self-join-optimization). (Use
the same definition for @ClientHandling.algorithm to make it work.).
This blog should help how to deal with long activation time.
2020/9/27
Use metadata data extension for the VDM which includes @Metadata.allowExtensions:true
to change UI, Consumption, EndUserText annotations.
2021/2/6
2023/5/16
By adding the following annotation, activation time can be shortened as checks are skipped,
but it is not officially supported. For test purpose, it could be used.
Le VDM prédéfini est l'une des clés de l'architecture S/4HANA, bien qu'il ne soit pas souligné
comme l'objet en dessous, mais à ma connaissance, peu de clients l'apprécient. Je pense que
l'une des principales raisons devrait être que la façon d'utiliser Predefined VDM n'est peut-
être pas claire pour eux, et certains penseraient que c'est inutile car ils ont des champs
personnalisés dans la table ou veulent ajouter le champ d'une autre table mais ce serait
impossible d'ajouter un champ à Predefined VDM. Pour surmonter ces problèmes, je fournis
l'exemple de code pour utiliser Predefined VDM, y compris Extend View avec lequel des
champs peuvent être ajoutés à Predefined VDM standard.
Target audience:
This blog is for the ones who want to create report and analytical apps. It is not only for
analytics experts but for all functional experts as it is expected to create report based on
CDS View, instead of traditional functions like ALV or Report Painter, which has been used by
functional experts. See SAP Note 2579584 and 2349297.
It is also for developers as CDS View can be used not only for analytical apps, but it can be
used in normal ABAP program.
Summary:
• Concrete samples of the predefined VDMs are explained to understand what exactly
the predefined VDM is.
• Samples of custom CDS View using predefined VDMs and Extend View to add fields
to predefined VDM are provided, as the best way to understand is to see the source.
The predefined VDM of Billing Document Item is associated to Sales Order Item in
the sample.
o In the sample Extend View, a CDS Wiew is associated, and a field is added
from the view.
o Considerations to use Extend View and limitations are included.
o In the sample of Consumption View, some advanced settings are included
(hoping it would help creating sophisticated Analytic Query, although it is not
the main topic of this blog).
▪ Add value help to a parameter using association.
▪ Set start/end date as consumption filtering value automatically using
lookup entry used in Date Function.
▪ Exception aggregations are used to avoid value duplication when
joining sales order and billing document.
• How to deal with “Not released” predefined VDM is argued. “Not released” VDM is
subject to change after version up of the system. But in my personal view, it should
be better to use it than creating custom CDS Views for all business entities.
Predefined VDM is the predefined CDS Views for business entities or for applications in
S/4HANA. There are mainly 3 types of predefined VDM in S/4HANA.
• Consumption View: The view consumed by application (Tech name: C_*). e.g.
Journal Entry Analyzer (C_GLLINEITEMSQ0001). It is created from Interface View in
general.
• Interface View: The view is the foundation of Consumption View (Tech name: I_*).
Interface View for business entities in S/4HANA is called Basic View, e.g. GL Account
Line Item (I_GLAccountLineItem), Profit Center (I_ProfitCenter). Interface view
created from Basic View is called Composite View, e.g. G/L Account Balance Cube
(I_GLAcctBalanceCube).
• Private View: The view used as a part to create Interface View or Consumption View
(Tech name: P_*). It is not mandatory to create.
See the document linked in this blog in detail about CDS View and VDM.
(In BW context, Consumption View is like BW Query and Interface View is like InfoProvider
or InfoObject.)
You can find the predefined VDMs in S/4HANA with Fiori View Browser.
Extend View:
Extend View is used to add fields to predefined VDM without changing predefined VDM
itself. It is possible to associate the view and add it in the source view, and it is also possible
to use the association for foreign key association on the added field. It is like APPEND for
table in ABAP Dictionary. See SAP Help , Wiki or blog in detail.
Enhancement by Extend View is in a sense like modification, so would cause the following
issues when upgrading the system.
• Conflict of the field name: conflict of the field name would happen if new fields are
added on the predefined VDM in the newer version but the field names has already
been used in the Extend View, e.g. Segment is added with Extend View to the source
predefined VDM, but in the newer version of the predefined VDM, Segment is added
by default. To avoid it, it is recommended to rename the fields added with Extend
View with ZZ~.
• Field name change of the source view: fields in the source (select ~ from <Source>)
can be added using Extend View. But if the source view is unreleased (see below), the
field name might be changed (or the filed would be deleted) in the newer version. In
this case, it cannot be avoided to adjust the Extend View and relevant CDS Views.
For those reasons, it is recommended to add fields using Key User Extensibility Tools
“Custom Fields and Logic” to add fields as much as possible.
• [ min .. *] cannot be used in Extend View. See the blog for [min..*] association.
• The field of the association cannot be added when path expression is used in ON
condition of the association, _FiscalYearCalenderDate.FiscalYear cannot be added
when _FiscalYearCalenderDate is associated in the Extend View and
SDIA._ControllingArea.FiscalYearVariant is used in the ON condition.
• It is not possible to set annotation only to existing field.
o For doing that ANNOTATE VIEW is used. But it is available only for the
predefined VDM in which Metadata.allowExtensions is set to true.
@AbapCatalog.sqlViewAppendName: ‘ZESSOITMCB’
on $projection.ZZFiscalYearVariant = _FiscalYearVariant.FiscalYearVariant
@ObjectModel.foreignKey.association: ‘_FiscalYearVariant’
SDIA._ControllingArea.FiscalYearVariant as ZZFiscalYearVariant,
–expose
_FiscalYearVariant
Detail:
• Add fields from associated Views: FiscalYearVariant is added from I_ControllingArea
associated in the source I_SalesOrderItemCube, and master view I_FiscalYearVariant
is associated and it is set as the foreign key association on the added field
FiscalYearVariant.
• Renamed as ZZ~: All fields added in the Extend View are renamed to ZZ~. it is to
avoid the possible conflict of the name when upgrading the system. Now
I_SalesOrderItemCube doesn’t have the field FiscalYearVariant so it is possible to add
the field named “FiscalYearVariant” with Extend View. However, if the field
FiscalYearVariant is added in the next version of I_SalesOrderItemCube, the conflict
would happen.
• Field and foreign key association added from associated View: The field Segment is
added from I_ProfitCenter, and _Segment (_ProfitCenter. _ProfitCenter) is also
added from I_ProfitCenter, and is used in the foreign key association on the field.
Although I_Segment has already been used in the foreign key association in
I_ProfitCenter, foreign key association setting is necessary again in the Extend View
(Transaction Interface View).
• Not possible to use Path Expression for ON condition for the association: I tried to
associate _FiscalCalendarDate.FiscalYear but found it is not possible. It is because
_ControllingArea. FiscalYearVariant cannot be used for ON condition for association
to add fields from the associated view, although it is possible to add association only,
e.g. _FiscalCalendarDate.FiscalYear cannot be added, but _FiscalCalendarDate can be
added. For doing that, the only way is to add only association in Extend View and add
the field from the associated view in custom CDS View created from the source view
extended by Extend View.
@AbapCatalog.sqlViewName: ‘ZISALESBILL’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘SalesOrder+BillingDoc’
@Analytics.dataCategory: #CUBE
@VDM.viewType: #COMPOSITE
@ClientHandling.algorithm: #SESSION_VARIABLE
with parameters
P_ExchangeRateType : kurst,
P_DisplayCurrency : vdm_v_display_currency
on $projection.ControllingArea = _ProfitCenter.ControllingArea
on $projection.SalesOrder = _BillingDocumentItemBasic.SalesDocument
on $projection.ZZFiscalYearVariant = _FiscalCalendarDate.FiscalYearVariant
SalesOrder,
SalesOrderItem,
SalesOrderType,
SalesOrderDate,
SalesOrganization,
DistributionChannel,
OrganizationDivision,
ControllingArea,
SalesOrderDateYearMonth,
DisplayCurrency,
@ObjectModel.foreignKey.association: ‘_ProfitCenter’
ProfitCenter,
ZZFiscalYearVariant,
NetAmountInDisplayCurrency,
@ObjectModel.foreignKey.association: ‘_Segment’
_ProfitCenter.Segment,
_BillingDocumentItemBasic.BillingDocument,
_BillingDocumentItemBasic.BillingDocumentItem,
_FiscalCalendarDate.FiscalYear as ZZFiscalYear,
_FiscalCalendarDate.FiscalPeriod as ZZFiscalPeriod,
_FiscalCalendarDate.FiscalYearQuarter,
/* Associations */
//I_SalesOrderItemCube
_ControllingArea,
_DistributionChannel,
_FiscalYearVariant,
_OrganizationDivision,
_SalesOrder,
_SalesOrderType,
_SalesOrganization,
_ScheduleLine,
_ProfitCenter,
_ProfitCenter._Segment
Detail:
• Add fields from associated Views: In this Interface View, I_ProfitCenter are
associated and Segment are added from it, and this view is set as Foreign Key
association on ProfitCenter. BillingDocument and BillingDocumentItem are added
from associated I_BillingDocumentItemBasic, and FiscalYear, FiscalPeriod, and
FiscalQuarter are added from associated I_FiscalCalendarDate.
Most of them could be added with Extend View and it might be possible to go without
creating custom Interface View. However, it is created in this sample as it might be better to
avoid using Extend View too much because of the considerations and limitations as
mentioned above.
@AbapCatalog.sqlViewName: ‘ZCSALES’
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: ‘Sample Sales’
@Analytics.query: true
with parameters
@AnalyticsDetails.query.variableSequence: 20
@Consumption.defaultValue: ‘EUR’
P_DisplayCurrency : vdm_v_display_currency,
@AnalyticsDetails.query.variableSequence: 30
P_ExchangeRateType : kurst,
@Consumption.hidden: true
@Environment.systemField: #SYSTEM_DATE
P_KeyDate : sydate
SalesOrder,
SalesOrderItem,
@AnalyticsDetails.query.totals: #SHOW
SalesOrderType,
@AnalyticsDetails.query.variableSequence : 10
@Consumption: {
derivation: {
lookupEntity: ‘C_SglGregorianCalDateFunction’,
resultElementHigh: ‘DateFunctionEndDate’ }
SalesOrderDate,
@AnalyticsDetails.query.axis: #ROWS
@AnalyticsDetails.query.display: #TEXT
@AnalyticsDetails.query.totals: #SHOW
SalesOrganization,
@AnalyticsDetails.query.display: #TEXT
@AnalyticsDetails.query.totals: #SHOW
DistributionChannel,
@AnalyticsDetails.query.display: #TEXT
@AnalyticsDetails.query.totals: #SHOW
OrganizationDivision,
@AnalyticsDetails.query.display: #TEXT
@AnalyticsDetails.query.totals: #SHOW
ControllingArea,
@AnalyticsDetails.query.axis: #COLUMNS
@AnalyticsDetails.query.totals: #SHOW
SalesOrderDateYearMonth,
DisplayCurrency,
ZZFiscalYearVariant,
BillingDocument,
BillingDocumentItem,
@AnalyticsDetails.query.axis: #ROWS
@AnalyticsDetails.query.display: #TEXT
@AnalyticsDetails.query.totals: #SHOW
ProfitCenter,
@AnalyticsDetails.query.display: #TEXT
@AnalyticsDetails.query.totals: #SHOW
Segment,
ZZFiscalYear,
ZZFiscalPeriod,
FiscalYearQuarter,
@Consumption.hidden: true
@DefaultAggregation: #FORMULA
@AnalyticsDetails: {
exceptionAggregationElements: [‘BillingDocument’,’BillingDocumentItem’]
}]
@AnalyticsDetails.query.formula : ‘NetAmountInDisplayCurrency’
1 as SalesOrderAmtTmp,
@AnalyticsDetails.query.axis: #COLUMNS
@EndUserText.label: ‘SalesOdrAmt_D’
@DefaultAggregation: #FORMULA
@AnalyticsDetails: {
exceptionAggregationElements: [‘SalesOrder’,’SalesOrderItem’]
}],query.decimals: 0
@AnalyticsDetails.query.formula : ‘$projection.SalesOrderAmtTmp’
1 as SalesOrderAmt
• Analytic Query: This Consumption View is Analytic Query, which works as the source
of Fiori Multidimensional Reporting. It can be used with SAC and BusinessObjects.
• Value help for the parameter: I_ExchangeRateType is associated practically without
on condition (dummy association) to use it for the value help for the parameter
P_ExchangeRateType. See the blog in detail.
• Derive start and end date automatically using lookup entry for Date Function: The
start and end date are derived automatically from C_SglGregorianCalDateFunction as
Lookup entry. C_SglGregorianCalDateFunction is the CDS View used in Date Function.
As YEARTODATE is set as Date Function parameter Value, when running the view on
8/19/2018, 1/1/2018 is derived as start date and 8/19/2018 as end date.
• Exception Aggregation to avoid value duplicate value: The record of
I_SalesOrderItemCube would be duplicated when JOIN happens as relationship
between I_SalesOrderItemCube and I_BillingDocumentItemBasic is 1 : N. To avoid it,
2 calculated measures including Exception Aggregation are created
(SalesOrderAmtTmp and SalesOrderAmt). In SalesOrderAmtTmp, ZBillingDocument
and ZBillingDocumentItem are used as Exception Aggregation Element, and
Aggregation is set to MAX, so the aggregation of ZBillingDocument and
ZBillingDocumentItem is MAX, not SUM. In SalesOrderAmt, ZSalesOrder and
ZSalesOrderItem are used as Exception Aggregation Element, and Aggregation is set
to SUM, SalesOrderAmtTmp is aggregated with SUM. (For this reason, [0..*] in the
association to I_BillingDocumentItemBasic in Interface View (Extend View) is no
problem in this case).
When drilled down with Billing Document, SalesOdrAmt_D for Sales Order 388 is displayed
twice.
Even when Billing Document is removed and records are aggregated, SalesOdrAmt_D for
Sales Order 388 is displayed as expected without duplication.
As high granular attributes ZBillingDocument, ZBillingDocumentItem, and ZSalesOrder,
ZSalesOrderItem are used in Exception Aggregations, they have to be included in the select
list of internal SELECT statement. It would lead to longer runtime as larger amount of data
would have to be retrieved.
Hope you enjoy high productivity by using predefined VDM and Extend View!
Assigned Tags
• ABAP Development
• ABAP Extensibility
• SAP S/4HANA
• SAP S/4HANA Cloud, private edition
• SAP S/4HANA Embedded Analytics
• ABAP CDS view
• embedded analytics
•
•
•
•
•
23 Comments
You must be Logged on to comment or reply to a post.
vishwanath vedula
October 22, 2018 at 7:33 am
Great!
• Like 0
• Share
Joachim Rees
November 6, 2018 at 2:43 pm
Hi Masaaki,
While your blog didn't help me with my specific question (see below), it still was a good
read.
I want to extend C_SalesContractWl_F1851 and thus also have to extend the underlying
views
I_SalesContract
I_SalesDocument
I_SalesDocumentBasic
So I need to create a total of 4 extend views (one for each SAP CDS-View).
https://mastodon.technology/@Joachim_Rees/101024454603885620
Best
Joachim
• Like 0
• Share
Masaaki Arai
Blog Post Author
November 8, 2018 at 7:23 pm
Hello Joachim,
Interesting question.
If the field is new field in VBAK, I think you can add the field easily with Key User Tool,
Custom Fields and Logic.
If the field has already been there, one way it to add the field to all the views underneath.
In this case, you dont have to be concerned about the performance by joining large table
again, as internally self join optimization should happen, so it should be avoided to join VBAK
again internally.
But note that you have to avoid naming conflict to the fields added with Custom Fields and
Logic, e.g. if CFL uses ZZ1, you have to start the name of the field you add with ZY~.
Thanks, Masa
• Like 0
• Share
Tarow W
June 13, 2019 at 3:28 am
Hi Masaaki,
I am investigating how to VDM in Fiori using MultiDimensional (as suggested in one of your
blogs).
https://blogs.sap.com/2018/07/11/how-to-create-custom-fiori-multidimensional-reporting-
application-in-s4hana-on-premise/
I can create BW query on top of CDS view (as a Cube) and display it in RSRT perfectly.
However, when I consume this BW query in Fiori using MultiDimensional, the free
characteristics disappear.
https://answers.sap.com/questions/12698306/no-free-dimensions-when-using-fiori-
multidimension.html
Not sure if there is any missing step.
• Like 0
• Share
Sreekanth Surampally
April 12, 2020 at 10:07 pm
Hi Masa, thank you for the blog. Quick question on the example you explained. When we are
creating ZI_SALESBILL custom cds view, we can make association from i_salesorderitemcube
to i_fiscalyearvariant to get the required column fiscal year variant, why do we need to
extend the i_salesorderitemcube standard cds view? am I missing something here in
understanding an extension?
Thanks, Sreekanth
• Like 0
• Share
Masaaki Arai
Blog Post Author
April 13, 2020 at 3:24 am
Hello Sreekanth,
Thanks, Masa
• Like 0
• Share
Sreekanth Surampally
April 13, 2020 at 4:45 am
Yes, but if I add fiscalyearvariant in ZI_SALESBILL and move the association target
i_fiscalcalendarDate to next level cds like ZI_SALESBILL1., should n't that be ok? I am just
trying to understand what is the benefit of extending i_salesorderitemcube ., please assist
me.
• Like 0
• Share
Masaaki Arai
Blog Post Author
April 13, 2020 at 9:54 am
• Like 0
• Share
Sreekanth Surampally
April 13, 2020 at 1:55 pm
Sorry for the confusion Masa, I will explain with below screen shot, If I can add the new
fields in a custom cds view which reads the standard cds view, what would be the need for
extending standard cds view generally?
• Like 0
• Share
Masaaki Arai
Blog Post Author
April 13, 2020 at 5:38 pm
Okay, I see.
Yes, another way to add fields is to create wrapping view on top of the standard View. In
this way, it might be that the time for activation should be shorter.
But in the case, you have to create custom Fiori app consuming the wrapping CDS View as
the source instead of the standard VDM, although in case of odata, it could be avoided by
redirection. but anyway, it is complex.
Thanks, Masa
• Like 1
• Share
Sreekanth Surampally
April 14, 2020 at 11:14 am
• Like 0
• Share
Gregorio Cybill
April 18, 2020 at 3:29 am
Hi Masa,
I like the approach you are explaining the CDS concept and example.
Would you be able to share another blog associating hierarchy with the custom CDS view?
For example, CDS GL hierarchy based on the S/4 GL FSV group.
Thank you.
• Like 0
• Share
Mayumi Lacerda Blak
May 14, 2020 at 1:29 pm
Hello Masaaki!
I'm trying to extend the P&L Plan/Actual Fiori app. So I mapped the flow:
Extend Views:
My question is:
how can I have the fields extended for Plan and Actual? I cannot extend the composite view
with both of the extension views, because the fields get duplicated.
If I extend only from E_JournalEntryItem, the plan values are not read for the fields.
Mayumi
How can I have the fields being read by both Plan and Actual Extend views?
• Like 0
• Share
Masaaki Arai
Blog Post Author
May 14, 2020 at 5:45 pm
Hello Mayumi,
https://blogs.sap.com/2020/02/01/adding-field-in-standard-fiori-apps-of-s-4hana-with-
custom-fields-and-logic/
regards, Masa
• Like 0
• Share
Hello Masaaki,
I read your link but unfortunately according to sap note 2453614, COPA fields are not
extendable through app Custom Fields and Logic (not available in SCFD_EUI).
I did it sucessfully for CDS related to Actuals (P&L Actuals), that are based on
I_JournalEntryItem, but for Plan/Actual, I could't find the solution.
Kind regards
Mayumi
• Like 0
• Share
Masaaki Arai
Blog Post Author
May 18, 2020 at 8:27 am
Hello Mayumi,
Yes, If it is not possible with CFD, the remaining way is extend view.
https://blogs.sap.com/2018/08/22/sample-custom-cds-view-using-predefined-virtual-data-
model-and-extend-view-in-s4hana/
Thanks, Masa
• Like 1
• Share
Hello Masa,
Do you have an example of how to extend CDS views with new fields + texts? I extended
COPA fields but only the key, the texts are not available on reports.
Kind regards
Mayumi
• Like 0
• Share
Masaaki Arai
Blog Post Author
May 27, 2020 at 5:09 am
Hi Mayumi,
You can associate the master view via extend view. the master view should have the text
field and associated to the key field.
regards, Masa
• Like 0
• Share
Mayumi Lacerda Blak
May 28, 2020 at 10:27 pm
Hello Maza!
It worked for Key and text only with the annotation @AnalyticsDetails.query.display: #TEXT.
When I put @AnalyticsDetails.query.display: #KEY_TEXT, only the key was available.
Thanks a lot for your help! I'm not an Abaper so i'm struggling with CDS View extensions....
Kind Regards
Mayumi
• Like 0
• Share
Sreekanth Surampally
June 23, 2020 at 9:09 pm
Hi Masa, What is need of Private Views in Standard VDM content., I could not find more
explanation in sap help documentation and also in SAP forum. Why did SAP created some
private views in every business model, I mean what ever the code/logic inside private view
can be achieved with regular basic view or composite view. I posted a question in the forum
as well, but did not get any response.https://answers.sap.com/questions/13078306/what-
do-we-need-of-private-cds-views-s4-hana-vdm.html
• Like 0
• Share
Masaaki Arai
Blog Post Author
June 29, 2020 at 4:44 pm
Hello Sreekanth,
Private View is not mandatory, but importance is in Interface View and Consumption View.
Private View would have to be created for technical reasons, e.g. to create instead of sub-
query.
I personally think the differentiation among Consumption View, Interface View and Private
view is not so important. I think transaction view and master view should be differentiated.
https://blogs.sap.com/2018/10/18/predefined-virtual-data-model-as-example/
Thanks, Masa
• Like 0
• Share
Joachim Rees
August 31, 2020 at 10:05 am
I'm creating a report selection some stuff, and want "to do it right", using CDS-views.
I was not sure how interface- and consummations views work together, I wanted to read up
in the again. So I searched for "CDS VDM" and found this blog.
The section "Predefined VDM and Extend View" is just what I was looking for, and helps me
a lot!
As I need to join DD02L, TADIR and TDEVC, one of my questions was if I should:
- first create CDS-Views (Interface-Views) for each singel table, then do the join them
together in another (Interface-) view on top of them
or:
- do the join right away in the first (interface-) view I create.
Interface View: I_SalesDocumentItem (Use table VBAK, VBAP, VBKD, VEDA as sources)
• Like 1
• Share
Sebastián Linares
November 25, 2020 at 12:52 pm
one question.........If I want use the I_* views from a C_* view standard from SAC its not
necessary make anything, ok? I should create a custom C view when I want take it directly
(the I_* views)......ok?
Thanks