Ansicht
Dokumentation

ABAPCONVERT_UTCLONG - CONVERT UTCLONG

ABAPCONVERT_UTCLONG - CONVERT UTCLONG

Addresses (Business Address Services)   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

CONVERT UTCLONG

Short Reference



CONVERT UTCLONG time_stamp
        INTO $[DATE dat$]
             $[TIME tim $[FRACTIONAL SECONDS fs$]$]
             $[DAYLIGHT SAVING TIME dst$]
             TIME ZONE tz.


Effect

This statement converts the time stamp contained in a time stamp field time_stamp to the local date and local time of the time zone specified in tz and assigns the result to the variables dat, tim, and dst. At least one of the additions DATE, TIME, or DAYLIGHT SAVING TIME must be specified. The conversion is performed in accordance with the rules for time zones.

time_stamp is a time-stamp-like expression position and tz is a functional operand position.

  • The operand time_stamp must be of the type utclong, which contains a valid time stamp. If time_stamp does not contain a valid time stamp, a catchable exception of the class CX_SY_CONVERSION_NO_DATE_TIME is raised.
  • The operand tz must be character-like and contain a time zone from the DDIC database table TTZZ.
  • If tz is initial, the UTC time stamp is not converted to a different time zone. The local date and time in the target fields correspond to the UTC reference time.

  • If the specified time zone is not found in the DDIC database table TTZZ, a catchable exception of the class CX_SY_CONVERSION_NO_DATE_TIME is raised, unless the time stamp is initial.

  • If the rule set for the specified time zone is incomplete, an uncatchable exception is raised.

  • The local date is assigned to dat as a return value of the data type d. The following can be specified for dat:
  • An existing variable of type d.

  • The local time without the fractions of seconds is assigned to tim as a return value of data type t. The following can be specified for tim:
  • An existing variable of type t.

  • The fractions of seconds are assigned to fs as a return value of the data type decfloat34. The following can be specified for fs:
  • An existing variable of the type decfloat34.

  • An inline declaration DATA(var) or FINAL(var), where a variable of data type decfloat34 is declared.

  • If the time stamp in time_stamp for the time zone specified in tz is in daylight saving time, dst is given the value "X". Otherwise it is given the value " ". The following can be specified for dst:
  • An existing variable of the type c with length 1

  • An inline declaration DATA(var) or FINAL(var), where a variable of data type c with length 1 is declared.

Regardless of the time zone specified, an initial time stamp generates type-dependent initial values in all target fields. If the time stamp has the minimum value "0001-01-01T00:00:00.0000000" or is in the last possible second "9999-12-31T23:59:59.fffffff" no time shift is calculated. A time stamp whose value is greater than or equal to the last second or is between "9999-12-31 23:59:59.0000000" and "9999-12-31 23:59:59.9999999" is handled like the maximum value "9999-12-31 23:59:59.9999999".

If time_stamp contains a valid value but results in an invalid date in combination with a valid time zone in tz, a catchable exception of the class CX_SY_CONVERSION_NO_DATE_TIME is raised.

Notes

  • A current UTC time stamp can be created with the built-in function utclong_current.
  • The current user time zone can be found in the system field sy-zonlo.
  • It is now possible to use the return value for the daylight saving time in dst to distinguish duplicate local time specifications that occur when UTC time stamps are converted into local time within the double hour in the switch between daylight saving and standard time.
  • Usually, an invalid date and the associated exception can be created from a valid time stamp only by combining the first valid day with time zones west of UTC or the last valid day with time zones east of UTC.
  • An initial time zone tz only corresponds to UTC if the tables of the rules for time zones are filled correctly for the time zone UTC.
  • The statement CONVERT INTO UTCLONG does not set the return value sy-subrc.

Example

For the time zone "EST" in the DDIC database table TTZZ, a shift of -5 hours from the UTC reference time is entered in the DDIC database table TTZR. In the DDIC database table TTZDV, the end of daylight saving time is defined as the first Sunday in November at 02:00 using the key "USA". In 2019, the first Sunday is November 03. With these settings in the rule set, the two conversions below both result in the same local time of "01:30:00". The first conversion shows that the time is still in daylight saving time.

Convert Time Stamp to Time Stamp Field.

Exceptions

Catchable Exceptions

CX_SY_CONVERSION_NO_DATE_TIME

  • Cause: Invalid time zone in tz.
    Runtime Error: INVALID_TIME_ZONE
  • Cause: An invalid date would be generated.
    Runtime Error: LOCAL_TIMESTAMP_OUT_OF_RANGE
  • Cause: The specified time stamp is invalid.
    Runtime Error: INVALID_UTCLONG

Non-Catchable Exceptions

  • Cause: Incomplete set of rules for the specified time zone.
    Runtime Error: CONVERT_TSTMP_INCONSISTENT_TAB
  • Cause: An operand with an incorrect type is being used.
    Runtime Error: TCHK_TYPE_LOAD





BAL_S_LOG - Application Log: Log header data   BAL_S_LOG - Application Log: Log header data  
This documentation is copyright by SAP AG.

Length: 10621 Date: 20240419 Time: 203349     sap01-206 ( 118 ms )