A constant is the simplest type of operand used in C/AL. The value of a constant cannot be changed during the execution of the code. Constants can be defined for each of the simple data types in C/AL.
|Numbers such as 2,147,483,647 and 999,999,999,999,999.99 cannot be entered in the C/AL editor in this form that uses commas. The commas are only used to increase the legibility when describing large numbers. If you use commas when you enter numbers in the C/AL editor, a compilation error occurs.|
A Boolean constant can have either the value TRUE or FALSE.
An integer constant has a value in the range -2,147,483,647 to 2,147,483,647.
A decimal constant must contain a decimal point "." (depending on your regional settings) and have at least one digit to the right of the decimal point (for example, the digit "0"). A constant of type decimal can be used to represent decimal numbers between -999,999,999,999,999.99 and 999,999,999,999,999.99 with 18 significant digits.
A date constant is written as six or eight digits followed by the letter "D." The date constant expressing "undefined date" is entered as "0D." The digits specify the date in the format MMDDYY or MMDDYYYY.
A time constant is written as six or nine digits followed by the letter "T." The "undefined time" constant is entered as "0T." The nine digits specify the time in the format HHMMSS[.XXX], that is, a 24 hour format with an optional part specifying thousandths of a second.
A text constant is a character string. Unique IDs are assigned to text constants so that an ID number represents a specific text constant. Examples of text constants are error messages, messages, and warnings.
The following table shows examples of different types of C/AL constants.
|The format depends on the regional format that is set on your computer. The examples in the table correspond to a computer that has the regional format set to English (United States).|
Date constant (December 21, 2001)
Time constant (the time 14:12:30)