CONVERT
Variants
1. CONVERT DATE f1 INTO INVERTED-DATE f2.
2. CONVERT INVERTED-DATE f1 INTO DATE f2.
Effect
Allows conversion between different formats which do not
have their own type (see also MOVE ).
The field f1 is converted from the source format to the target
format and placed in f2 .
At present, the following formats are supported:
DATE ==> INVERTED-DATE
INVERTED-DATE ==> DATE
Both formats form the nine's complement of internal date
representation, e.g. 19950511 ==> 80049488 or 80049488 ==>
19950511. In inverse date format, the most recent date has the lowest
numerical value. This is useful when sorting date specifications.
Note
The technique of modifying the sequence of dates by
inverting the internal date format is only used in very rare cases. For
example, you can sort internal tables in ascending or descending date
order much more elegantly with the additons ... ASCENDING bzw.
... DESCENDING of the SORT
statement.
Example
-
DATA DATE_INV LIKE SY-DATUM.
CONVERT DATE SY-DATUM INTO INVERTED-DATE DATE_INV.
If, for example, the internal representation of 11.05.95 in
SY-DATUM is 19950511, the value of DATE_INV after
execution of the CONVERT statement is 80049488.
Note
Runtime errors
-
CONVERT_ILLEGAL_CONVERSION : Conversion not possible due to
incorrect field length.
Index
© SAP AG 1996