CDS视图权限

Hi!

Hi!

对每个CDS视图,我们都得以因而DCL(Data Control
Language)定义访问调整。在那篇作品中,作者会介绍ABAP
CDS视图中国和北美洲常首要的另1方面:权限管理。

对每1个CDS视图,大家都足以透过DCL(Data Control
Language)定义访问调整。在那篇小说中,小编会介绍ABAP
CDS视图中国和澳洲常首要的一头:权限处理。

正文的论述基于本身正在选用的S4/HANA 1六十 on NW 7.5一.

正文的阐发基于自个儿正在使用的S4/HANA 1陆十 on NW 7.5一.

内容分成八个部分:

内容分成七个部分:

  1. 正规示例的访问调节。
  2. 遵照PFCG权限创造3个轻巧的事例。
  3. 涵盖CUBE数据类其余CDS分析视图。
  4. CDS分析查询视图的访问调节。
  5. 权限对象的并集(UNION)或许夹杂(INTECRUISERSECTION)。
  1. 正规示例的访问调控。
  2. 遵照PFCG权限创制四个简短的例证。
  3. 含有CUBE数据类别的CDS分析视图。
  4. CDS分析查询视图的访问调控。
  5. 权限对象的并集(UNION)或许夹杂(INTE昂科拉SECTION)。

 

 

正文链接:http://www.cnblogs.com/hhelibeb/p/7427753.html

正文链接:http://www.cnblogs.com/hhelibeb/p/7427753.html

1. 专门的工作示例的访问调控例子

壹. 正规示例的访问调节例子

一) 全访问示例(Full access

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_FULLACC'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_fullaccess
  as select from
    scarr
    {
      key carrid,
          carrname,
          currcode,
          url
    };  

 DCL:

@MappingRole: true
define role demo_cds_role_fullaccess {
  grant select on demo_cds_auth_fullaccess; }

1) 全访问示例(Full access

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_FULLACC'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_fullaccess
  as select from
    scarr
    {
      key carrid,
          carrname,
          currcode,
          url
    };  

 DCL:

@MappingRole: true
define role demo_cds_role_fullaccess {
  grant select on demo_cds_auth_fullaccess; }

二) 字面条件示例(Literal conditions

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_LITERAL'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_literal
 as select from
 scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 };

DCL:

@MappingRole: true
define role demo_cds_role_literal {
  grant select on demo_cds_auth_literal
  where carrid = 'LH'; }

二) 字面条件示例(Literal conditions

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_LITERAL'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_literal
 as select from
 scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 };

DCL:

@MappingRole: true
define role demo_cds_role_literal {
  grant select on demo_cds_auth_literal
  where carrid = 'LH'; }

3) PFCG权限示例

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_PFCG'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_pfcg
 as select from
 scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 }; 

DCL:

@MappingRole: true
define role demo_cds_role_pfcg {
  grant select on demo_cds_auth_pfcg
  where (carrid) =
  aspect pfcg_auth (s_carrid, carrid, actvt='03'); }

 权限对象s_carrid能够在业务代码SU21中的BC_C object类下查到。

三) PFCG权限示例

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_PFCG'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_pfcg
 as select from
 scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 }; 

DCL:

@MappingRole: true
define role demo_cds_role_pfcg {
  grant select on demo_cds_auth_pfcg
  where (carrid) =
  aspect pfcg_auth (s_carrid, carrid, actvt='03'); }

 权限对象s_carrid能够在作业代码SU21中的BC_C object类下查到。

四) 字面条件和PFCG权限结合示例

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_LITPFCG'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_lit_pfcg
 as select from
 scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 };    

DCL:

@MappingRole: true
define role demo_cds_role_lit_pfcg {
  grant select on demo_cds_auth_lit_pfcg
  where (carrid) =
  aspect pfcg_auth (s_carrid, carrid, actvt='03') and
         currcode = 'EUR'; }

4) 字面条件和PFCG权限结合示例

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_LITPFCG'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_lit_pfcg
 as select from
 scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 };    

DCL:

@MappingRole: true
define role demo_cds_role_lit_pfcg {
  grant select on demo_cds_auth_lit_pfcg
  where (carrid) =
  aspect pfcg_auth (s_carrid, carrid, actvt='03') and
         currcode = 'EUR'; }

