ABAP predefined datatype

来源:互联网 发布:wps苹果mac版 编辑:程序博客网 时间:2024/05/22 08:18
TypeLengthStandard LengthNameb1 byte 1-byte integer (internal)s2 byte 2-byte integer (internal)i4 byte 4-byte integerp1 to 16 bytes8 bytePacked numberdecfloat168 byte Decimal floating point number with 16 decimal placesdecfloat3416 byte Decimal floating point number with 34 decimal placesf8 byte Binary floating point number with 17 decimal places

 

 

TypeValue RangeInitial Valueb0 to 2550s-32,768 to +32,7670i-2,147,483,648 to +2,147,483,6470pThe valid length for packed numbers is between 1 and 16 bytes; two decimal places are packed into one byte, whereby the last byte only contains one place and the plus/minus sign; after the decimal separator, up to 14decimal places are permitted. Depending on the field length len and the number of decimal places dec, the following applies for the value range: (-10^(2len -1) +1) / (10^(+dec)) to (+10^(2len -1) -1) /(10^(+dec)) in steps of 10^(-dec). Values in between this range are rounded; invalid contents result in undefined behavior.0decfloat16Decimal floating point numbers of this type are represented internally with 16 decimal places in accordance with the IEEE-754-2008 standard; valid values are numbers between 1E385(1E-16 - 1) and -1E-383 for the negative range, 0 and +1E-383 to 1E385(1 - 1E-16) for the positive range. Values lying between the ranges form the subnormal range and are rounded; outside of the subnormal range, each 16-digit decimal number can be represented precisely with such a decimal floating point number0decfloat34Decimal floating point numbers of this type are represented internally with 34 decimal places in accordance with the IEEE-754-2008 standard; valid values are numbers between 1E6145(1E-34 - 1) and -1E-6143 for the negative range, 0 and +1E-6143 and 1E6145(1 - 1E-34) for the positive range. Values lying between the ranges form the subnormal range and are rounded; outside of the subnormal range, each 34-digit decimal number can be represented precisely with such a decimal floating point number0fBinary floating point numbers are represented internally in accordance with the IEEE-754 standard (double precision); in ABAP, 17 decimal places are represented (one place before the decimal point and 16 places in the fractional part). Valid values are numbers between -1.7976931348623157E+308 and -2.2250738585072014E-308 for the negative range and between +2.2250738585072014E-308 and +1.7976931348623157E+308 for the positive range, plus 0. Both validity intervals are extended in the direction of zero using subnormal numbers in accordance with the IEEE-754 standard.0


Notes


The numeric data types are used for numeric calculations. Here, the data type f for binary floating point numbers isreplaced largely by the types decfloat16 and decfloat34 for decimal floating point numbers.
The types b and s are internal types and cannot be specified either statically or dynamically in ABAP statements. Self-defined data types and data objects in ABAP programs have the data types b or s if they have been defined with reference to data elements of the ABAP Dictionary that have the external data types INT1 or INT2.
The type p, for which a length interval is specified in the second column in the first table, isgeneric, which means that the length is not part of the type description. Also, thefractional portion is undefined as well as the length. The entry in the Standard Length column specifies the length used in declarations of data objects when using types with generic lengths, if no explicit length is specified in the relevant statement.
The system class CL_ABAP_MATH contains constants for the minimum and maximum values of most numeric types.
Since the decimal places of a floating point number of type f are represented internally as dual fractions, there is not an exact equivalent for every number that can be represented in the decimal system. This can lead to rounding errors in conversions and intermediate results of calculations. These errors can be avoided by using a two-step rounding procedure.
For data objects of data type p, the program attribute Fixed Point Arithmetic must be set so that the decimal separator is taken into account. Otherwise, in all operations, the content is handled as if there is no decimal separator. The sequence of digits in the variables of type p is interpreted as a whole number. Exceptions are:
Representation on screens
Formatting with WRITE [TO]
Conversions to character-like objects with the types c and string
For decimal floating point numbers, the ABAP runtime environment uses runtime modules of decNumber (c) Copyright IBM Corporation 2001, 2004. All rights reserved.
See also Numeric Data Types.

Example

According to the formula in the table, the value range of a packed number with length 2 and two decimal places is (-10^(2x2 -1) +1) / (10^2) to (+10^(2x2 -1) -1) / (10^2) and therefore =-9.99 to +9.99 in steps of 0.01. A value within this range, for example 1.428, is rounded up to 1.43.

DATA: pack   TYPE p LENGTH 2 DECIMALS 2,
      result TYPE REF TO data.
FIELD-SYMBOLS <result> TYPE ANY.
result = cl_abap_exceptional_values=>get_min_value( pack ).
IF result IS NOT INITIAL.
  ASSIGN result->* TO <result>.
  WRITE <result>.
ENDIF.
result = cl_abap_exceptional_values=>get_max_value( pack ).
IF result IS NOT INITIAL.
  ASSIGN result->* TO <result>.
  WRITE <result>.
ENDIF.


TypeLengthStandard LengthNamec1 to 262,143 characters1 charactersText FieldstringVariable Text stringn1 to 262,143 characters1 charactersNumeric text fieldd8 characters Character-like date fieldt6 characters Character-like time field


TypeValue RangeInitial ValuecAny alphanumeric characters" " for every positionstringAs for type cEmpty string with length 0nAny alphanumeric characters; only valid values are the digits 0 to 9, however"0" for every positiondAny eight alphanumeric characters; only those digits are valid, however, that are valid as dates according to the calendar rules in the format "yyyymmdd": "yyyy" (year): 0001 to 9999, "mm" (month): 01 to 12, "dd" (day): 01 to 31"00000000"tAny six alphanumeric characters; the only valid values are numbers that are valid as times in the 24-hour clock format "hhmmss". "hh" (hours): 00 to 23, "mm" (minutes): 00 bis 59, "ss" (seconds): 00 to 59."000000"


TypeDescriptionanyAny data typeany tableInternal table with any table typecText field with a generic lengthclikeCharacter-like (c, d, n, t, string, and character-like flat structures); in non-Unicode programs also x, xstring, and any flat structurescsequenceText-like (c, string)dataAny data typedecfloatDecimal floating point number (decfloat16, decfloat34)hashed tableHashed tableindex tableIndex tablenNumeric text with generic lengthnumericNumeric (i (b, s), p, decfloat16, decfloat34, f)objectAny object type (root class of the inheritance hierarchy)pPacked number with generic length and generic number of decimal placessimpleElementary data type including structured types with exclusively character-like flat componentssorted tableSorted tablestandard tableStandard tabletableStandard tablexByte field with generic lengthxsequenceByte-like (x, xstring)


0 0
原创粉丝点击