如何计算CDS view里两个时间戳之间的天数间隔
ABAP透明表里的时间戳,数据类型为dec:
有个需求:计算这两个时间戳之间的天数间隔,丢弃时间戳年-月-日8位后面的小时:分钟:秒。
举个例子:如果时间戳是20180918173132,丢弃173132,只保留20180918, 然后再计算天数间隔。
直接用CDS view的字符串操作函数substring是不行的,因为时间戳类型dec和substring期待的字符串类型不匹配。
解决方案:
先将时间戳字段类型从dec强制转换成abap.dats:
@AbapCatalog.sqlViewName: 'zproday'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Day between'
define view zdate_day_between as select from comm_product {
key comm_product.product_id as prod_id,
comm_product.product_guid as prod_guid,
comm_product.valid_from as valid_from,
comm_product.valid_to as valid_to,
cast(substring(cast(valid_from as abap.char(32)),1,8) as abap.dats) as from_date,
cast(substring(cast(valid_to as abap.char(32)),1,8) as abap.dats) as to_date
}
然后再用CDS view标准的时间处理函数DATS_DAYS_BETWEEN:
@AbapCatalog.sqlViewName: 'zdbetw'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Day between'
define view zc_date_day_between as select from zdate_day_between as host{
key host.prod_guid,
host.prod_id,
host.from_date,
host.to_date,
DATS_DAYS_BETWEEN(host.from_date, host.to_date) as no_of_days
}
测试结果:
ABAP
(1) Dialog: Individual, interactive system access.
(2) System: Background processing and communication within a system (such as RFC users for ALE, Workflow, TMS, and CUA).
(3) Communication:Dialog-free communication for external RFC calls.
(4) Service: Dialog user available to a larger, anonymous group of users.
(5) Reference: General, non-person related users that allows the assignment of additional identical authorizations, such as for Internet users created with transaction SU01. No logon is possible.
SAP Cloud Platform
Business user vs technical user:
Kubernetes
也有User Account和Service account的概念。
用户帐户为用户提供账户标识,而服务账户为计算机进程和Kubernetes集群中运行的
Pod提供账户标识。两者的一个区别是作用范围:前者对应人
的身份,与服务的namespace无关,因此用户账户是跨namespace的;而后者对应的是一个运行中程序的身份,因此与特定namespace相关。
Service Account用来访问Kubernetes API,由Kubernetes自动创建,并且会自动挂载到
Pod的 /run/secrets/kubernetes.io/serviceaccount 目录中。
如下图:以这个pod为例:
要获取更多Jerry的原创文章,请关注公众号"汪子熙".
- 点赞
- 收藏
- 关注作者
评论(0)