cancel
Showing results for 
Search instead for 
Did you mean: 

Calendar In CE

Former Member
0 Kudos

Hi,

How to set the working duration and working time in the Calendar? I need the duration to be be 8 hours and working hours 9 am to 6 pm.

Thanks & Regards,

Amrita

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

There's a preferred way of setting the duration

The representation uses the following literals:

  • P = denotes the duration and must precede every duration value

  • nY = the number prefix (n) is the duration in years

  • nM = the number prefix (n) is the duration in months

  • nD = the number prefix (n) is the duration in days

  • T = is the prefix for the time period in hours, minutes, and seconds. Not required if no times are defined

  • nH = the number prefix (n) is the duration in hours

  • nM = the number prefix (n) is the duration in minutes

  • nS = the number prefix (n) is the duration in seconds

As we need 9 hours of working time . Our string representation would be ""P0Y0M0DT9H0M0S"

where 9H shows 9 working hours.

Please use the below line to set duration

CctDuration duration = new CctDuration("P0Y0M0DT9H0M0S");

Regards,

Ashish

Answers (6)

Answers (6)

Former Member
0 Kudos

Hi,

I agree with KV's suggestion of using a context attribute. As it allows you to set the values as and when desired from different event handlers.

However, if you are sure that the values aren't going to change . Then you can very well hard code.

Try the following for datatype conversion issue and see if it works:

workingTime.setStart(new CctTime(java.sql.Time.valueOf("09:00:00")));
workingTime.setDuration(new CctDuration("9"));

Regards,

Ashish

Former Member
0 Kudos

Hi Ayyapparaj,

I hardcoded the value as u mentioned but the calendar week view still shows all the 24 hrs.

Thanks,

Amrita

Former Member
0 Kudos

Hi Stefanie,

I have used the calendar tutorial. It displays 24 hrs at 1 hr interval. I need to show only 9 hrs at 1hr interval. How many hours does P0Y0M0DT9H0M0S stand for? I need to show from 9 am to 6 pm.

Thanks,

Amrita

Former Member
0 Kudos

Hi Amrita,

check out the [Calendar tutorial|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e012e6a2-8d21-2a10-1bb8-d9b606f3474c]

And don't forget to read documentation: [WorkingTime|http://help.sap.com/saphelp_nwce10/helpdata/en/44/117dcd48c9088be10000000a422035/frameset.htm]

Duration example:

CctDuration duration = new CctDuration("P0Y0M0DT9H0M0S");

Hope this helps

kind regards

Stefanie

Former Member
0 Kudos

Hi Ashish,

In which format should i enter the time and the duration? On hard coding the values it gives me datatype error.

Thanks,

Amrita

Former Member
0 Kudos

Hi,

Following code may help



IWDWorkingTime workingTime = (IWDWorkingTime) view.createElement(IWDWorkingTime.class, "workingTime");
	  Calendar cal = Calendar.getInstance();
	  Time time = new Time( cal.getTime().getTime());
	  workingTime.setStart(new CctTime(time));
                  // as mentioned by stefanie
                  CctDuration duration = new CctDuration("P0Y0M0DT9H0M0S");

	  workingTime.setDuration(duration);

Why not try to bind this to context attributes and use them?

Regards

Ayyapparaj

Former Member
0 Kudos

create a working time element to be consumed by the calendar UI element

Code snippet

IWDWorkingTime workingTime = (IWDWorkingTime) view.createElement(IWDWorkingTime.class, "workingTime");

workingTime .setStart(//set the start time i.e. 9 am in your case)
workingTime .setDuration (//set the duration i.e. 9 hours in your case)

Calendar.setWorkingTime(workingTime );

I hope this helps you.