cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

How to access current system date???

Former Member
0 Likes
916

Hi Experts,

I am working on a process wherein a user creates a proposal and a notification is sent to the manager for approval.

Now i need to send the date of creation as a attribute to the manager.

Can anyone guide me as to how to get the current system date???

Thanks a lot.

Cheers

Gaurav Raghav

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Likes

Hi,

You use "Current State Information" CO to find the data and time

Thanks

Gopal

Former Member
0 Likes

Hi Gopal,

I guess the Current State Information Co can be used in GP.

I want obtain the current system date in Web Dynpro project.

Any idea how to go about it??

Thanks.

Cheers

Gaurav Raghav

Former Member
0 Likes

try to use system field SY-DATUM

Former Member
0 Likes

Hi Wojciech Matulewicz ,

I am using Web Dynpro Java in SAP NW Developer studio.

that code is for Web Dynpro ABAP and i know that as i am a ABAP Consultant..

But i need the code to get the current system date to send the day of creation of proposal request in Web Dynpro Java.

Any clues???

Cheers

Gaurav Raghav

Former Member
0 Likes

//You can get current date

Date currDate = new Date(System.currentTimeMillis());

Former Member
0 Likes

Hi Wojciech Matulewicz,

I have tried using this before and i faced this problem.

When i click on create proposal, the screen just refreshes and the CO execution doesnt ends.

Without ending this field, however things work fine.

here is the code:

Method technicalDescription()

IGPAttributeInfo date = output.addAttribute("DATE", IGPAttributeInfo.BASE_DATE);

date.setMultiplicity(IGPAttributeInfo.MULITIPLICITY_1_1);

Method execute()

Date currDate = new Date(System.currentTimeMillis());

contextElement.setDate(currDate);

Method complete()

output.setAttributeValue("Date", wdContext.currentContextElement().getDate());

If i comment out this code, the CO execution works out fine, but on addition of this code the screen refreshes and CO execution doesnt end.

Am i doing something wrong???

please help me out with this.

Thanks.

Cheers

Gaurav Raghav

Answers (2)

Answers (2)

Former Member
0 Likes

Hi All,

I used the code given by Wojciech Matule and it is working fine now.

Thanks a lot.

Cheers

Gaurav Raghav

Former Member
0 Likes

Hello all,

I'm new to GP and CAF. I see that there are some JAVA statements to be writte for Webdynpro CO. Where do you guys actually put this code?

Is there a place where we can write some JAVA code for JAVA webdynpros?

Thanks,

Sam

Former Member
0 Likes

Hi Mandrake,

Yes there is a place to put the JAVA Code.

Follow these steps:

Create a Web Dynpro Application in SAP NW Developer Studio

Switch to Web Dynpro perspective

Create a Component

Open the Java editor of Component Controller/View Controller to put the necessary Java code.

Follow this doc for details.

https://wwwn.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e0957cb6-5103-2a10-6d9d-a0a4d68...

Hope it helps.

Welcome to ESA.

Cheers

Gaurav Raghav

Former Member
0 Likes

Thanks a lot Gaurav. Actually I have not been using NW Dev Studio till now and I was clueless about these. Appreciate your response.

Cheers,

Sam

ReenaWadhwa
Product and Topic Expert
Product and Topic Expert
0 Likes

Hi,

You can use following code to get system date and day.

public static final String DATE_FORMAT_NOW = "yyyy-MM-dd HH:mm:ss";

Calendar cal = Calendar.getInstance();

SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);

sdf.format(cal.getTime());

you can specify format according to you and can get day, date and time.

Reena