SAP S/4HANA CDS View的访问控制实现:DCL介绍

来自我的同事Xu Miles

Authorization Objects are business concept, they are distinguished by business scenario.
Therefore, there might be a lot of Authorization Objects using the same Authorization Field. Such as VKORG.

webp

In Sales Planning, there're two Authorization Objects related to Sales Area, V_VBAK_VKO and V_VBRK_VKO, they represent transaction scenario Sales Document and Billing Document repectively. If we want to extract the Sales Area master data, technically we could use any Authorization Object with Authorization Field VKORG, VTWEG, SPART.
However, considering the authorization of the business user, we need to use Authorization Object V_VBAK_VKO and V_VBRK_VKO separately when end user is planning for income sales or sales volume.
To do this, we could use additional CDS view + DCL to realize.

Example on ERG/001:

CDS: ZMX_SalesArea_DCL
DCL: ZMX_SalesArea_DCL
The logic in DCL:


@EndUserText.label: 'Auto assigned mapping role for ZMX_SalesArea_DCL'@MappingRole: truedefine role ZMX_SalesArea_DCL  {grant select on ZMX_SalesArea_DCLwhere (SalesPlanPurpose = '0' and (SalesOrganization, DistributionChannel, Division) =aspect pfcg_auth (V_VBAK_VKO,
VKORG,
VTWEG,
SPART,
actvt = '03'))OR (SalesPlanPurpose = '1' and (SalesOrganization) =aspect pfcg_auth (V_VBRK_VKO,
VKORG,
actvt = '03'));
}

The logic in the CDS view:


define view ZMX_SalesArea_DCLas select fromI_SalesArea
{
key SalesOrganization,
key DistributionChannel,
key Division,'0' as SalesPlanPurpose
}
union all select from I_SalesArea
{
key SalesOrganization,
key DistributionChannel,
key Division,'1' as SalesPlanPurpose
};

Authorization test on QW9/910
User: MILES01
Authorization:

Test Report:

REPORT mx_test_sa_dcl.
PARAMETERS:
p_purp TYPE C LENGTH 1.
DATA:
lt_tab TYPE STANDARD TABLE OF i_salesarea_dcl.
SELECT * FROM i_salesarea_dcl INTO TABLE @lt_tab
WHERE salesplanpurpose = @p_purp.
LOOP AT lt_tab ASSIGNING FIELD-SYMBOL(<fs_row>).
WRITE:/ <fs_row>-salesorganization, <fs_row>-distributionchannel, <fs_row>-division, <fs_row>-salesplanpurpose.
ENDLOOP.
WRITE:/ 'Finished.'.

The logic flow is that firstly we use SalesPlanUUID to get SalesPlanPurpose, then with SalesPlanPurpose we could get the Sales Area master data via the corresponding Authorization Objects.
SalesPlanPurpose: 0 (Incoming sales)

webp

SalesPlanPurpose: 1(Sales Volume)

webp

要获取更多Jerry的原创文章,请关注公众号"汪子熙":

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24475491/viewspace-2564239/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/24475491/viewspace-2564239/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值