Olaf Pohlmann
Read all my blogsSooner or later every developer has to work with time zones and time stamps. Luckily the SAP system provides plenty of tools to support you in this area. In this blog I want to highlight some of the tools I’ve used in the past to make work a little easier.
The local time within a time zone is defined by its offset (difference) from Coordinated Universal Time (UTC), the world’s time standard. In SAP this piece of information can be stored in the user’s master data. You can adjust your own time zone from the menu: System » User profile » Own data and then the tab Defaults (or transaction SU3/SU50).
Conversion exits
- TSTPS – Displays a time stamp in the UTC time zone
- TSTLC – Displays a time stamp in the user’s local time zone
Just attach these conversion exits to a domain to profit from advanced display handling. Instead of creating your own data elements you can also reuse LCA_TIMESTAMP (UTC time) or SALV_DE_TSTLC (local time). When these are used on a (selection-)screen, the attached conversion exits automatically render the values. Note that in the example below the internal values of both fields are equal in my situation where the local time zone is CET.
Transactions SE16 and SE16N also take into account possible conversion exits. For SE16, with default settings, the detail screen shows the converted values. By the way, the internal value is also rendered but according to its internal type, decimal, which is rather meaningless for time stamps.
Other tools
- If you’re a fan of functional methods you can use CL_ATRADT_TRACES_RES_TRACES=>GET_CURRENT_TIMESTAMP( )or CL_KF_HELPER=>CURRENT_TIMESTAMP_GET( ) as an alternative for the statement GET TIME STAMP
- Class CL_ABAP_TSTMP provides methods to manipulate or compare time stamps. The strange abbreviated class name puzzles me and certainly makes it harder to find compared to e.g. CL_ABAP_TIMESTAMP which is still available in my system…
Daylight saving time (DST) – Summer time
As an example some time stamps around the moment summer time ends:
Did you know?
And by the way, did you know that…
- France currently holds the world record for the country with the most time zones (12!) because of its overseas territories, beating even the United States and Russia
- China, roughly similar size to the continental United States, has one time zone
- While most time zones differ from UTC by a number of full hours, there are also a few time zones with both 30-minute and 45-minute offsets like India (+5:30) and Nepal (+5:45)