SQL Server administration and T-SQL development, Web Programming with ASP.NET, HTML5 and Javascript, Windows Phone 8 app development, SAP Smartforms and ABAP Programming, Windows 7, Visual Studio and MS Office software SAP ABAP Programming and HANA Database Tutorials
Development resources, articles, tutorials, samples, codes and tools for .Net, SQL Server, Windows, Windows Phone, SAP and ABAP, like SAP UI5, Screen Personas, etc.

CRM Companies List
Web Based CRM Software

How to Convert Timestamp to String in ABAP

SAP timestamp values are stored in fields with decimal data types. In ABAP to convert timestamp to string programmer can use function modules.
ABAP function module RRBA_CONVERT_TIMESTAMP_TO_STR given in this tutorial is an example to display time stamp field values in character or string data representations.

In SAP sales documents VBAK table, there is a field named UPD_TMSTMP with data element TIMESTAMPL for storing last change date and time in UTC time stamp long form (YYYYMMDDhhmmssmmmuuun).
In my development SAP system, in VBAK table you can see sample rows with timestamp values in below screenshot.

convert timestamp to string using ABAP function module

ABAP programmers can work on such sample sales order data to convert timestamp field to string expression as we will do in this ABAP tutorial using below shared codes.

ABAP Function Module to Convert Timestamp to String

ABAP developers can use the function module RRBA_CONVERT_TIMESTAMP_TO_STR to convert timestamp values to string easily.

Let's make a test.
In this example, since ABAP function module RRBA_CONVERT_TIMESTAMP_TO_STR accepts timestamp input parameter in short form we will convert UPD_TMSTMP field value from long form to short form.

DATA lv_vbeln TYPE vbeln VALUE '0100001415'.
DATA lv_timestamp_string TYPE string.
DATA lv_timestamp_short TYPE rs_timestmp.

SELECT SINGLE upd_tmstmp INTO @DATA(lv_timestamp)
 FROM vbak WHERE vbeln = @lv_vbeln.

" convert timestamp in long form to timestamp in short form
lv_timestamp_short = lv_timestamp.

" ABAP function module accepts timestamp input parameter in short form
  i_timestamp = lv_timestamp_short
  e_output = lv_timestamp_string.

WRITE lv_timestamp_string.

The output is as "22.03.2016 08:32:44" for the above ABAP code execution which programmers can use to convert timestamp to string or character variable.

convert timestamp to string in ABAP

You can check your ABAP code test results by switching to VA03 Sales Order Display transaction with your sample VBELN number. Then following top menu options "Environment > Changes" display changes on sales document sorted by "time of change". The last change will be the output of above ABAP function module RRBA_CONVERT_TIMESTAMP_TO_STR.

SAP Tutorials

SAP Tutorial

SAP Forums

SAP Tools

SAP Transaction Codes Table

Copyright © 2004 - 2018 Eralper YILMAZ. All rights reserved.
Community Server by Telligent Systems