CONVERT - INVERTED-DATE

Short Reference

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-type 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-type data type with the length 8. You can specify the same data object for dat2 as for dat1

Note

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 to the SORT statement. If necessary, the complement on nine can be formed using the following TRANSLATE statement:

dat2 = dat1.

TRANSLATE dat2 USING '09182736455463728190'.

Example

After the following program section, the internal table sflight_tab is sorted in descending order according to 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 with a single line:

SORT sflight_tab BY fldate DESCENDING.

Exceptions

Non-Catchable Exceptions