Skip to Content
Author's profile photo Chandan Bankar

SAP C4C SDK: Re-use Function to fetch the Day for Specific Date


I had the requirement, where I need to have the Day for the specific date. Example if the entered date is 06/25/2015, I want to get Thursday. I had created the discussion on SCN for same. Below is the link to the discussion.

C4C SDK: Fetching Day for the specified Date

I was suggested by Cloud Application Studio expert Alessandro Iannaccito create the re-use function. However Cloud Application Studio expert Horst Schaude has mentioned that SAP will be get this as function in next release. But I thought of getting the experience to create my first new Re-use function. 😉

Thought of sharing this with the Community. 🙂

Note: I have created the Custom BO just to implement and test this functionality before implementing on any standard.

Business Object Definition

import AP.Common.GDT as apCommonGDT;

businessobject DayReuseLib {

[AlternativeKey] [Label(“Enter Date”)] element tdate : Date;

[Label(“Today”)] element today : LANGUAGEINDEPENDENT_ENCRYPTED_MEDIUM_Description;

[Transient][Label(“Leap Year”)] element leap : Indicator; // indicator For Leap Year Check


Event- AfterModify.absl

import ABSL;

import AP.Common.GDT as apCommonGDT;

var value1;

var year;

if(!this.tdate.IsInitial()) {

// ********* Checking if Leap Year ***************** //

var nyear : NumberValue;

nyear = year;

this.leap = false;

var leap : FloatValue;

leap = nyear/4;

if (!leap.ToString().Contains(“.”)) {

  this.leap = true;


// Call Reuse function to get the Day

value1  = Library::DayReuseLib.ReturnDayfromDate(this.tdate,this.leap);

  if(!value1.IsInitial()){ = value1; // Display the Day on the screen


Below is the Re-Use function coding.




Hopefully this might be helpful to the community.

Cheers. 🙂

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Alessandro Iannacci
      Alessandro Iannacci

      Great job!!! Congratulations and thanks!

      Author's profile photo Former Member
      Former Member

      Really Good

      Author's profile photo Former Member
      Former Member

      Good but not sure why you chose screen shots over just including the text...

      Author's profile photo Chandan Bankar
      Chandan Bankar
      Blog Post Author

      William, Thanks 🙂

      My idea was to present the complete code neat and clean and I thought that was only the way it can be shown. However I will surely check if there is anyway that I can attach the code. Surely will share it.



      Author's profile photo Stefan Hagen
      Stefan Hagen

      If I remember correctly, it will show quite okay and with syntax highlighting if you copy it from the SDK to the visual editor here.

      Author's profile photo Tammy McQuade
      Tammy McQuade


      Author's profile photo Chandan Bankar
      Chandan Bankar
      Blog Post Author

      Thanks Tammy 🙂

      Author's profile photo Tobias Kuhn
      Tobias Kuhn

      Hi Chandan,

      thank you for this tutorial.

      This feature will also be part of the Standard SAP Cloud Applications Studio 1508 Features for the Ruse Library "Date".


      Sample form the 1508 Documentation: = Date.ParseFromString("20100215");
      this.result =;
      Result: Integer value to 7

      Best regards


      Author's profile photo Chandan Bankar
      Chandan Bankar
      Blog Post Author

      Thanks for the valuable information Tobias 🙂

      Author's profile photo Former Member
      Former Member

      Hi Chandan,

      Good Job!

      But, instead of using "if else" better to use switch case. It will reduce the compiling time, and it will save the time.


      SHIVA G