天天看點

Annotation @Environment.systemField

@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,

   @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.

Annotation @Environment.systemField

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 .

Annotation @Environment.systemField

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

Annotation @Environment.systemField