Symptom
Your requirement is to fetch the Business Partner Address information like Street, Postal Code, Email Address etc. Upon executing the CDS view I_ADDRESS_2 or I_AddressEmailAddress_2 using the app Custom CDS View, you are unable to see any data regarding the Street, Email Address, and so on.
Environment
SAP S/4HANA Cloud Public Edition
Reproducing the Issue
- Go to the app Custom CDS Views.
- Select Create button.
- On the Create Custom CDS View dialog box, provide the below:
- Label:
- Name:
- Scenario: Standard CDS View.
- Select Create.
- In the Select: Primary Data Source screen, search for I_ADDRESS_2 or I_AddressEmailAddress_2.
- Primary Datasource is released with access Protection: Privileged Only.
- Execute the CDS View I_ADDRESS_2 or I_AddressEmailAddress_2 and you are unable to see the complete Address / Email Address information.
Cause
You can refer the documentation available in SAP Help Portal regarding the Access Protection in Custom CDS Views.
- If a CDS view has the status privileged only, the data contained cannot be accessed directly and is not exposed in an OData Service. The data can only be accessed via an association in a protected CDS view.
- If you build a custom CDS view on top of a CDS view with the status privileged only, your custom CDS view inherits the privileged only status of its parent CDS View. The same rules apply concerning data access.
- If a CDS view has the status protected, it can only be accessed if the corresponding business roles are assigned to a user. Otherwise, the data contained cannot be accessed or exposed in an OData Service.
Both I_ADDRESS_2 and I_AddressEmailAddress_2 are annotated with @AccessControl.authorizationCheck: #PRIVILEGED_ONLY, which means the data cannot be previewed directly in the Custom CDS View app. To view the data, the WITH PRIVILEGED ACCESS clause must be added in the SQL statement when executing the views in ADT.
Resolution
I_Address_2, I_AddressEmailAddress_2 and I_Address both have DCL authorizations built on them, which means to view the data, we need to add ‘With privileged access’ in the SQL statement which is generated in ADT on executing the view. It is not possible to preview the data in the Custom CDS view app.
You should login to the ADT tool (ABAP Development Tools) to execute the CDS view.
For exmaple, for the CDS view I_ADDRESS_2:
- Open the ABAP Development Tools app
- File->New->ABAP Project
- Currently logged into XYZ (XYZ represents the SAP internal test system)
- Select the icon Open ABAP Development Object
- Select the Data Definition for I_ADDRESS_2
- Observe the below:
========================
@AccessControl.authorizationCheck: #PRIVILEGED_ONLY
@Analytics : {
dataCategory: #DIMENSION,
dataExtraction: {
enabled: true }
}
@AccessControl.privilegedAssociations: ['_OrganizationAddress', '_PersonAddress', '_EmailAddress', '_CurrentDfltEmailAddress', '_PhoneNumber', '_CurrentDfltLandlinePhoneNmbr', '_CurrentDfltMobilePhoneNumber', '_FaxNumber', '_CurrentDfltFaxNumber', '_UniformResourceIdentifier', '_MainWebsiteURL']
@EndUserText.label: 'Address of an Organization or a Person'
======================== - Select F8
- On the right side, click on the tab SQL Console
- Scroll down to the bottom of the code lines, make the required changes as below
FROM
I_ADDRESS_2
WITH PRIVILEGED ACCESS
- Select the button Run
- Check the Data Preview on the right side
- Able to see the data available in the street fields for the Business Partner
I_ADDRESS_2~STREETNAME,
I_ADDRESS_2~STREETPREFIXNAME1,
I_ADDRESS_2~STREETPREFIXNAME2,
I_ADDRESS_2~STREETSUFFIXNAME1,
I_ADDRESS_2~STREETSUFFIXNAME2
See Also
Keywords
S4_PC, S4_1C, S/4HANA Cloud, Access Protection, Custom CDS Views, ADT, ABAP Development Tools, Privileged Only, Privileged, I_ADDRESS_2, Address, Street, Business Partner, BP. , KBA , LO-MD-BP-2CL , Business Partners for Public Cloud , LO-MD-BP , Business Partners , Problem
SAP Knowledge Base Article - Public