Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Processing External Data →  ABAP Database Access →  ABAP and SAP HANA 

Data Aging in SAP HANA

The data aging concept makes it possible to distinguish between current ("HOT") data and old ("COLD") data within SAP HANA database tables. Application programmers define which data is current or old in a special temperature column in the database table with the mandatory name _DATAAGING. The entries in this column partition the data in the database table and make it possible to archive obsolete data in a transparent way for application programmers. Only the data from the current partition is held in the working memory of the SAP HANA database. Partitions with old data, on the other hand, remain in persistent memory. This partitioning is performed in tasks called data aging runs.

By default, AS ABAP respects data aging by instructing the database interface to read only current data when a database table on the SAP HANA database is accessed implicitly, and to not read any old data. This also applies to access using AMDP. The way data aging is handled can be modified as follows:

  • The profile parameter abap/data_aging enables and disables data aging.
  • The classes CL_ABAP_SESSION_TEMPERATURE and CL_ABAP_STACK_TEMPERATURE can be used to override the current temperature of specific contexts in the current ABAP program and the database interface reads the data with this temperature if data aging is enabled.

If tables are not accessed using the AS ABAP database interface, such as when using non-ABAP-managed Native SQL, data aging is not respected.

If database tables have a _DATAAGING column (and hence the data aging concept applies) and data is accessed that does not have the current temperature, it is usually the case that all partitions must first be loaded into the main memory of the SAP HANA database. This can have a negative affect on performance. Dependency rules can be used to optimize access in such a way that only the required partitions are loaded.

Other versions: 7.31 | 7.40 | 7.54


Notes

  • Current and old data can be handled implicitly only on SAP HANA databases. On other databases, the database interface always reads all data. The value false for the annotation @DataAging.noAgingRestriction of a CDS entity is ignored here.

  • From a technical perspective, the database interface appends the addition WITH RANGE_RESTRICTION('CURRENT'); to every SQL statement, including calls of AMDP procedures and functions. For this reason, Native SQL statements should not be ended with a semicolon ; when using EXEC SQL or ADBC for the SAP HANA database.

  • Generally speaking, only current data is of interest for transactional applications, whereas analytical applications require access to old data too.

Example

The database table DAAG_SFLIGHT has a _DATAAGING column, which means that the data aging concept applies on a SAP HANA database. A data aging run partitions the data and only data where the _DATAAGING column contains the value '00000000’ is loaded into the working memory of the database. The database interface selects only this data by default. This is why the results set of the first SELECT statement is empty. The method SET_TEMPERATURE of the class CL_ABAP_SESSION_TEMPERATURE sets the temperature of the current internal session so that data from the whole of the past year is respected. If data like this exists, the results set of the second SELECT statement is not empty. For this to happen, data from additional partitions must be loaded into the working memory.

SELECT * 
       FROM daag_sflight 
       WHERE _dataaging <> '00000000' 
       INTO TABLE @DATA(result1). 
cl_demo_output=>write( result1 ). 

TRY. 
    cl_abap_session_temperature=>get_session_control( 
      )->set_temperature( im_temperature = CONV d( sy-datlo - 363 ) ). 
  CATCH cx_abap_session_temperature INTO DATA(exc). 
    cl_demo_output=>display( exc->get_text( ) ). 
    RETURN. 
ENDTRY. 

SELECT * 
       FROM daag_sflight 
       WHERE _dataaging <> '00000000' 
       INTO TABLE @DATA(result2). 
cl_demo_output=>display( result2 ).

This example is for demonstration purposes only. ABAP programs should never access the temperature column explicitly or read it.

Continue

Dependency Rules for Optimization of Access to Old Data