当前位置: 移动技术网 > IT编程>网页制作>HTML > CDS View-Part5&Part6&Part7

CDS View-Part5&Part6&Part7

2020年07月14日  | 移动技术网IT编程  | 我要评论

原文:
https://sapyard.com/abap-for-sap-hana-part-xxi-abap-cds-views-with-authorization/
https://help.sap.com/viewer/f2e545608079437ab165c105649b89db/7.5.5/en-US/7072ee4d6bf41014b5040bee4e204223.html
尊重版权,仅个人学习

CDS View的权限是如何管理的?

ABAP Core Data Services (CDS)有自己的权限管理概念:基于数据控制语言data control language(**DCL**)的授权概念。

D C L是不是比D D L大,所以DCL是哥哥,要保护DDL。汗

CDS授权概念与用于ABAP的SAP NetWeaver Application Server的传统授权概念共存。这些概念可以一起使用,也可以单独使用。传统的授权概念基于授权对象。用户的授权可以是隐式的(例如在调用事务时),也可以是显式的使用权限检查语句AUTHORITY-CHECKCDS授权概念基于隐式授权检查,在用户使用服务适应定义语言service adaptation definition language(SADL)或Open SQL访问CDS Entity时进行检查。

下图显示了创建DCL的主要组件。在创建了CDS Entity之后你希望在DDL中保护它不被未授权访问,这时就可以使用基于eclipse的ABAP IDE中的向导为授权对象创建DCL源在DCL源文件中定义CDS角色

在创建DDL时使用DCL语句DEFINE role为CDS Entity定义CDS角色。这样当使用SADL或Open SQL访问这个CDS Entity时,会检查以下内容:

  1. 是否为CDS Entity定义了角色? 如果没有则对查询返回的数据没有限制。
  2. 当前用户是否具有所需的权限?
    接上一个检查,如果CDS实体定义了角色,那么访问控制管理将使用传统的权限管理检查当前用户的权限,并仅读取有授权的数据。此时,CDS角色被隐式地分配给所有用户。

当激活DCL时,SAP NW AS为生成权限视图并且填充所需的metadata到相应的访问控制管理表。

在这里插入图片描述
用户会被授于两类权限:

  • 系统权限
  • 对象权限

举例说明:

  1. 使用表SFLIGHT 和 SFLCONNPOS创建一个CDS View
    在这里插入图片描述
  2. 创建 DCL
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

CDS 基本表达式和操作语法

CDS中的参数:
在这里插入图片描述
Session 变量:
在这里插入图片描述

user 当前用户
client 登录client
system_language 系统语言
system_date 系统日期
@AbapCatalog.sqlViewName: 'ZFLG_CDS_OP_V'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Operations'
define view ZFLG_CDS_OP
      with parameters p_date : abap.dats
  as select from sflight as a
{
  key a.carrid as FlgCarr,
  key a.connid as FlgConn,
  key case ( a.planetype )
  when '737-400' then 'BOEING'
  when 'A340-600' then 'AIRBUS'
  else 'OTHERS'
  end  as FlgType,
  key a.fldate,
     case 
     when a.price is null then 'error'
     when  a.price < 200  then 'Budget'
     when  a.price >= 200 and
           a.price < 400 then 'Business'
     else 'Very Costly'
            end      as flight_type,
  $session.system_language as Language        
}
    where a.fldate = $parameters.p_date;

在这里插入图片描述

算术表达式/聚合表达式/类型转换

算术计算

正负转换:

'Field Value' * '-1' = -'Field Value'

还有:
Finding the absolute value of a number: |a| -> ABS( a ).
Finding the lowest integer greater than a: CEIL( a ).
Finding the greatest integer less than a: FLOOR( a ).
For trigonometric operands, try ACOS, COS, etc
Finding the square root of a, a > 0: SQRT( a )
Finding the length of characters in the string: STRLEN( a )
Finding remainder a/b: a MOD b.

聚合

常见聚合包括 max/min/avg/sum/count:

@AbapCatalog.sqlViewName: 'ZFLG_CDS_OP_V'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Operations'
define view ZFLG_CDS_OP
as select from sflight as a
{
key a.carrid as FlgCarr,
max( a.price ) as MaxPrice,
min( a.price ) as MinPrice,
avg( a.price ) as AvgPrice,
sum( a.price ) as SumPrice,
count( * ) as TotalCount
} group by a.carrid

类型转换:

基本类型列表:

Data Type Description
abap.char( len ) CHAR with length len
abap.clnt[(3)] CLNT
abap.cuky( len ) CHAR with length len
abap.curr(len,decimals) CURR with length len and decimals decimal places
abap.dats[(8)] DATS
abap.dec(len,decimals) DEC with length len and decimals decimal places
abap.fltp[(16,16)] FLTP
abap.int1[(3)] INT1
abap.int2[(5)] INT2
abap.int4[(10)] INT4
abap.int8[(19)] INT8
abap.lang[(1)] LANG
abap.numc( len ) NUMC with length len
abap.quan(len,decimals) QUAN with length len with decimals decimal places
abap.raw(len) RAW
abap.sstring(len) SSTRING
abap.tims[(6)] TIMS
abap.unit( len ) CHAR with length len

参考:
https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_cast_expression.htm
https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencds_f1_cast_expression_rules.htm

本文地址:https://blog.csdn.net/xiayutian_c/article/details/107167970

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网