SAP CONVERSION TYPE D



Get Example source ABAP code based on a different SAP table
  



Source Field Type d
The conversion rules are designed in such a way that when data objects of the date type d are assigned to character-like data objects they behave like character-like objects and numerically in assignments to numeric data objects. The latter is the basis for date calculations in arithmetic expressions.
Only dates in the format yyyymmdd are valid for data objects of type d where 00010101 is the first valid value. The conversion rules, however, also allow the assignment of date fields that contain invalid data. The latter is not recommended.
ITOC

Numeric Target Fields TargetConversion i, int8, (b, s)If the source field contains a valid date in the format yyyymmdd, it is used to calculate the number of days since 01.01.0001, and this value is then converted to the internal representation of the corresponding integer. If the source field contains an invalid date, the target field is assigned the value 0. If the value range for the internal data types b and s is insufficient, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. pIf the source field contains a valid date in the format yyyymmdd, it is used to calculate the number of days since 01.01.0001, and this value is then converted to the internal representation of a packed number. If the value range of the target field is too small, the catchable exception CX_SY_CONVERSION_OVERFLOW is raised. If the source field contains an invalid date, the target field is assigned the value 0. decfloat16, decfloat34If the source field contains a valid date in the format yyyymmdd, it is used to calculate the number of days since 01.01.0001, and this value is then converted to the internal representation of a decimal floating point number with a scaling of 0. If the source field contains an invalid date, the target field is assigned the value 0. fIf the source field contains a valid date in the format yyyymmdd, it is used to calculate the number of days since 01.01.0001, and this value is then converted to the internal representation of a binary floating point number. If the source field contains an invalid date, the target field is assigned the value 0.



Latest notes:

The conversion of a date into the number of days since 01.01.001 is designed in such a way that the transition from the Julian to Gregorian calendar is respected: 4.10.1582 results in 577,736 and 15.10.1582 in 577,737. Converting the dates for the nonexistent days between 5.10.1582 and 14.10.1582 produces the same result as converting the existing days from 15.10.1582 to 24.10.1582.
The assignment of the values 00000000 and 00010101 to a numeric type produces the value 0 in each case. The assignment of the value 0 to a date field produces 00000000. This means that the assignment of the value 00010101 to a numeric type is not reversible.
NON_V5_HINTS
ABAP_HINT_END

ABAP_EXAMPLE_VX5
The result of the following conversion has the value 736341. This is the number of days of the specified date since 01.01.0001.
ABEXA 00924
ABAP_EXAMPLE_END

Character-Like Target Fields TargetConversion cThe content is handled in the same way as a source field of type c nThe characters in the source field are passed left-aligned to the target field. Trailing blanks in the source field are passed. If the target field is longer than the source field, it is padded on the right with the character 0. If the target field is shorter, it is truncated on the right. stringThe content is handled in the same way as a source field of type c

ABAP_EXAMPLE_VX5
The string resulting from the conversion is 2017. Four characters 0111 are cut off on the right.
ABEXA 00925
ABAP_EXAMPLE_END

Byte-Like Target Fields TargetConversion xThe content of the source field is first converted to data type i (see above) and then to type x (see conversion table for source field type i, int8, (b, s)). xstringThe content of the source field is first converted to data type i (see above) and then to type xstring (see conversion table for source field type i, int8, (b, s)).

ABAP_EXAMPLE_VX5
The byte chain resulting from the conversion is 0B3C55. This is the integer 736341 or the number of days since 01.01.0001.
ABEXA 00926
ABAP_EXAMPLE_END

Date/Time Fields as Target Fields TargetConversion dThe content of the source field is passed unconverted. tNot supported. Produces a syntax error or runtime error. utclongNot supported. Produces a syntax error or raises the exception CX_SY_CONVERSION_NOT_SUPPORTED.

ABAP_EXAMPLE_VX5
The conversion of d to t, which is not known statically, is not supported and produces the runtime error MOVE_NOT_SUPPORTED .
ABEXA 00927
ABAP_EXAMPLE_END