ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Character String and Byte String Processing → Expressions and Functions for String Processing → string_exp - String Expressions → string_exp - String Templates → Examples of string templates
String Templates, Time Zones
The example demonstrates the formatting of a time stamp using time zones.
Other versions: 7.31 | 7.40 | 7.54
Source Code
TYPES: BEGIN OF timezone,
tzone TYPE ttzz-tzone,
descript TYPE ttzzt-descript,
datetime TYPE string,
END OF timezone.
DATA: timezones TYPE TABLE OF timezone,
tstamp TYPE timestamp.
FIELD-SYMBOLS <timezone> TYPE timezone.
SELECT ttzz~tzone, ttzzt~descript
FROM ttzz INNER JOIN ttzzt
ON ttzz~tzone = ttzzt~tzone
WHERE ttzz~tzone NOT LIKE '%UTC%' AND
ttzzt~langu = 'E'
INTO CORRESPONDING FIELDS OF TABLE @timezones
##too_many_itab_fields.
GET TIME STAMP FIELD tstamp.
LOOP AT timezones ASSIGNING <timezone>.
<timezone>-datetime = |{ tstamp TIMEZONE = <timezone>-tzone
TIMESTAMP = USER }|.
ENDLOOP.
SORT timezones BY datetime.
cl_demo_output=>new(
)->begin_section( 'Timezones Around the World'
)->display( timezones ).
Description
All time zones with a geographical reference are extracted from the database table TTZZ into an internal table. The current time stamp is formatted with each of these time zones and written to the internal table. The internal table is sorted and displayed according to the formatted time stamp.