SAP CDS SERIES GENERATORS



Get Example source ABAP code based on a different SAP table
  


• SERIES_GENERATE_DATE ABAP_SYSTEM_CDS
• SERIES_GENERATE_INTEGER ABAP_SYSTEM_CDS
• SERIES_GENERATE_TIME ABAP_SYSTEM_CDS
• SERIES_GENERATE_TIMESTAMP ABAP_SYSTEM_CDS

SERIES_GENERATE_, Series Generators
Series generators are a set of CDS system table functions that create a series table. This table contains a series of numbers, dates, times, or time stamps.
ITOC



Latest notes:

NON_V5_HINTS
In AB_SQL , usage of an series generator enforces ABAP_STRICT_784 strict mode from ABAP_RELEASE ABAP_784 / .
ABAP_HINT_END

Common Parameters and Result
All series generators have the following mandatory parameters: ParameterDetails
step Number that defines the increment value for the series to be generated, for example, numbers, seconds or days depending on the table function used. lbr lbr step is of type INT4. It must be greater than 0. If step is greater than the difference of the parameters to_value and from_value, the result is an initial table.
from_value Start value of the series. The type depends on the series generator used.
to_value Final value of the series. The value is not included as value in the generated_period_end field in the generated table since the series ends with the step before the to_value is reached. The data type of to_value depends on the table function used.
The generated result tables have the following fields: FieldDetails
generated_period_start Start value of a generated period of the series. The value of generated_period_end becomes the new value for generated_period_start of the next period.
generated_period_end Final value of a generated period of the series. The defined parameter to_value is not included in the table.
element_number Number of the period. It is consecutively numbered, starting with 1, in integer steps.
fraction_of_min_max_range The calculated value of ( generated_period_end - generated_period_start ) / ( to_value - from_value ).

SERIES_GENERATE_DATE
The CDS table function SERIES_GENERATE_DATE creates a table with a series of dates. The following types are used:
Parameters:
step: INT4
from_value: DATN
to_value: DATN
The table is of type SERIES_GENERATE_DATE and has the following fields:
generated_period_start: DATN
generated_period_end: DATN
element_number: INT8
fraction_of_min_max_range: FLTP

ABAP_EXAMPLE_VX5
The following source code demonstrates the creation of a series of dates using the CDS system entity SERIES_GENERATE_DATE.
ABEXA 01608
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The following CDS view entity demonstrates the creation of a series of dates using the CDS system entity SERIES_GENERATE_DATE.
DDLS DEMO_CDS_SERIES_GENERATOR_DATE
The class CL_DEMO_CDS_SERIES_GNRTR_DATE accesses the CDS view entity with a simple SELECT * statement and generates a screen output of the result.
ABAP_EXAMPLE_END

SERIES_GENERATE_INTEGER
The CDS system entity SERIES_GENERATE_INTEGER creates a table with a series of numbers. The following types are used:
Parameters:
step: INT4
from_value: INT4
to_value: INT4
The table is of type SERIES_GENERATE_ INTEGER and has the following fields:
generated_period_start: INT4
generated_period_end: INT4
element_number: INT8
fraction_of_min_max_range: FLTP

ABAP_EXAMPLE_VX5
The following source code demonstrates the creation of a series of numbers using the CDS system entity SERIES_GENERATE_INTEGER .
ABEXA 01609
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The following CDS view entity demonstrates the creation of a series of numbers using the CDS system entity SERIES_GENERATE_INTEGER.
DDLS DEMO_CDS_SERIES_GENERATOR
The class CL_DEMO_CDS_SERIES_GENERATOR accesses the CDS view entity with a simple SELECT * statement and generates a screen output of the result.
ABAP_EXAMPLE_END

SERIES_GENERATE_TIME
The CDS system entity SERIES_GENERATE_TIME creates a table with a series of times. The following types are used:
Parameters:
step: INT4
from_value: TIMN
to_value: TIMN
The table is of type SERIES_GENERATE_TIME and has the following fields:
generated_period_start: TIMN
generated_period_end: TIMN
element_number: INT8
fraction_of_min_max_range: FLTP

ABAP_EXAMPLE_VX5
The following source code demonstrates the creation of a series of times using the CDS system entity SERIES_GENERATE_TIME.
ABEXA 01610
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The following CDS view entity demonstrates the creation of a series of times using the CDS system entity SERIES_GENERATE_TIME.
DDLS DEMO_CDS_SERIES_GENERATOR_TIME
The class CL_DEMO_CDS_SERIES_GNRTR_TIME accesses the CDS view entity with a simple SELECT * statement and generates a screen output of the result.
ABAP_EXAMPLE_END

SERIES_GENERATE_TIMESTAMP
The CDS table function SERIES_GENERATE_TIMESTAMP creates a table with a series of time stamps. The following types are used:
Parameters:
step: INT4
from_value: UTCLONG
to_value: UTCLONG
The table is of type SERIES_GENERATE_ TIMESTAMP and has the following fields:
generated_period_start: UTCLONG
generated_period_end: UTCLONG
element_number: INT8
fraction_of_min_max_range: FLTP

ABAP_EXAMPLE_VX5
The following source code demonstrates the creation of a series of time stamps using the CDS system entity SERIES_GENERATE_TIMESTAMP .
ABEXA 01611
ABAP_EXAMPLE_END

ABAP_EXAMPLE_VX5
The following CDS view entity demonstrates the creation of a series of time stamps using the CDS system entity SERIES_GENERATE_TIMESTAMP .
DDLS DEMO_CDS_SERIES_GENERATOR_TS
The class CL_DEMO_CDS_SERIES_GNRTR_TS accesses the CDS view entity with a simple SELECT * statement and generates a screen output of the result.
ABAP_EXAMPLE_END



Runtime Exceptions



Catchable Exceptions
CX_SY_OPEN_SQL_DB
Reason for error:
Increment value must be a positive value.
Runtime error:
DBSQL_SQL_ERROR