ABAPCONVERT_DATE_TIME-STAMP - CONVERT DATE TIME-STAMP

BAL Application Log Documentation   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

CONVERT DATE

Syntax

CONVERT DATE dat [TIME tim [DAYLIGHT SAVING TIME dst]]
        INTO TIME STAMP time_stamp TIME ZONE tz.

Short Reference



Addition:

... DAYLIGHT SAVING TIME dst

Effect

This statement interprets a date specified in dat, a time specified in tim, and a daylightsaving time selection specified in dst as the local date and time for the time zone specified in tz. It then converts this to theUTC reference time, and assigns the result to the time_stamp variable as atime stamp. dat and tim arefunctional operand positions.

For dat and tim, operands of data type d or t are expected. Operands ofother types are converted to d or t. If the TIME addition is not specified, the system implicitly uses the initial time "000000" for tim. If dat or tim containinvalidvalues, time_stamp is not changed and sy-subrc is set to 12. In tim, only the values 00 to 23 for the hours, and 00 to 59 for the minutes are valid.

tz must be declared as an operand of type TIMEZONE from ABAP Dictionary. This data object must contain a time zone from the TZONE column of the database tableTTZZ in uppercase letters. tz is also afunctionaloperand position. If tz is initial, the time specified in dat and tim is adoptedas the UTC reference time and sy-subrc is set to 4. If the specified time zone is not found in the database table TTZZ, time_stamp remains unchanged and sy-subrc is set to 8. If therule set for the specified time zone is incomplete, an exception that cannot be handled is raised.

The data object time_stamp must have either the data typeTIMESTAMP orTIMESTAMPL from the ABAP Dictionary corresponding to ABAP type p of length 8 or p of length 11 with sevendecimalplaces. If time_stamp is of data type TIMESTAMPL for the long form, the second fractions in the decimal places are initialized during assignment.

Note

When dates are converted to reflect the conversion from the Julian calendar to the Gregorian calendarand the non-existence of the days between 19/5/1582 and 10/14/1582, this returns the same results as the conversion for the days from 10/15/1582 to 10/24/1582 (which do exist).

System Fields

sy-subrcMeaning
0Local time of specified time zone was converted to time stamp and assigned to the target field
4Time specification was converted to time stamp without time shift and assigned to the target field.
8Time specification could not be converted, because the specified time zone is not in the database table TTZZ
12Time specification could not be converted, because dat, tim, or dst contain invalid or inconsistent values.

Addition

... DAYLIGHT SAVING TIME dst

Effect

The DAYLIGHT SAVING TIME addition can be specified after TIME to control the behaviorof the statement with regard to daylight saving time. For dst, you must specify a data object of type c with length 1, which has the value "X" or " ".

  • If dst has the value "X", the value of tim is adopted as the time specification in daylight saving time.
  • If dst has the value "X", the value of tim is adopted as the time specification in winter time.

If dst has a different value or the value of dst does not match the value in tim,dat, and tz, time_stamp remains unchanged and sy-subrc is set to 12. Forexample, the value for dst does not match the other values if it contains the value "X", and tim, dat, and tz contain values for a time stamp for winter time in the northern hemisphere.

If tz contains a time zone without a daylight saving time rule (for example, if you specify theUTCreference time using "UTC"), the addition is ignored. If the DAYLIGHT SAVING TIME additionis not specified, the value of dst is implicitly set to "X" in daylight saving time and " " inwinter time for tim and dat. In the extra hour that arises when switching from daylightsaving time to winter time, dst is set to "X" and the values in tim and dat are adopted as the time in daylight saving time.

Notes

  • Current user-specific, local time specifications and the corresponding local time zones are stored inthe system fields sy-datlo,sy-timlo,and sy-zonlo.
  • Specifying daylight saving and winter time after DAYLIGHT SAVING TIME enables you to create differentUTC time stamps from matching local time stamps within the extra hour when switching from daylight saving to winter time.
  • When the switch is made from winter to daylight saving time, an hour is lost. For example, in the "CET"time zone in the year 2009, on March 29, the hour between 02:00 and 03:00 does not exist. If you attemptto convert a time during this missing hour, the statement is always terminated with the value 12 for sy-subrc because this time or this local time stamp does not exist.


Example

For the time zone "BRAZIL", the settings apply that are described in the example for CONVERTTIME STAMP in the rule set for time stamps. By specifying the daylight saving and winter time,two different UTC time stamps "20030309033000" and "20030309043000" are created from one local time specification. Without the addition DAYLIGHT SAVING TIME, the UTC time stamp "20030309033000" is created.

DATA: time_stamp     TYPE timestamp,
      dat TYPE d,
      tim TYPE t,
      tz  TYPE ttzz-tzone.

tz = 'BRAZIL'.
dat = '20030309'.
tim = '013000'.

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME 'X'
        INTO TIME STAMP time_stamp TIME ZONE tz.
WRITE: / time_stamp.

CONVERT DATE dat TIME tim DAYLIGHT SAVING TIME ' '
        INTO TIME STAMP time_stamp TIME ZONE tz.
WRITE: / time_stamp.

Exceptions

Non-Catchable Exceptions

  • Cause: Inconsistent control tables for the conversion.
    Runtime Error: CONVERT_TSTMP_INCONSISTENT_TAB







RFUMSV00 - Advance Return for Tax on Sales/Purchases   ABAP Short Reference  
This documentation is copyright by SAP AG.


Length: 9433 Date: 20120522 Time: 041039     triton ( 273 ms )