Open all | Close all
|
Formatting a date field
The following ABAP code demonstrates a number of ways to format a SAP date value:
|
* Using the WRITE statement
***************************
data: gd_date(10). "field to store output date
* Converts SAP date from 20020901 to 01.09.2002
write sy-datum to gd_date dd/mm/yyyy.
* Converts SAP date from 20020901 to 01.09.02
write sy-datum to gd_date dd/mm/yy.
|
* Using data manipulation techniques
************************************
data: gd_date(8). "field to store output date
* Converts SAP date from 20010901 to 01092001
gd_date(2) = sy-datum+6(2).
gd_date+2(2) = sy-datum+4(2).
gd_date+4(4) = sy-datum(4).
|
* Using Function modules
************************
data: gd_date(8). "field to store output date
* Converts date from 20010901 to 01SEP2001
gd_date = sy-datum.
CALL FUNCTION 'CONVERSION_EXIT_IDATE_OUTPUT'
EXPORTING
input = gd_date
IMPORTING
OUTPUT = gd_date.
|
|
|