SAP DDICDDL DEFINE DYNAMIC CACHE



Get Example source ABAP code based on a different SAP table
  


• DEFINE DYNAMIC CACHE ABAP_DDIC_STATEMENT
• { } ABAP_DDIC_DEFINE_DYNCA

ABAP_DDIC_DDL - DEFINE DYNAMIC CACHE

ABAP_SYNTAX
DEFINE DYNAMIC CACHE cache_name
ON dbtab
{ projection_list }
$[WHERE filter_cond$]
$[SEGREGATE CACHE DATA BY filter_cond$]
$[CREATION CONFIGURABLE DEFAULT ${ON$|OFF$}$];

What does it do?
Dictionary DDL statement used to define a dynamic cache for a DDIC database table .
The name cache_name of a dynamic cache must comply with the naming conventions for DDIC data types and can have a maximum of 30 characters. The name is in the namespace of the DDIC data types and must match the name of the DTDC source code.
A dynamic cache can be defined for exactly one DDIC database table dbtab, which is specified after ON. Tables with data aging are not supported. Multiple dynamic caches can be defined for the same database table.

Projection List
The projection list projection_list of a dynamic cache consists of a restricted subquery which is applied to the DDIC database table to be tuned. It can consist of the following components:
Fields of dbtab can optionally be specified. ABAP_CAUTION Client fields must not be specified. Client handling takes place implicitly.
At least one aggregate function must be specified in the projection list. The following aggregate functions can be specified:
SUM(arg)
AVG(arg)
MIN(arg)
MAX(arg)
COUNT(arg)
COUNT(*)
The argument arg of the aggregate function can be a field of dbtab, an untyped numeric or character literal, an arithmetic expression, or a case expression. The arithmetic expression can, in turn, have fields or literals as operands. The case expression can have fields, literals, or arithmetic expressions as operands.

Clauses
In a WHERE filter condition filter_cond, the cache result can be restricted as follows:
lhs = rhs $[${AND $| OR$} lhs = rhs$]
It is possible to join multiple expressions using AND and OR .
lhs can be a field of dbtab.
rhs can be a field of dbtab or an untyped numeric or character literal.
The fields evaluated in the condition do not need to be defined as elements in the projection list.
Optionally, a further filter condition filter_cond can be added after SEGREGATE CACHE DATA BY to define which filtered results should be cached as follows:
lhs = rhs $[AND lhs = rhs$]
It is possible to join multiple expressions using AND.
lhs must be a field of dbtab.
rhs can be a character or numeric literal or a numbered placeholder $1, $2, ...
The fields evaluated in the condition must be defined as elements in the projection list.
CREATION CONFIGURABLE DEFAULT ${ON$|OFF$}: Optional addition to activate or deactivate the dynamic cache.
ON: the dynamic cache is created on SAP HANA as soon as the DDIC definition is activated.
OFF: creation of the dynamic cache on SAP HANA is deferred to a later point in time.
If this clause is not used, the default is ON.
If the dynamic cache is deactivated, the consumer can later on decide when the cache should be used. This configuration can be done with transaction S_DBCACHE_CONFIG.

ABAP_EXAMPLE_VX5
The following source code shows an example for a dynamic cache for the database table DEMO_DDIC_TYPES. DEFINE DYNAMIC CACHE demo_ddic_dynamic_cache
ON demo_ddic_types
{
int4,
sum( int8 )
}
WHERE int1 = 4
SEGREGATE CACHE DATA BY int4 = $1
CREATION CONFIGURABLE DEFAULT OFF;
This cache is generated as SQL view on the database. Client handling is added automatically.
IMAGE dynamic_cache.png 394 187
ABAP_EXAMPLE_END