5) 承袭权限示例

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_INH'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_inherited
  as select from
    demo_cds_auth_lit_pfcg
    {
      key carrid,
          carrname,
          currcode,
          url
    };  

DCL:

@MappingRole: true
define role demo_cds_role_inherited {
  grant select on demo_cds_auth_inherited
               inherit demo_cds_role_lit_pfcg or currcode = 'USD'; }

在那几个例子会显示USD和EU途乐类型货币的笔录。

五) 承接权限示例

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_INH'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_inherited
  as select from
    demo_cds_auth_lit_pfcg
    {
      key carrid,
          carrname,
          currcode,
          url
    };  

DCL:

@MappingRole: true
define role demo_cds_role_inherited {
  grant select on demo_cds_auth_inherited
               inherit demo_cds_role_lit_pfcg or currcode = 'USD'; }

在那些例子会显示USD和EU汉兰达类型货币的记录。

6) 根据当前用户的权限决定示范

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_USR'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_user
  as select from
    abdocmode
    {
      key uname,
      key langu,
          flag
    };  

DCL:

@MappingRole: true
define role demo_cds_role_user { 
  grant select on demo_cds_auth_user
    where
      uname ?= aspect user; }

6) 依照当前用户的权柄调节示范

DDL:

@AbapCatalog.sqlViewName: 'DEMO_CDS_USR'
@AccessControl.authorizationCheck: #CHECK
define view demo_cds_auth_user
  as select from
    abdocmode
    {
      key uname,
      key langu,
          flag
    };  

DCL:

@MappingRole: true
define role demo_cds_role_user { 
  grant select on demo_cds_auth_user
    where
      uname ?= aspect user; }

二. 基于PFCG权限创立叁个简练的例子

复制以下代码,制造我们和好的CDS视图:

@AbapCatalog.sqlViewName: 'ZDEMO_CDS_PFCG'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Demo access pfcg'
define view Zdemo_Access_Pfcg as select from scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 };   

三,今后,要是在HANA
Studio中开采数据预览,大家将能够见见富有记录。访问控制方今还不存在。

图片 1

2,在SU二一创造大家温馨的自定义权限对象:

图片 2

对此每一种对象定义权限字段和活动字段,参加允许活动“03显示”。在本示例中,大家要在ZS_CONNID中加多字段CA中华VOdysseyID和CONNID。

图片 3

图片 4

3,为ZS_CA卡宴普拉多ID成立数量调控。

@MappingRole: true
define role zdemo_access_pfcg {
  grant select on Zdemo_Access_Pfcg
  where (carrid) =
  aspect pfcg_auth (zs_carrid, carrid, actvt='03'); }

4,在PFCG中创建叁个新的角色,在此处充分刚刚成立的权力对象,定义用户应当看到的依赖选用字段的数量。不要忘记生成配置。为大家的用户分配剧中人物。

在第贰个示范中,大家只使用ZS_CA福特Explorer宝马X5ID。在文章的末端,我们会用到任何的对象。

图片 5

图片 6

5,回到HANA Studio来测试权限。展开我们的CDS视图的多少预览:

图片 7

于今大家只看到了定义好的宇宙航行企业(CA中华VXC90ID)字段的笔录。

注意:

  1. 假诺在ABAP字典(SE1一)中展开视图,结果会是整个数码记录。
  2. 一旦在DDL中修改表明为如下内容,并激活CDS视图,大家将得以另行在数据预览中来看任何数码。那意味检查已经停业。

    @AccessControl.authorizationCheck: #NOT_ALLOWED

结论:在三个从数据库表中查询数据的粗略例子中,我们来看了访问调控是如何行事的。上面讲讲CDS分析视图。

2. 依照PFCG权限成立三个轻巧易行的例证

复制以下代码,创造我们友好的CDS视图:

@AbapCatalog.sqlViewName: 'ZDEMO_CDS_PFCG'
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Demo access pfcg'
define view Zdemo_Access_Pfcg as select from scarr
 {
 key carrid,
 carrname,
 currcode,
 url
 };   

3,今后,要是在HANA
Studio中展开数据预览,大家将得以看来具备记录。访问调控目前还不设有。

图片 8

二,在SU贰壹创设大家本身的自定义权限对象:

图片 9

对此各种对象定义权限字段和移动字段,参预允许活动“03展现”。在本示例中,大家要在ZS_CONNID中增加字段CALX570昂CoraID和CONNID。

图片 10

图片 11

