The ABAP runtime maintains various system fields that hold information of general interest, the system date and time, the logon client and language, the user name of the current user, and so on.
When you want to use the values of these system fields in CDS entities, you have 2 options:
1. Session variable.
Inside an ABAP CDS view entity, you can use session variables to access the value of ABAP system fields. Access to a session variable starts with prefix $session., followed by the variable name.
2. Input parameter with annotation @Environment.systemField
If a parameter is annotated like this, the ABAP runtime will automatically supply the parameter with the value of the related system field, in case the consumer provides no other value.
Note:
Session variables only contain values if the reading request comes from an ABAP system. In any other situation, the values of session variables are undefined! That is why you should prefer input parameters to access ABAP system fields.
Please share with your ABAP friends and follow us.
If you want to dive deeper, visit our course https://lnkd.in/daTqKQFV
댓글