Ansicht
Dokumentation

ABENTIME_STAMPS_PACKED - TIME STAMPS PACKED

ABENTIME_STAMPS_PACKED - TIME STAMPS PACKED

ABAP Short Reference   General Data in Customer Master  
This documentation is copyright by SAP AG.
SAP E-Book

Time Stamps in Packed Numbers

In this format, time stamps are represented using packed numbers of the type p.

Representation of Time Stamps in Packed Numbers

There is a short form and a long form.

  • In the short form, a time stamp is represented precisely to the second using a packed number with length 8 without decimal places, and the ABAP Dictionary type TIMESTAMP. The digits of the packed number show the time stamp in the format "yyyymmddhhmmss", where "yyyy" is the year, "mm" is the month, "dd" is the day, "hh" is the hour, "mm" are the minutes, and "ss" are the seconds.
  • In the long form, a time stamp is represented precisely to 100 ns using a packed number with length 11 and seven decimal places, and the ABAP Dictionary type TIMESTAMPL The digits of the packed number show the time stamp in the format "yyyymmddhhmmss.sssssss", where, in addition to the short form, the seven decimal places "sssssss" are the fractions of a second. The maximum time resolution that can be achieved depends on the operating system of the host computer of the current and can be less.

In its integer part, a valid time stamp must contain valid dates and times:

  • When specifying the date, only the values 01 to 9999 for the year, 01 to 12 for the month, and 01 to 31 for the day are valid.
  • When specifying the time, only the values 00 to 23 for the hours, and 00 to 59 for the minutes and seconds are valid.

A time valid in the Gregorian calendar must be represented. Leap seconds are not supported.

Notes

  • An initial packed number with the value 0 does not contain a valid time stamp.
  • The method NORMALIZE of class CL_ABAP_TSTMP can be used to convert invalid values in time stamps to valid values.

Accessing Time Stamps in Packed Numbers

Only a few statements recognize that packed numbers of the types TIMESTAMP and TIMESTAMPL are time stamps. All other statements interpret the content of these data types as numbers and, with the exception of direct comparisons, are not suitable for handling time stamps. The statements for handling time stamps in packed numbers are as follows:

Furthermore, time stamps in packed numbers are handled specifically in the following output formats:

  • Use of the addition TIME ZONE of the statement WRITE $[TO$].

The system class CL_ABAP_TSTMP provides methods for adding, subtracting, converting, and comparing time stamps in packed numbers.

Note

Special time stamp functions can be used in ABAP SQL and the CDS DDL of the ABAP CDS for processing time stamps stored as packed numbers in database tables.

Notes on Handling Time Stamps in Packed Numbers

Time stamps in packed numbers are only interpreted as such if they are accessed by the statements, methods, and functions listed above. When being assigned or converted, they behave like packed numbers of the type p, which means they are not suitable for direct calculations. Comparisons produce a meaningful result only when two time stamps are compared with each other. In programs for which the program attribute Fixed Point Arithmetic is not set, the corresponding rules applying to the data type p should be respected. In particular, direct comparisons of time stamps in the long form with the short form produce a meaningful result only when the program attribute fixed point arithmetic is set. Otherwise, the system class CL_ABAP_TSTMP must be used for comparisons as well.

A time stamp in its short form is the integer part of a time stamp in its long form. When assigning time stamps in the long form to time stamps in the short form, unwanted rounding effects can always occur. For this reason, the method MOVE of the system class CL_ABAP_TSTMP should always be used for this.

When time stamps in packed numbers are used in operand positions that are not specifically intended for them, no warnings are given by the syntax check or by the extended program check, not even in lossless assignments.

Examples for Time Stamps in Packed Numbers

Direct comparison of time stamps in packed numbers with the same data type.

Example

Conversion of a time stamp in a packed number to a date and a time field, and determination of the daylight saving time marker.

Example

Formatting of a time stamp in a packed number in a string template in a type-friendly way.

Example

Serialization of a time stamp in a packed number by using a special domain.

Example

Calculation of the difference between two time stamps in packed numbers using the class CL_ABAP_TSTMP.

Example

Direct calculation using time stamps in packed numbers. If, for example, ts1 has the value 20161004130733, adding 3600 s in ts2 produces the value 20161004140733. Since the time stamps are interpreted as numbers of type p in the calculation, the result is 10000, which would generally be unexpected.

Example

Incorrect calculation using time stamps in packed numbers. The assumption here is that time stamps are interpreted as a number of seconds in calculations. This is not the case here. The result does not meet expectations and is generally not a valid time stamp. For example, the invalid value 20161004315506 is calculated from 20161004131906.






CPI1466 during Backup   ROGBILLS - Synchronize billing plans  
This documentation is copyright by SAP AG.

Length: 9314 Date: 20240427 Time: 050959     sap01-206 ( 107 ms )