3,为ZS_CAENCORELX570ID创立数量调节。

@MappingRole: true
define role zdemo_access_pfcg {
  grant select on Zdemo_Access_Pfcg
  where (carrid) =
  aspect pfcg_auth (zs_carrid, carrid, actvt='03'); }

四,在PFCG中创立一个新的剧中人物,在那里丰盛刚刚成立的权能对象,定义用户应当看到的依照采纳字段的多寡。不要遗忘生成配置。为我们的用户分配剧中人物。

在率先个示范中,我们只行使ZS_CA景逸SUVRID。在小说的末尾,大家会用到其余的靶子。

图片 12

图片 13

5,回到HANA Studio来测试权限。张开大家的CDS视图的数码预览:

图片 14

目前大家只看到了概念好的飞行集团(CA猎豹CS6EscortID)字段的记录。

注意:

  1. 假使在ABAP字典(SE11)中开采视图,结果会是总体多少记录。
  2. 假定在DDL中修改注明为如下内容,并激活CDS视图,大家将得以重新在数码预览中看出全数数额。那象征检查已经关闭。

    @AccessControl.authorizationCheck: #NOT_ALLOWED

结论:在三个从数据库表中查询数据的简要例子中,我们看到了访问调控是怎样职业的。上面讲讲CDS分析视图。

三. 包罗CUBE数据类其余CDS分析视图

1,通过复制已有个别内容创制我们友好的CDS视图。那是五个涵盖CUBE数据分类的CDS视图(译注:代码框出了点难点,大家聚拢看下..):

 

@AbapCatalog.sqlViewName: 'Z05_CFLIGHTAQ'                       // Name of the CDS database view in the ABAP Repository
@AccessControl.authorizationCheck: #CHECK              // CDS authorizations, controls the authorization check. In S4H410 not required
@EndUserText.label: 'Available Flights'                         // Translatable short text. Max 60characters. Text label is exposed to Analytica tools and the OData service
@VDM.viewType: #CONSUMPTION                                     // This is a CONSUMPTION view
@Analytics.query: true                                          // By tagging the CDS view as an analytical query it will be exposed to the analytic manager
@OData.publish: true                                            // Generates a suitable OData service, that will use the analytical query, when the CDS entity is activated

define view Z05_C_FlightByAirportQuery as select from Z05_I_FlightByAirport     // A analytical query CDS is implemented using a query select from CDS view Z00_I_FlightByAirport
                                                                                // Take care with OData publishing the max. lenght is 26 characters
{
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column Airline
    Z05_I_FlightByAirport.Airline,                              // Use the column Airline
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightConnection
    Z05_I_FlightByAirport.FlightConnection,                     // Use the column FlightConnection
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightDate
    Z05_I_FlightByAirport.FlightDate,                           // Use the column FlightDate
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false }  // Creates a mandatory filter on the values in the field AirportFrom
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportFrom
    @EndUserText.label: 'Departure Airport'                     // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo
    Z05_I_FlightByAirport.AirportFrom,                          // Use the column AirportFrom
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false } //  Creates an optional filter on the values in the field AirportTo
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportTo
    @EndUserText.label: 'Arrival Airport'                       // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo 
    Z05_I_FlightByAirport.AirportTo,                            // Use the column AirportTo                             
    Z05_I_FlightByAirport.Currency,                             // Use the column Currency  
    Z05_I_FlightByAirport.AircraftType,                         // Use the column AircraftType
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column FlightPrice
    Z05_I_FlightByAirport.FlightPrice,                          // Use the column FlightPrice
    Z05_I_FlightByAirport.MaximumNumberOfSeats,                 // Use the column MaximumNumberOfSeats
    Z05_I_FlightByAirport.NumberOfOccupiedSeats,                // Use the column NumberOfOccupiedSeats
    @DefaultAggregation: #FORMULA                               // Important to know for formular placement is evaluation time. Inside the final query, the evaluation is done after the flightbyairport
                                                                // view aggragation, so it's not on a very detailed level or even row level, but at the aggragate level. This is important for avarages 
                                                                // as they cannot be evaluated at the detail level 
    @EndUserText.label: 'Available Seats'
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column NumberOfAvailableSeats
    Z05_I_FlightByAirport.MaximumNumberOfSeats - Z05_I_FlightByAirport.NumberOfOccupiedSeats as NumberOfAvailableSeats  // this is a formular (calculated column) 
} 

