ABAPCONVERT_TIME-STAMP - CONVERT TIME-STAMP

Addresses (Business Address Services)   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

CONVERT TIME STAMP

Short Reference



Syntax

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

Addition:

... DAYLIGHT SAVING TIME dst

Effect

This statement interprets a time stamp specified in time_stamp as aUTCreference time, converts it to the local date and local time of the time zone specified in tzand assigns the result to the dat, tim and dst variables. At least one of the two additions DATE or TIME must be specified. time_stamp and tz arefunctional operand positions.

The time_stamp operand must have either the data typeTIMESTAMP orTIMESTAMPL from the ABAP Dictionary and the corresponding ABAP type p of length 8 or p of length 11 with sevenfractionalportions, and which contains one valid time stamp in short or long form. If time_stamp doesnot contain a valid time stamp, the content of dat and tim is not changed, and sy-subrc is set to 12.

For tz, an operand of type TIMEZONE from the ABAP Dictionary must be specified that contains a time zone from the TZONE column of database tableTTZZ in uppercase. If tz is initial,no local time is calculated; instead, dat and tim are assigned to the UTC reference timeand sy-subrc is set to 4. If the specified time zone is not found in database table TTZZ, the content of dat and tim remains unchanged and sy-subrc is set to 8. If therules for the specified time zone are not complete, this results in an untreatable exception.

The return values for dat and tim are of data type d or t. For datand tim, suitable data objects into which the return values can be converted have to be specified.If the time stamp in time_stamp is available in long form, then the fractions of seconds in the fractional portions are ignored.

Note

If a time stamp is converted to reflect the conversion from the Julian calendar to the Gregorian calendarand the non-existence of the days between 10/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
0Time stamp was converted into the local time of the specified time zone and assigned to the target fields.
4Time stamp was assigned to the target fields without conversion into the local time.
8Time stamp could not be converted since the specified time zone is not available in database table TTZZ.
12Time stamp could not be converted since time_stamp contains an invalid value.

Notes

  • A current UTC time stamp can be created using the GET TIME STAMP statement.

The current user-specific local time zone can be found in the system field sy-zonlo.

Addition

... DAYLIGHT SAVING TIME dst

Effect

A dst variable of type c of length 1 must be specified after the optional DAYLIGHTSAVING TIME addition. If the time stamp contained in time_stamp for the time zone specified in tz is in the summer, then dst is set to "X". If it is not, it is set to " ".

Note

It is now possible to use the return value for the summer time in dst to differentiate betweenduplicate local time specifications that occur when UTC time stamps are converted into local time during the double hour in the changeover between summer and winter time.

Example

For the "BRAZIL" time zone available in database tableTTZZ, a shift of -3 hours with respect to the UTC reference time is entered in database tableTTZR. The end of the summer time is defined in database tableTTZDV as the second Sunday in March at 02:00,which in the year 2003 corresponds to March 9th. With these settings in the rules, the two conversionsbelow both result in the same local time of "01:30:00". The first conversion shows that the time is still in the summer time.

DATA: time_stamp TYPE timestamp,
      dat        TYPE d,
      dat        TYPE d,
     tz         TYPE ttzz-tzone,
     dst        TYPE c LENGTH 1.

tz = 'BRAZIL'.
time_stamp = 20030309033000.
CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
WRITE: /(10) dat, (8) tim, dst.

time_stamp = 20030309043000.
CONVERT TIME STAMP time_stamp TIME ZONE tz
        INTO DATE dat TIME tim DAYLIGHT SAVING TIME dst.
WRITE: /(10) dat, (8) tim, dst.

Exceptions

Non-Catchable Exceptions

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







PERFORM Short Reference   TXBHW - Original Tax Base Amount in Local Currency  
This documentation is copyright by SAP AG.


Length: 7821 Date: 20120522 Time: 041208     triton ( 298 ms )