Get the App
SLTechnology News&Howtos  ›  Database  › 

Parsing CDS view annotations-@ Environment.systemField

Shulou Source: shulou.com Published: 2022-06-01 06:42:05 10月14日 Update

The following CDS view uses the annotation @ Environment.systemField, defining two parameters # SYSTEM_LANGUAGE and # USER.

This view reads the product description information from the product header table COMM_PRODUCT of the CRM material master data, product_id, product_type, and comm_prshtext, which is stored in the field description.

AbapCatalog.sqlViewName: 'zprdtext' @ AbapCatalog.compiler.compareFilter: true @ AccessControl.authorizationCheck: # CHECK @ EndUserText.label:' Jerry productdescription '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 preview the view in ABAP Development Studio, we are asked to specify values for these two parameters:

In Open SQL, these two parameters are automatically assigned the values of the system variables sy-langu and sy-uname in the ABAP programming language, respectively.

Data: lt_result TYPE TABLE OF Zproductdescription. SELECT * FROM Zproductdescription INTO TABLE @ lt_result.

This can be confirmed in the trace obtained by using the transaction code ST05: at run time, P_LANGUAGE is assigned the value E of sy-langu, and P_UNAME is assigned the value WANGJER of sy-uname.

For more original Jerry technical articles, please follow the official account "Wang Zixi" or scan the following QR code:

Tags: Two parameters products annotations transactions information public variables available through fields technology technical articles data articles more materials systems programming languages tables languages Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno macOS Apple Huawei Microsoft Docker