贰,在访问调整中进行定义:

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
    where ( Airline ) = 
    aspect pfcg_auth (  ZS_CARRID,
                        CARRID,
                        actvt = '03' );

}

3,在小说的第3有的,大家在权力对象中增添了ZS_CA讴歌RDX景逸SUVID。在HANA
Studio的多少预览中检查结果。行数是530.图片 15

 

四,在作业代码哈弗SRT中反省结果,行数也是530。结果1致。

伍,在BO Analysis for
Excel中反省结果。结果是壹致的,对用户来讲,只有选中的航空集团得以被访问。

 图片 16

注意:没有AF飞行公司的事务数据,那是上面的显示器未出示相关数据的原由。

三. 暗含CUBE数据类别的CDS分析视图

一,通过复制已有的内容成立大家自身的CDS视图。那是一个饱含CUBE数据分类的CDS视图(译注:代码框出了点难点,我们集结看下..):

 

@AbapCatalog.sqlViewName: 'Z05_CFLIGHTAQ'                       // Name of the CDS database view in the ABAP Repository
@AccessControl.authorizationCheck: #CHECK              // CDS authorizations, controls the authorization check. In S4H410 not required
@EndUserText.label: 'Available Flights'                         // Translatable short text. Max 60characters. Text label is exposed to Analytica tools and the OData service
@VDM.viewType: #CONSUMPTION                                     // This is a CONSUMPTION view
@Analytics.query: true                                          // By tagging the CDS view as an analytical query it will be exposed to the analytic manager
@OData.publish: true                                            // Generates a suitable OData service, that will use the analytical query, when the CDS entity is activated

define view Z05_C_FlightByAirportQuery as select from Z05_I_FlightByAirport     // A analytical query CDS is implemented using a query select from CDS view Z00_I_FlightByAirport
                                                                                // Take care with OData publishing the max. lenght is 26 characters
{
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column Airline
    Z05_I_FlightByAirport.Airline,                              // Use the column Airline
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightConnection
    Z05_I_FlightByAirport.FlightConnection,                     // Use the column FlightConnection
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightDate
    Z05_I_FlightByAirport.FlightDate,                           // Use the column FlightDate
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false }  // Creates a mandatory filter on the values in the field AirportFrom
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportFrom
    @EndUserText.label: 'Departure Airport'                     // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo
    Z05_I_FlightByAirport.AirportFrom,                          // Use the column AirportFrom
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false } //  Creates an optional filter on the values in the field AirportTo
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportTo
    @EndUserText.label: 'Arrival Airport'                       // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo 
    Z05_I_FlightByAirport.AirportTo,                            // Use the column AirportTo                             
    Z05_I_FlightByAirport.Currency,                             // Use the column Currency  
    Z05_I_FlightByAirport.AircraftType,                         // Use the column AircraftType
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column FlightPrice
    Z05_I_FlightByAirport.FlightPrice,                          // Use the column FlightPrice
    Z05_I_FlightByAirport.MaximumNumberOfSeats,                 // Use the column MaximumNumberOfSeats
    Z05_I_FlightByAirport.NumberOfOccupiedSeats,                // Use the column NumberOfOccupiedSeats
    @DefaultAggregation: #FORMULA                               // Important to know for formular placement is evaluation time. Inside the final query, the evaluation is done after the flightbyairport
                                                                // view aggragation, so it's not on a very detailed level or even row level, but at the aggragate level. This is important for avarages 
                                                                // as they cannot be evaluated at the detail level 
    @EndUserText.label: 'Available Seats'
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column NumberOfAvailableSeats
    Z05_I_FlightByAirport.MaximumNumberOfSeats - Z05_I_FlightByAirport.NumberOfOccupiedSeats as NumberOfAvailableSeats  // this is a formular (calculated column) 
} 

二,在访问调控中展开定义:

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
    where ( Airline ) = 
    aspect pfcg_auth (  ZS_CARRID,
                        CARRID,
                        actvt = '03' );

}

三,在篇章的第3局部,我们在权力对象中加多了ZS_CA福特ExplorerLANDID。在HANA
Studio的数量预览中反省结果。行数是530.图片 17

 

四,在职业代码奥迪Q5SRT中检查结果,行数也是530。结果同样。

五,在BO Analysis for
Excel中检查结果。结果是同样的,对用户来讲,唯有选中的宇宙航行集团得以被访问。

 图片 18

