ABAPCONVERT_DATE - CONVERT DATE

rdisp/max_wprun_time - Maximum work process run time   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

CONVERT - INVERTED-DATE

Short Reference



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 numbersin a character-like data object dat1 into their complement on nine (the difference to the number nine) and assign the result to data object dat2. The data objects dat1 and dat2 must have aflatcharacter-like data type with length 8. You can specify the same data object for dat2 and dat1.

Notes

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

  • The variant of the CONVERT DATE statement shown in this example should not be confused with the CONVERT DATE statement for generating time stamps.


Example

When the following program section is run, 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 .
  CONVERT DATE -fldate
    INTO INVERTED-DATE -fldate.
ENDLOOP.

SORT sflight_tab BY fldate.

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

The last nine lines can be replaced with 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









Addresses (Business Address Services)   ABAP Short Reference  
This documentation is copyright by SAP AG.


Length: 3567 Date: 20120522 Time: 040934     triton ( 87 ms )