SAP® Documentation

Single view

ABAPCONSTANTS - CONSTANTS

BAL Application Log Documentation   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.
SAP E-Book

CONSTANTS

Short Reference



Syntax

CONSTANTS const $[options$].

Effect

This statement declares a constant data object, const for short. The content of a constant cannot be changed at runtime of an ABAP program. It can only be used as an operand in reader positions of ABAP statements. Constants declared in the declaration part of a class or an interface are static attributes of that class or interface.

The naming conventions apply to the name const. The syntax of the additions options of the statement CONSTANTS for declaring constants matches the statement DATA for declaring variables. Only the additions READ-ONLY and BOXED
plus declarations of LOB handle structures are not possible. The statement INCLUDE cannot be used within the declaration of a structure.

Unlike the statement DATA, an initial value with the addition VALUE must be specified when using the statement CONSTANTS. The same restrictions as for DATA apply. This has the following implications for the declaration of constants with deep data types:

  • A start value val can be specified for the ABAP types string and xstring only.

  • Constant internal tables, reference variables, and structures with components that are not just character-like and flat can be assigned their initial value by IS INITIAL only, and are therefore always initial.


Notes

  • If the class component selector is used, the interface name can also be used to access static attributes of interfaces declared using CONSTANTS.
  • Constants are stored in the PXA and are available to all programs.


Example

The statements below declare a numeric constant, a constant structure, and a constant reference. The reference can be used in comparisons, for example, or passed to procedures.

CONSTANTS pi TYPE p LENGTH 8 DECIMALS 14
             VALUE '3.14159265358979'.

CONSTANTS: BEGIN OF sap_ag,
             zip_code TYPE n LENGTH 5 VALUE '69189',
             city     TYPE string VALUE `Walldorf`,
             country  TYPE string VALUE `Germany`,
           END OF sap_ag.

CONSTANTS null_pointer TYPE REF TO object VALUE IS INITIAL.






BAL Application Log Documentation   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.

Length: 4577 Date: 20200126 Time: 033448     sap01-206 ( 32 ms )

Our Service

Looking for Support? Questions?

The

Consolut

Callback-Service

Leave us your contact details and we will call you back. Panels marked with * are mandatory.