SAP CDS F1 DCL FUNCTION
Get Example source ABAP code based on a different SAP table
• SACF_CHECK_IN_USE ABAP_CDS_GRANT_SELECT
• OPTIONAL_ELEMENT_EXISTS ABAP_CDS_GRANT_SELECT
• SWITCH_RUNTIME_STATE ABAP_CDS_GRANT_SELECT
• TOGGLE_RUNTIME_STATE ABAP_CDS_GRANT_SELECT
• CONTEXT_NODE_EXISTS ABAP_CDS_GRANT_SELECT
ABAP_CDS_DCL -
ABAP_SYNTAX
IS $[NOT$] INITIAL $}
$| ${ OPTIONAL_ELEMENT_EXISTS( NAME => element )
IS $[NOT$] INITIAL $}
$| ${ SWITCH_RUNTIME_STATE( NAME => switch_name )
IS $[NOT$] INITIAL $}
$| ${ TOGGLE_RUNTIME_STATE( NAME => toggle_name )
IS $[NOT$] INITIAL $}
$| ${ CONTEXT_NODE_EXISTS(...)
IS $[NOT$] INITIAL $} ...>
ABAP_VARIANTS:
1
2
3
4
5
What does it do?
DCL functions are evaluated in the ABAP application server before the
They evaluate to either logical
Latest notes:
The effect of the DCL function applies at runtime only. Syntactical correctness of the access control must be always given.
For example, in a condition like
NON_V5_HINTS
ABAP_HINT_END
ABAP_VARIANT_1
What does it do?
Using this DCL function, the state of switchable authorization checks can be queried and used in an access control to enable or disable condition blocks.
The function behaves like the ABAP method
ABAP_EXAMPLE_VX5
WHERE
SACF_CHECK_IN_USE (NAME => NEW_AUTH_SWITCH ) IS INITIAL
AND
( element ) = ASPECT PFCG_AUTH( OLD_AUTH, F )
OR
SACF_CHECK_IN_USE( NAME => NEW_AUTH_SWITCH ) IS NOT INITIAL
AND
( element ) = ASPECT PFCG_AUTH( NEW_AUTH, F );>
This access control realizes a migration from an old authorization object
ABAP_EXAMPLE_END
Latest notes:
When you only need to introduce new authorization objects without the need to instantly disable the evaluation of a predecessor, the regular syntax addition to PFCG conditions is preferred:
NON_V5_HINTS
ABAP_HINT_END
ABAP_VARIANT_2
What does it do?
With this DCL function, existence of the given CDS element in the protected entity can be queried at runtime. Based on the outcome of the check, larger condition blocks in the access control can then be enabled or disabled.
It is an extension to the concept of optional elements ( ABAP Addition ELEMENTS>>) and allows application not only for newly introduced elements, but also for replacement scenarios in which an element is semantically replaced by another element.
Latest notes:
NON_V5_HINTS
ABAP_HINT_END
ABAP_EXAMPLE_VX5
WITH OPTIONAL ELEMENTS (itemState DEFAULT FALSE )
WHERE
OPTIONAL_ELEMENT_EXISTS( NAME => itemState ) IS INITIAL
AND
toItem.state = 'A'
OR
OPTIONAL_ELEMENT_EXISTS( NAME => itemState ) IS NOT INITIAL
AND
itemState = 'A';>
This access control formerly realized access control using an association.
To increase the selection performance, this association should be replaced by a replica of the used element in the protected entity itself (
As this element is not instantly available in CDS entities which inherit their access conditions from this entity, the new element is introduced as optional element (the default value
As soon as the new element becomes available, it should be used instead and the former one no longer be used at all (to avoid performance degradation due to join evaluation).
ABAP_EXAMPLE_END
ABAP_VARIANT_3
What does it do?
This function retrieves the runtime state of a switch in the
Latest notes:
NON_V5_HINTS
ABAP_HINT_END
ABAP_EXAMPLE_VX5
WHERE
IF
( SWITCH_RUNTIME_STATE( NAME => SWITCH_NAME ) IS NOT INITIAL )
THEN
{ STATE1 = 'A' }
ELSE
{ STATE2 = 'A' };>
If the switch with the name
ABAP_EXAMPLE_END
ABAP_VARIANT_4
What does it do?
This function behaves like
The rationale for using two different functions is the best practice that feature toggles should exist only temporarily until the feature they guard becomes a core feature, while switches of other types are long-lived.
The dedicated function allows the reader of the access control to immediately recognize that the content is ephemeral.
ABAP_VARIANT_5
What does it do?
This function is reserved for use by SAP.
BEGIN_SECTION SAP_ONLY See
END_SECTION SAP_ONLY