SAP Knowledge Base Article - Public

2887459 - Timestamp field represented as decimal in Custom CDS View

Symptom

You are using Custom CDS View application to create your own CDS View.

You have chosen a timestamp field from an standard Data Source and it looks like a decimal number.

Environment

S/4HANA Cloud

Reproducing the Issue

1. Create a Custom CDS View YY1_CUSTOMCDSVIEW

2. Make an association to I_ServiceEntrySheetAPI01 Service Entry Sheet API01 with alias _ServiceEntrySheet

3. Choose field _ServiceEntrySheet.ApprovalDateTime ApprovalDateTime Approval Date Field DEC (11)

4. When you preview the Custom CDS View, the DateTime field is represented as a number with decimals instead of a timestamp.

*The standard CDS View I_ServiceEntrySheetAPI01 is just an example that presents this issue.

Cause

The field comes in decimal format.

Resolution

In order to convert this data format, we recommend you to create calculated fields in Field Selection in Custom CDS Views.
With the following cast functions, it is possible to retrieve the data format as date:

cast( cast( DateTimeFieldName as ABAP.SSTRING( Length ) ) as ABAP.DATS )

cast( cast( floor(DateTimeFieldName ) as ABAP.SSTRING( Length ) ) as ABAP.DATS )

See Also

2737769 - Transient (2O-) Characteristic is Truncated in Query Result

Keywords

Timestamp, Decimal format, DEC 21, Custom CDS View '''''' '''''' '''''' '''''' '''''' '''''' '''''' '''''' '''''' , KBA , BC-SRV-APS-GKE , Generic CDS Key User Editor , MM-PUR-SVC-SES , Service Entry Sheet for Service Procurement , BW-BEX-OT-ODP , Query Runtime for Operational Data Provisioning , Problem

Product

SAP S/4HANA Cloud 1911