注意:没有AF航空集团的政工数据,那是地方的显示屏未出示相关数据的原故。

四. CDS分析查询视图的访问调节。

一,在第3部分的CUBE CDS中创建1个解析查询视图。

@AbapCatalog.sqlViewName: 'Z05_CFLIGHTAQ'                       // Name of the CDS database view in the ABAP Repository
@AccessControl.authorizationCheck: #CHECK              // CDS authorizations, controls the authorization check. In S4H410 not required
@EndUserText.label: 'Available Flights'                         // Translatable short text. Max 60characters. Text label is exposed to Analytica tools and the OData service
@VDM.viewType: #CONSUMPTION                                     // This is a CONSUMPTION view
@Analytics.query: true                                          // By tagging the CDS view as an analytical query it will be exposed to the analytic manager
@OData.publish: true                                            // Generates a suitable OData service, that will use the analytical query, when the CDS entity is activated

define view Z05_C_FlightByAirportQuery as select from Z05_I_FlightByAirport     // A analytical query CDS is implemented using a query select from CDS view Z00_I_FlightByAirport
                                                                                // Take care with OData publishing the max. lenght is 26 characters
{
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column Airline
    Z05_I_FlightByAirport.Airline,                              // Use the column Airline
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightConnection
    Z05_I_FlightByAirport.FlightConnection,                     // Use the column FlightConnection
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightDate
    Z05_I_FlightByAirport.FlightDate,                           // Use the column FlightDate
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false }  // Creates a mandatory filter on the values in the field AirportFrom
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportFrom
    @EndUserText.label: 'Departure Airport'                     // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo
    Z05_I_FlightByAirport.AirportFrom,                          // Use the column AirportFrom
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false } //  Creates an optional filter on the values in the field AirportTo
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportTo
    @EndUserText.label: 'Arrival Airport'                       // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo 
    Z05_I_FlightByAirport.AirportTo,                            // Use the column AirportTo                             
    Z05_I_FlightByAirport.Currency,                             // Use the column Currency  
    Z05_I_FlightByAirport.AircraftType,                         // Use the column AircraftType
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column FlightPrice
    Z05_I_FlightByAirport.FlightPrice,                          // Use the column FlightPrice
    Z05_I_FlightByAirport.MaximumNumberOfSeats,                 // Use the column MaximumNumberOfSeats
    Z05_I_FlightByAirport.NumberOfOccupiedSeats,                // Use the column NumberOfOccupiedSeats
    @DefaultAggregation: #FORMULA                               // Important to know for formular placement is evaluation time. Inside the final query, the evaluation is done after the flightbyairport
                                                                // view aggragation, so it's not on a very detailed level or even row level, but at the aggragate level. This is important for avarages 
                                                                // as they cannot be evaluated at the detail level 
    @EndUserText.label: 'Available Seats'
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column NumberOfAvailableSeats
    Z05_I_FlightByAirport.MaximumNumberOfSeats - Z05_I_FlightByAirport.NumberOfOccupiedSeats as NumberOfAvailableSeats  // this is a formular (calculated column) 
} 

 

二,在HANA
Studio中举行数量预览,行数依旧4894。看起来CDS分析查询未有应用到Cube
CDS视图权限,然而事实并非如此。你并不要求为分析查询CDS视图创立额外的访问调整。

三,在Excel中检查奥迪Q7SRT或许BO分析的结果。结果评释Cube
CDS视图的权杖在解析查询中起到了意义。

图片 19

在意:在分析查询定义中不须要创制任何变量,就好像大家在含蓄权限的BEx查询中那么。

4,修改Cube CDS视图,增多权限对象ZS_CONNID而非ZS_CARRID

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
     where ( FlightConnection) = aspect pfcg_auth (  ZS_CONNID,
                                                     CONNID,
                                                     actvt = '03' );

}

剖析查询结果变得严苛了(在第一局地的第6步能够见到ZS_CONNID的定义).

如今结果的行数是21二.

图片 20

肆. CDS分析查询视图的访问调整。

壹,在第2部分的CUBE CDS中开创八个分析查询视图。

