Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Obsolete Language Elements →  Obsolete character string and byte string processing 

CONVERT - INVERTED-DATE

Short Reference

Other versions: 7.31 | 7.40 | 7.54

Obsolete Syntax

CONVERT { {DATE dat1 INTO INVERTED-DATE dat2}
        | {INVERTED-DATE dat1 INTO DATE dat2} }.

Effect

These variants of the CONVERT statement are not permitted in classes. They convert the numbers in a character-like data object in dat1 into their complement on nine (the difference to the number nine) and assign the result to the data object dat2. The data objects dat1 and dat2 must have a flat character-like data type with length 8. The same data object can be specified for dat2 as for dat1.


Notes

  • These forms of the CONVERT statement are not allowed in classes. They were previously used for sorting by date fields in internal tables and extracts for changing the sort direction. These have now been replaced by the ASCENDING and DESCENDING additions of the SORT statement. If necessary, the complement on nine can be formed using the following TRANSLATE statement:
dat2 = dat1.
TRANSLATE dat2 USING '09182736455463728190'.

Example

The following program section sorts the internal table sflight_tab in descending order by the fldate column.

DATA sflight_tab TYPE TABLE OF sflight. 

FIELD-SYMBOLS <sflight_wa> TYPE sflight. 

SELECT * FROM sflight INTO TABLE sflight_tab. 

LOOP AT sflight_tab ASSIGNING <sflight_wa>. 
  CONVERT DATE <sflight_wa>-fldate 
    INTO INVERTED-DATE <sflight_wa>-fldate. 
ENDLOOP. 

SORT sflight_tab BY fldate. 

LOOP AT sflight_tab ASSIGNING <sflight_wa>. 
  CONVERT INVERTED-DATE <sflight_wa>-fldate 
     INTO DATE <sflight_wa>-fldate. 
ENDLOOP.

The last nine lines can be replaced by a single line:

SORT sflight_tab BY fldate DESCENDING.

Exceptions


Non-Catchable Exceptions

  • Cause: Conversion not possible due to invalid field length
    Runtime Error: CONVERT_ILLEGAL_CONVERSION