Get Example source ABAP code based on a different SAP table
• IF ABAP_CDS_GRANT_SELECT • THEN ABAP_CDS_GRANT_SELECT • ELSE ABAP_CDS_GRANT_SELECT
ABAP_CDS_DCL - DEFINE ROLE>, if_then_else>
ABAP_SYNTAX ... IF ( condition ) THEN { condition } ELSE { condition } ... >
What does it do? The condition condition> in the IF> branch is evaluated in the application server. If the result is true>, the if_then_else> is replaced by the condition in the THEN> branch, otherwise by the condition in the ELSE> branch.
Latest notes:
The condition in the IF> branch must contain only left-side host expressions> (that is, it must not contain a reference to any elements of the CDS entity). Parentheses and logical operators are allowed.
The conditions in the THEN> and ELSE> branches can be any condition, including a nested if_then_else>.
The separation between the THEN> and the ELSE> branches occurs at runtime. At compile time, both branches must be syntactically valid. NON_V5_HINTS ABAP_HINT_END
ABAP_EXAMPLE_VX5 GRANT SELECT ON cds_entity WHERE IF ( ( $PARAMETERS.P1 = 'NEW' OR $PARAMETERS.P1 = 'MODERN' ) AND ( ) = ASPECT PFCG_AUTH( S_DEMO ) ) THEN { A_NEW = 1 AND ( B_NEW ) = ASPECT PFCG_AUTH( S_DEMO, F1 ) } ELSE { A_OLD = 1 AND ( B_OLD ) = ASPECT PFCG_AUTH( S_OLD, F1 ) };> This condition tests whether the actual value of the view parameter P1> is either NEW> or MODERN> and in addition whether the current user has any authorization for the authorization object S_DEMO>. If this condition is true, the access condition using the fields A_NEW> and B_NEW> applies, otherwise the one using A_OLD> and B_OLD> applies. ABAP_EXAMPLE_END