Timestamp display in ALV
The provided text contains information and code related to working with timestamps and formatting them for display in an ALV (ABAP List Viewer) table. Here's a breakdown of the key points:
Timestamp Format Transformation: The text begins with a description of a timestamp represented as '20,201,004,223,429' and the desire to format it as '2020-10-04 22:34'. This indicates a need to transform the timestamp from one format to another for better presentation.
ABAP Code: The code section titled "FORM modify_fieldcat" shows a piece of ABAP code that is likely part of an ABAP program. It appears to be working with field catalog entries for an ALV display. In this code, a specific field with the name 'TIMESTAMP' is being modified. The modifications include setting the field as non-editable ('
Timestamp Conversion: The text also provides information about converting date and time into a timestamp and vice versa. It mentions that you can convert date and time into a timestamp using the 'CONVERT DATE' syntax and split a timestamp into date and time using the 'CONVERT TIME STAMP' syntax. This is useful for scenarios where you need to work with both date/time and timestamps.
In summary, the text is primarily focused on formatting timestamps for display in an ALV table, and it includes relevant ABAP code for modifying field catalog entries to achieve the desired formatting. Additionally, it provides information about how to convert between date/time and timestamps when needed in ABAP programming.

In ABAP, when displaying a timestamp in an ALV (ABAP List Viewer), you typically use the CL_SALV_TABLE
or REUSE_ALV_GRID_DISPLAY
functions to present data, including timestamp fields. The timestamp field is often stored in the TIMESTAMP
or TIMESTAMPL
format (CHAR
type with length 14 or 21 respectively). To display it properly in an ALV, you can use formatting options or convert it into a readable format.
Here’s how you can display a timestamp in ALV
Example using CL_SALV_TABLE
:
DATA: lt_data TYPE TABLE OF ztable, " Replace ztable with your table lr_alv TYPE REF TO cl_salv_table, lt_fieldcatalog TYPE salv_t_fieldcat_alv. " Select data from your table with timestamp fields SELECT * FROM ztable INTO TABLE lt_data. " Create the ALV instance cl_salv_table=>factory( IMPORTING r_salv_table = lr_alv CHANGING t_table = lt_data ). " Optionally, format the timestamp field to be more readable DATA: ls_columns TYPE REF TO cl_salv_columns_table, ls_column TYPE REF TO cl_salv_column. ls_columns = lr_alv->get_columns( ). " Get the timestamp field for formatting ls_column = ls_columns->get_column( 'TIMESTAMP_FIELD' ). " Replace with actual field name " Set output length (if required) and other properties ls_column->set_output_length( 21 ). " Display the ALV lr_alv->display( ).
Example using REUSE_ALV_GRID_DISPLAY
:
DATA: lt_data TYPE TABLE OF ztable, " Replace ztable with your table lt_fieldcatalog TYPE slis_t_fieldcat_alv, ls_fieldcatalog TYPE slis_fieldcat_alv. " Select data with timestamp fields SELECT * FROM ztable INTO TABLE
I have a time stamp which is displayed as '20,201,004,223,429'
. I want to show this in ALV formatted as '2020-10-04 22:34'
.
FORM modify_fieldcat. LOOP AT i_fieldcat ASSIGNING <fs_fieldcat>. CASE <fs_fieldcat>-fieldname. WHEN 'TIMESTAMP'. <fs_fieldcat>-edit = ' '. <fs_fieldcat>-col_opt = 'X'. <fs_fieldcat>-edit_mask = '____-__-__ __:__'. ENDCASE. ENDFORM.
Converting Date & Time to Timestamp or vice versa
Assume date and time is only available, but the target value required was timestamps. In this case, the date and time needs to be converted/combined as a timestamp.
In other way, assume if only timestamp is available but the date and time required separately. This case, the timestamp should be split into date and time.
Syntax: Timestamp from date & time
CONVERT DATE w_date [TIME w_time [DAYLIGHT SAVING TIME w_dst]] INTO TIME STAMP w_tstamp TIME ZONE w_tzone.
Syntax – Split timestamp to date & time
CONVERT TIME STAMP w_tstamp TIME ZONE w_tzone INTO [ DATE w_date] [ TIME w_time ] [DAYLIGHT SAVING TIME w_dst].