Skip to Content
0

UDF to know calendar week in a year

Mar 10, 2017 at 10:39 AM

66

avatar image
Former Member

Hi PI/PO Experts,

I have a requirement to populate current calendar week of a year.

Could you please provide me an UDF to achieve my requirement.

I have checked in sap sdn forums and did not find it.

Thanks in advance.

Thank you,

Chakradhar N

10 |10000 characters needed characters left characters exceeded
Former Member

Hi Inaki,

Thanks a lot for sharing the below blog.

https://blogs.sap.com/2009/02/13/yes-it-is-possible-with-datetrans-function/?, or you need a factory calendar like in SAP ERP?

issue got resolved.

Thank you,

Chakradhar N

0
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Evgeniy Kolmakov Mar 10, 2017 at 11:32 AM
0

Hi Chakradhar!

Calendar calendar = new GregorianCalendar();
Date trialTime = new Date(); // Your date here 
calendar.setTime(trialTime);    
int weekNumber = calendar.get(Calendar.WEEK_OF_YEAR));

Regards, Evgeniy.

Show 3 Share
10 |10000 characters needed characters left characters exceeded

Hi Evgeniy,

Once I had a situation that a server time zone and a local time zone were different. Since then I always specify the required time zone during creation of java objects. For example:

Calendar cal = GregorianCalendar.getInstance(TimeZone.getTimeZone("Europe/Berlin"));
int weekOfYear = cal.get(Calendar.WEEK_OF_YEAR);

Regards,

Andrzej

1

Hi Andrzej!

Thank you very much for your suggestion.

Regards, Evgeniy.

0
Former Member

Hi Evgeniy,

Thank you very much for the UDF. I will try this.

Thank you,

Chakradhar N

0
Iñaki Vila Mar 10, 2017 at 12:01 PM
0

Hi,

Have you checked this blog

https://blogs.sap.com/2009/02/13/yes-it-is-possible-with-datetrans-function/?, or you need a factory calendar like in SAP ERP?

Regards.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Mar 10, 2017 at 04:13 PM
0

Hi Inaki,

Thanks a lot for providing the blog link, i did not find this blog before.

It will full fill my requirement.

Thanks again.

Thank you,

Chakradhar N

Share
10 |10000 characters needed characters left characters exceeded