@AbapCatalog.sqlViewName: 'Z05_CFLIGHTAQ'                       // Name of the CDS database view in the ABAP Repository
@AccessControl.authorizationCheck: #CHECK              // CDS authorizations, controls the authorization check. In S4H410 not required
@EndUserText.label: 'Available Flights'                         // Translatable short text. Max 60characters. Text label is exposed to Analytica tools and the OData service
@VDM.viewType: #CONSUMPTION                                     // This is a CONSUMPTION view
@Analytics.query: true                                          // By tagging the CDS view as an analytical query it will be exposed to the analytic manager
@OData.publish: true                                            // Generates a suitable OData service, that will use the analytical query, when the CDS entity is activated

define view Z05_C_FlightByAirportQuery as select from Z05_I_FlightByAirport     // A analytical query CDS is implemented using a query select from CDS view Z00_I_FlightByAirport
                                                                                // Take care with OData publishing the max. lenght is 26 characters
{
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column Airline
    Z05_I_FlightByAirport.Airline,                              // Use the column Airline
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightConnection
    Z05_I_FlightByAirport.FlightConnection,                     // Use the column FlightConnection
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column FlightDate
    Z05_I_FlightByAirport.FlightDate,                           // Use the column FlightDate
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false }  // Creates a mandatory filter on the values in the field AirportFrom
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportFrom
    @EndUserText.label: 'Departure Airport'                     // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo
    Z05_I_FlightByAirport.AirportFrom,                          // Use the column AirportFrom
    @Consumption.filter: {selectionType: #SINGLE, multipleSelections: false, mandatory: false } //  Creates an optional filter on the values in the field AirportTo
    @AnalyticsDetails.query.axis: #ROWS                         // Defines the default row/colums apperance for the column AirportTo
    @EndUserText.label: 'Arrival Airport'                       // Add an human readable enduser label to make sure that we can differentiate between AirportFrom and AirportTo 
    Z05_I_FlightByAirport.AirportTo,                            // Use the column AirportTo                             
    Z05_I_FlightByAirport.Currency,                             // Use the column Currency  
    Z05_I_FlightByAirport.AircraftType,                         // Use the column AircraftType
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column FlightPrice
    Z05_I_FlightByAirport.FlightPrice,                          // Use the column FlightPrice
    Z05_I_FlightByAirport.MaximumNumberOfSeats,                 // Use the column MaximumNumberOfSeats
    Z05_I_FlightByAirport.NumberOfOccupiedSeats,                // Use the column NumberOfOccupiedSeats
    @DefaultAggregation: #FORMULA                               // Important to know for formular placement is evaluation time. Inside the final query, the evaluation is done after the flightbyairport
                                                                // view aggragation, so it's not on a very detailed level or even row level, but at the aggragate level. This is important for avarages 
                                                                // as they cannot be evaluated at the detail level 
    @EndUserText.label: 'Available Seats'
    @AnalyticsDetails.query.axis: #COLUMNS                      // Defines the default row/colums apperance for the column NumberOfAvailableSeats
    Z05_I_FlightByAirport.MaximumNumberOfSeats - Z05_I_FlightByAirport.NumberOfOccupiedSeats as NumberOfAvailableSeats  // this is a formular (calculated column) 
} 

 

二,在HANA
Studio中开始展览多少预览,行数照旧48九四。看起来CDS分析查询未有选择到Cube
CDS视图权限,不过实际并非如此。你并不要求为分析查询CDS视图创建额外的访问调控。

三,在Excel中检查RAV4SRT大概BO分析的结果。结果注脚Cube
CDS视图的权杖在分析查询中起到了效益。

图片 21

留意:在分析查询定义中不须要创设任何变量,就像是大家在蕴藏权限的BEx查询中那么。

4,修改Cube CDS视图,增添权力对象ZS_CONNID而非ZS_CARRID

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
     where ( FlightConnection) = aspect pfcg_auth (  ZS_CONNID,
                                                     CONNID,
                                                     actvt = '03' );

}

分析查询结果变得严谨了(在第3片段的第四步能够看到ZS_CONNID的定义).

现行反革命结果的行数是21贰.

图片 22

伍. 权力的并集(UNION)和混合(INTE陆风X八SECTION)

1,通过“AND”取权限的插花。那里定义了贰个新的权能“ZS_FLDAT”,它只包含叁天的限量(2015.0二.0肆

  • 201伍.0二.0陆)。修改DCL,扩展混合:

    @EndUserText.label: ‘Role for Z05_I_FLIGHTBYAIRPORT’
    @MappingRole: true
    define role Z05_ROLE {

      grant select on Z05_I_FlightByAirport
       where ( Airline) = 
              aspect pfcg_auth (  ZS_CARRID,
                                  CARRID,
                                  actvt = '03' ) AND
             (FlightDate ) = 
              aspect pfcg_auth (  ZS_FLDAT,
                                  FLTDATE,
                                  actvt = '03' );
    

    }

