Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
chandansb
Active Contributor

Background:

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. :wink:

Thought of sharing this with the Community. :smile:

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()){

  this.today = value1; // Display the Day on the screen

  }

Below is the Re-Use function coding.

Hopefully this might be helpful to the community.


Cheers. :smile:



10 Comments
Labels in this area