SAP CDS DCL CNV VARIANTS



Get Example source ABAP code based on a different SAP table
  


SAP_ONLY

ABAP_CDS_DCL - CONTEXT_NODE_VALUES, Use

ABAP_SYNTAX
${ context_node_values operator $['$]value$['$] ...
$| ${ context_node_values $[NOT$] BETWEEN $['$]value1$['$] AND $['$]value2$['$] $}
$| ${ context_node_values $[NOT$] LIKE 'value' $[ESCAPE 'esc'$] $}
$| ${ context_node_values IS $[NOT$] NULL $} $}
$| ${ context_node_values IS $[NOT$] INITIAL $} ...
$| ${ ( [...,] context_node_values [,...] ) = ASPECT pfcg_auth( ... ) $}

ABAP_VARIANTS:
1 context_node_values operator [']value[']
2 context_node_values $[NOT$] BETWEEN $['$]value1$['$] AND $['$] $['$]value2$['$]
3 context_node_values $[NOT$] LIKE 'value' $[ESCAPE 'esc'$]
4 context_node_values IS $[NOT$] NULL
5 context_node_values IS $[NOT$] INITIAL
6 ( [...,] context_node_values [,...] ) = ASPECT pfcg_auth( ... )

What does it do?
This topic describes all possible relational expressions that can be used to query the DCL function CONTEXT_NODE_VALUES in a left-side host expression.
Node values context_node_values are expanded using the DCL function CONTEXT_NODE_VALUES .

ABAP_VARIANT_1 context_node_values operator [']value[']

What does it do?
This condition is true if any (or all, depending on the optional keyword parameter quantifier) of the context node values satisfy the literal condition on the right side.



Latest notes:

If the context node does not exist or has no values, the conditions evaluate to FALSE.
This type of FALSE can be inverted with the NOT operator. It does not behave like a null value on the database.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_2 context_node_values $[NOT$] BETWEEN $['$]value1$['$] AND $['$] $['$]value2$['$]

What does it do?
This condition is true if any (or all, depending on the optional keyword parameter quantifier) of the context node values satisfy the literal condition on the right side.



Latest notes:

If the context node does not exist or has no values, the conditions evaluate to FALSE.
This type of FALSE can be inverted with the NOT operator. It does not behave like a null value on the database.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_3 context_node_values $[NOT$] LIKE 'value' $[ESCAPE 'esc'$]

What does it do?
This condition is true if any (or all, depending on the optional keyword parameter quantifier) of the context node values satisfy the literal condition on the right side.



Latest notes:

If the context node does not exist or has no values, the conditions evaluate to FALSE.
This type of FALSE can be inverted with the NOT operator. It does not behave like a null value on the database.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_4 context_node_values IS $[NOT$] NULL

What does it do?
If the context node addressed in the function does not exist, or if it exists but has no values, IS NULL returns TRUE and IS NOT NULL returns FALSE.



Latest notes:

If you need to distinguish between non-existent and empty cases, you can use the DCL function CONTEXT_NODE_EXISTS, which tests for the existence of the node and does not take values into account.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_5 context_node_values IS $[NOT$] INITIAL

What does it do?
This condition tests the context node values for initiality. IS INITIAL evaluates to TRUE if any (or all) values have the initial value , while IS NOT INITIAL evaluates to TRUE if any (or all) values have the non-initial value.



Latest notes:

You cannot use this operator to find out whether a node has values or not. Use IS $[NOT$] NULL for that purpose.
If a node has no values or does not exist, querying the node with IS INITIAL returns FALSE, and IS NOT INITIAL also (!) returns FALSE.
NON_V5_HINTS
ABAP_HINT_END

ABAP_VARIANT_6 ( [...,] context_node_values [,...] ) = ASPECT pfcg_auth( ... )

What does it do?
When used within a pfcg_condition, the values provided by the DCL function act as an additional filter for the authorizations of the user which are considered by the PFCG condition for further processing.
The DCL function can be used more than once, and it can be mixed with entity elements.
For each authorization and each usage of context_node_values, the values provided by the function as left-side host expressions are tested against the PFCG authorization values of that authorization for the authorization field on the right side corresponding to the position of the function on the left side.
Depending on the quantifier parameter of the DCL function, either some or all of the context values must pass the test against the authorization values:
If the test fails for any use of the DCL function in the condition, the actually processed authorization is discarded as a whole, and if all authorizations are discarded, the entire condition returns FALSE.
Otherwise, the remaining authorizations are used to construct the condition that is used to filter access to the database.



Latest notes:

A full authorization from PFCG for a particular field in a particular authorization always passes the test against the DCL function, even if the context node does not exist or contains no values.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLES
The following examples each present a condition with CONTEXT_NODE_VALUES and describe the result of this condition in the access rule.
The example conditions omit the parameters container or namespace.
Example 1
CONTEXT_NODE_VALUES( NODEPATH => A ) = 'X' Values in node AResult
Node does not existFALSE
NoneFALSE
[ X ]TRUE
[ X, Y ]TRUE
[ Z ]FALSE
Example 2
CONTEXT_NODE_VALUES( NODEPATH => A, QUANTIFIER => ALL ) LIKE 'X%' Values in node AResult
Node does not existFALSE
NoneFALSE
[ X1 ]TRUE
[ X1, X2 ]TRUE
[ X1, Y ]FALSE
[ Z ]FALSE
Example 3
CONTEXT_NODE_VALUES( NODEPATH => A ) IS NULL Values in node AResult
Node does not existTRUE
NoneTRUE
[ X ]FALSE
[ X, Y ]FALSE
[ initial value ]FALSE
Example 4
CONTEXT_NODE_VALUES( NODEPATH => A ) IS INITIAL Values in node AResult
Node does not existFALSE
NoneFALSE (!)
[ X ]FALSE
[ initial value ]TRUE
[ X, initial value ]TRUE
ABAP_NOTE With quantifier => ALL, the last result is FALSE .
Example 5
( CONTEXT_NODE_VALUES( NODEPATH => A ) ) = ASPECT PFGC_AUTH( OBJ, F ) Values in node A Authorizations of User for authorization object OBJResult
Not significant Authorization 1 lbr F: * (full authorization) TRUE
Node does not exist lbr Node has no values No authorization exists with full authorization for field F FALSE
[ X ]Authorization 1 lbr F: XTRUE
[ X, Y ]Authorization 1 lbr F: XTRUE
[ X ]Authorization 1 lbr F: X lbr Authorization 2 lbr F: Y TRUE
Example 6
( CONTEXT_NODE_VALUES( NODEPATH => A, QUANTIFIER => ALL ) ) = ASPECT PFGC_AUTH( OBJ, F ) Values in node A Authorizations of User for OBJ Result
Not significant Authorization 1 lbr F: * TRUE
Node does not exist lbr Node has no values No authorization exists with full authorization for field F FALSE
[ X ]Authorization 1 lbr F: XTRUE
[ X, Y ]Authorization 1 lbr F: X lbr F: Y TRUE
[ X, Y ]Authorization 1 lbr F: X lbr Authorization 2 lbr F: Y FALSE
Example 7
( CONTEXT_NODE_VALUES( NODEPATH => A ),
CONTEXT_NODE_VALUES( NODEPATH => B, QUANTIFIER => ALL ) ) =
ASPECT PFGC_AUTH( OBJ, FA, FB ) Values in node A Values in node B Authorizations of User for OBJResult
[ X ][ X ]Authorization 1 lbr FA: X lbr FB: X TRUE
[ X ][ X ]Authorization 1 lbr FA: X lbr FB: Y lbr Authorization 2 lbr FA: Y lbr FB: X FALSE
[ X ]NoneAuthorization 1 lbr FA: X lbr FB : * TRUE
NoneNoneAuthorization 1 lbr FA: * lbr FB: * TRUE
Example 8
( CONTEXT_NODE_VALUES( NODEPATH => A ), B ) = ASPECT PFGC_AUTH( OBJ, FA,FB ) Values in node A Authorizations of User for OBJ Result
[ X ]Authorization 1 lbr FA: X lbr FB: U lbr Authorization 2 lbr FA: Y lbr FB: V B = 'U'
[ X ]Authorization 1 lbr FA: X lbr FB: U lbr Authorization 2 lbr FA: X lbr FB: V B = 'U' OR B = 'V'
NoneAuthorization 1 lbr FA: * lbr FB: U B = 'U'
NoneAuthorization 1 lbr FA: X lbr FB: U FALSE
[ X ]Authorization 1 lbr FA: Y lbr FB: U FALSE
ABAP_EXAMPLE_END