Section 16 of CDS: Utilizing Built-In Features in CDS IV

We have discussed SQL functions, unit/currency conversion functions, and date functions in our Built In Functions in CDS section; however, we did not cover the Time function. We’ll pick up where we left off in the previous post today. Now let’s dive right into what may be the final installment of this Built-In Functions series.

Let’s go over the Time Functions in this post. It will be quite easy to go through the four functions indicated below with Time.

  • Time Is Valid
    It is necessary to pass a single parameter. It is imperative that the field type be TIMESTAMP – DEC – Length 15.The remaining features of this blog operate in the same way.
  • UTC HOUR
    The best thing about this is that no parameters are required. Provides the Coordinated Universal Time (UTC) by default.
  • ADD A SLEEP
    The result is the total of the numbers when, as the name implies, we add the seconds to the timestamp.
  • SLITS IN BETWEEN
    We had days between in our last issue, remember? There are now seconds in between.

It is improper to violate customs.How come the Code isn’t available to us?

@AbapCatalog.sqlViewName: 'ZTM_FNS_SQL_V'
@AbapCatalog.compiler.compareFilter: true
@AbapCatalog.preserveKey: true
@AccessControl.authorizationCheck: #NOT_REQUIRED
@EndUserText.label: 'Time Functions'
define view ZTM_FNS as select from zdt_concr_rept as a{
    key a.rpt_id as RPT_Comment,
    a.ztime as RPT_TMSP,
    tstmp_is_valid(a.ztime) as valid1,   
    tstmp_current_utctimestamp() as UTC_TM,
    tstmp_add_seconds(a.ztime, cast( 15 as abap.dec(15,0) ), 'INITIAL') as ADDED_TM,    
    //TESTING DIFFERENCE OF SECONDS
    tstmp_seconds_between(tstmp_current_utctimestamp(), a.ztime , 'FAIL') as difference 
}

Nothing that demands particular attention.

If you find this boring, check out our extra section. This section will link to all other worlds as well as SAP.

OData: Many of you have heard of this lovely idea and have worked with it.However, what if CDS was connected to the outside world (apart from SAP) via OData service?

Also Consider: ABAP on HANA Course

@AbapCatalog.sqlViewName: 'ZTYPE_CAST_V'
 @AbapCatalog.compiler.compareFilter: true
 @AbapCatalog.preserveKey: true
 @AccessControl.authorizationCheck: #NOT_REQUIRED
 @EndUserText.label: 'Type Casting Examples'
 define view ZTYPE_CAST
   as select from sflight as a
 {
   key a.carrid,
   key a.connid as originalConn,
   key a.fldate,
       cast (a.connid as abap.char(2) )
       as castedConn,
       a.planetype as originalType,
       cast( a.planetype as abap.char( 2 ) )
                   as castedType
 }
Observe keenly there are two warnings. Let’s see what are they.

So effectively two things needs to be kept in mind.

  1. Apply Type casting only when changing from one data type to other. If it is done within same data type the very purpose is not served.
  2. Need to be very careful such that no harm is done to data.

Output validates the earlier assertion.

Another insightful lesson for me! I attempted to insert castConn, the non-primary key, before fldate. However, SAP denied me access.

This concludes the functions series and Ishan’s specific request.

Return to CDS View via OData exposure. At technicalgyanguru, we already have a few articles on OData from CDS Annotations.However, our next piece on OData from CDS will be unique and captivating.Because there isn’t much room here, you’ll have to wait a little while longer. We pledge not to bother you too much and to deliver it in as little as two days. Please continue to watch.

We really appreciate your input. Kindly, provide your feedback down below.

WSDL file in SAP – Part I

Related Posts

Advanced SAPUI5 – 8 – How to Use Python to Get Weight for SAPUI5 Fiori Apps from the Weigh Scale/Weigh Bridge?

As promised, I will keep writing on SAPUI5, which is a rather complicated topic for which it is difficult to locate tutorial resources. Today, let’s look at a very real-world…

How can I configure the SAP PI system and set up NetWeaver Developer Studio (SAP NWDS) for SAP XI/PI/PO?

We will walk you through the steps of installing the necessary JDK version and configuring NetWeaver Developer Studio on your local PC in this comprehensive tutorial. We’ll also set up…

Leave a Reply

Your email address will not be published. Required fields are marked *

You Missed

Advanced SAPUI5 – 8 – How to Use Python to Get Weight for SAPUI5 Fiori Apps from the Weigh Scale/Weigh Bridge?

  • By Varad
  • January 22, 2025
  • 7 views
Advanced SAPUI5 – 8 – How to Use Python to Get Weight for SAPUI5 Fiori Apps from the Weigh Scale/Weigh Bridge?

How can I configure the SAP PI system and set up NetWeaver Developer Studio (SAP NWDS) for SAP XI/PI/PO?

  • By Varad
  • January 21, 2025
  • 29 views
How can I configure the SAP PI system and set up NetWeaver Developer Studio (SAP NWDS) for SAP XI/PI/PO?

An Object-Oriented Approach to Emailing a PDF Attachment

  • By Varad
  • January 20, 2025
  • 41 views
An Object-Oriented Approach to Emailing a PDF Attachment

How Can I Modify the Master List Item Selection in SAPUI5 Based on Hash Tag URL Changes?

  • By Varad
  • January 19, 2025
  • 30 views
How Can I Modify the Master List Item Selection in SAPUI5 Based on Hash Tag URL Changes?

SAP XI/PI/PO – End-to-End Synchronous Interface Development – Exposing RFC as REST API

  • By Varad
  • January 18, 2025
  • 52 views
SAP XI/PI/PO – End-to-End Synchronous Interface Development – Exposing RFC as REST API

How to Create an Audio Video Multimedia Player in SAPUI5 (Advanced SAPUI5-23)

  • By Varad
  • January 17, 2025
  • 57 views
How to Create an Audio Video Multimedia Player in SAPUI5 (Advanced SAPUI5-23)