Annotation @Environment.systemField

The below view declares two argument langauge and system user. The view is used to retrieve product id with description via inner join.

@AbapCatalog.sqlViewName: 'zprdtext'
@AbapCatalog.compiler.compareFilter: true
@AccessControl.authorizationCheck: #CHECK
@EndUserText.label: 'Jerry product description'
define view Zproductdescription
with parameters
    @Consumption.hidden: true
    @Environment.systemField: #SYSTEM_LANGUAGE
    P_Language              : syLangu,

    @Consumption.hidden: true
    @Environment.systemField : #USER
    p_uname : syst_uname  


as select from comm_product as product inner join comm_prshtext as _text
on product.product_guid = _text.product_guid {
   key product.product_id,
   product.product_type,
   _text.short_text as description
} where product.upname = :p_uname and _text.langu = :p_Language

When we locally preview the view, we are asked to provide the value for these two argument.

In productive use, it is this @Environment.systemField annotation which takes effect. In open SQL we do not need to explicitly pass value to these two parameters. See following ABAP code: all products created by Jerry are fetched, although no parameter for user name is passed.

data: lt_result TYPE TABLE OF Zproductdescription.

SELECT * FROM Zproductdescription INTO TABLE @lt_result .

You can verify via ST05 that ABAP runtime automatically fills these two parameter for you:

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券