图片 23

2,通过“OR”取并集:

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
     where ( Airline) = 
            aspect pfcg_auth (  ZS_CARRID,
                                CARRID,
                                actvt = '03' ) OR
           ( FlightDate ) = 
            aspect pfcg_auth (  ZS_FLDAT,
                                FLTDATE,
                                actvt = '03' );

}

图片 24

 三,如若在一个权力对象中加多这四个字段,那结果就象是于交集:

图片 25

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
     where ( Airline, FlightDate) = 
            aspect pfcg_auth (  ZS_NEW,
                                CARRID,
                                FLTDATE,
                                actvt = '03' );

图片 26

注意:永不遗忘在Cube
CDS视图的层级定义权限,而非分析视图层级。
倘使你在条分缕析查询层级定义了和第6部分同样的权能,那么:

  • 在SAP HANA Studio的多少预览中,结果看起来是对的。
  • 在RubiconSRT, BO Analysis for
    Excel和其他使用了OLAP引擎的工具中,使用的是Cube
    CDS视图的权位(如有定义)。

注意:在HANA
Studio的多寡预览中,分析查询的结果集会场全数来得。为了勘误那点,能够给分析查询成立以下访问调控:

@MappingRole: true
define role Z05_ROLE_2 {
  grant select on Z05_C_FlightByAirportQuery 
               inherit Z05_ROLE; }

敲定:你可以为CDS分析视图定义权限的插花也许并集。

 

本文结束,感激关怀!

 

英文原稿:ABAP CDS views with Authorization based on Access
Control

 

五. 权力的并集(UNION)和混合(INTE福特ExplorerSECTION)

一,通过“AND”取权限的参差不齐。那里定义了二个新的权限“ZS_FLDAT”,它只含有三天的限制(201五.0二.04

  • 2015.02.0陆)。修改DCL,增添混合:

    @EndUserText.label: ‘Role for Z05_I_FLIGHTBYAIRPORT’
    @MappingRole: true
    define role Z05_ROLE {

      grant select on Z05_I_FlightByAirport
       where ( Airline) = 
              aspect pfcg_auth (  ZS_CARRID,
                                  CARRID,
                                  actvt = '03' ) AND
             (FlightDate ) = 
              aspect pfcg_auth (  ZS_FLDAT,
                                  FLTDATE,
                                  actvt = '03' );
    

    }

图片 27

2,通过“OR”取并集:

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
     where ( Airline) = 
            aspect pfcg_auth (  ZS_CARRID,
                                CARRID,
                                actvt = '03' ) OR
           ( FlightDate ) = 
            aspect pfcg_auth (  ZS_FLDAT,
                                FLTDATE,
                                actvt = '03' );

}

图片 28

 三,如若在一个权力对象中增多那三个字段,那结果就就好像于交集:

图片 29

@EndUserText.label: 'Role for Z05_I_FLIGHTBYAIRPORT'
@MappingRole: true
define role Z05_ROLE {
    grant select on Z05_I_FlightByAirport
     where ( Airline, FlightDate) = 
            aspect pfcg_auth (  ZS_NEW,
                                CARRID,
                                FLTDATE,
                                actvt = '03' );

图片 30

注意:绝不忘记在Cube
CDS视图的层级定义权限,而非分析视图层级。
假诺您在分析查询层级定义了和第四片段壹模同样的权限,那么:

  • 在SAP HANA Studio的数据预览中,结果看起来是对的。
  • 在大切诺基SRT, BO Analysis for
    Excel和其余使用了OLAP引擎的工具中,使用的是Cube
    CDS视图的权杖(如有定义)。

注意:在HANA
Studio的数目预览中,分析查询的结果会全体来得。为了考订那一点,能够给分析查询创设以下访问调节:

@MappingRole: true
define role Z05_ROLE_2 {
  grant select on Z05_C_FlightByAirportQuery 
               inherit Z05_ROLE; }

敲定:你可感觉CDS分析视图定义权限的参差不齐也许并集。

 

本文甘休,感激关切!

 

英文原稿:ABAP CDS views with Authorization based on Access
Control