Ansicht
Dokumentation

ABENCDS_F1_COND_ASPECT - CDS F1 COND ASPECT

ABENCDS_F1_COND_ASPECT - CDS F1 COND ASPECT

BAL_S_LOG - Application Log: Log header data   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

- DEFINE ROLE, aspect_condition

... (element1 $[, element2, ...$] ) = ASPECT aspect
      $[FILTER BY ( aspect filter )$] ...


Addition:

... FILTER BY

Effect

Aspect condition as part of an access condition cds_cond in an access rule of the statement DEFINE ROLE in CDS DCL. An aspect condition specifies the self-defined aspect aspect defined in an aspect definition in the right side introduced by ASPECT.

In parentheses, the left side contains the ordered list of entity elements that match the output fields of the self-defined aspect.

Left-side host expressions are not supported in this language element. The only comparison operator allowed is the equality operator =.

When any of the left side elements of an aspect condition is declared as optional with default FALSE and missing at runtime, the entire aspect is handled as logically false.

Missing optional elements with default TRUE are removed from the link condition between the aspect entity and the protected entity. This process may apply to all left side elements, in which case the aspect condition reduces to a mere existence check of any row in the aspect entity for the current user.

Addition

...FILTER BY

When the aspect definition declares at least one filter element (see DEFINE ASPECT), you can use this addition to specify an additional selection condition for the rows of the aspect entity, before the result set is used to filter the rows of the protected entity.

The condition can use the declared aspect filters, literals, session variables and parameters of the protected entity, but you cannot refer to elements of the protected entity.

The aspect filter supports logical expressions and brackets.

Example

You have an aspect entity with the following content, where NULL denotes a null value:

USERNAME COSTCENTER STATE
A 1 U
A 2 V
A 3 NULL
B 1 V
B 2 U

In the aspect definition, you specify USERNAME as the user element, COSTCENTER as the output element, and STATE as the filter element:

DEFINE ASPECT DEMO_ASPECT AS SELECT FROM ...
  WITH USER ELEMENT USERNAME
  WITH FILTER ELEMENTS ( STATE )
  ${ COSTCENTER $}

In an access role you filter the protected entity based on column "CostCenter" using the self-defined aspect.

GRANT SELECT ON ... WHERE (CostCenter) = ASPECT DEMO_ASPECT;

With this condition, for user A the cost centers 1, 2 and 3 will be returned.

When only the cost centers with state U or NULL should be considered, you can filter the aspect rows:

GRANT SELECT ON ... WHERE (CostCenter) = ASPECT DEMO_ASPECT FILER BY( STATE = 'U' OR STATE IS NULL );

For user A, this condition will return cost center 1 and 3, while for user B, cost center 2 would be returned.






General Material Data   RFUMSV00 - Advance Return for Tax on Sales/Purchases  
This documentation is copyright by SAP AG.

Length: 7103 Date: 20240423 Time: 102723     sap01-206 ( 67 ms )