cancel
Showing results for 
Search instead for 
Did you mean: 

Bug !? Date selector picks up the wrong Date

Former Member
0 Kudos

Hi

I developed a Web Dynpro application which also have a imput field. The context that is mapped to it is a Date type. Sofar everything is ok. If I either select a date or enter it manually the date is shown right in the Inputfield. But as I want to get the Context like:

pStartDateOrig = wdContext.currentContextElement().getCtx_startDate();

, the Value is wrong. When I entered i.e. 07/25/2005, the debug mode shows me a value of 07-24-2005. That value is than stored wrong during the further processing. That bug does not appear permanently. Have anyone an idea? Is that a known bug. Any comments are welcome.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Andreas,

Everything works fine for me but i don't know why its not setting the correct date into ur xml file.can't u pass the value from the textview that shows u the correct date value?It should be andreas...........

Regards,

Nagarajan.

Former Member
0 Kudos

Hi Nagarajan

Thanks for your help. Yes I know it should pick up the right context, instead of counting one day of. The thing is there must be a bug in the get(Context). Because if you select a date, doesn't matter what, it is definately not the old context, but the new with one day earlier. I found a workaround what is not the right way to do, but for me it works. I now do not get the context, no, I get the value from the gui element, like:

startDateField = (IWDInputField) view.getElement("input_PStart");
  String startDateValue = startDateField.getValue();

That Value as String is the value that you see when selecting a date.

i.E I select 11/30/2005

the input field shows 11/30/2005

the value of the IWDInputField is : 11/30/2005

but the context that is mapped is : 11/29/2005

- And I don't do any process with the context, just mapped ! -

Anyway I hat a lot of struggles with that sql.date format that SAP use. IGS (Gantchart) wants the date in the form yyyyMMdd, instead MM/dd/yyyy. toString makes dd/MM/yyyy out of it so it is all mixed up within the wed dynpro framework.

My workaround works now and costs me nearly a day. Thanks a thousand times for your help, I really appreciate that. I will raise a OSS note and hope SAP will fix it. I will keep you informed and send you the Note number soon.

Regards, Normen

Former Member
0 Kudos

HI Andreas,

Thank u.Hope now everything goes on fine.

Regards,

Nagarajan.

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Andreas,

This should work properly,ok fine let us try step by step

1)create an input field and bind the contextatt to the i/p field.

2)create a text view and bind a context att to its text prop.

3) Implementation.

import java.sql.date;

Date x=wdContext.currentcontextelement.get(i/pfield cont att);

wdContext.currentcontextelement.<b>set(textviewcont att);</b>

Last post for setting i gave u the same i/p field context itself.sorry yar.

HOpe this works fine.

Regards,

Nagarajan.

Former Member
0 Kudos

Nagarajan,

Strange. The textview context is than set with the inputfield context within the wddoModifyView Method. So the textview element got the right date. But when I debug my code the context of the inputfield is still one day earlier. Why? Do you have any Idea how to solve it?

Former Member
0 Kudos

Andreas,

It puzzles me yar,I worked here to find out what is wrong.But everything is successful for me.so what might be the problem??????????why do u give this in the WDdomodifyview. Instead of that try adding a button and write the code inside the onaction of the button method to c how it gets displayed.

Don give up man try this for the last time it should be working.

If it is successful do tell me.

Regards,

Nagarajan.

Former Member
0 Kudos

Ok Mate

I tried it out. I put it into the save method that is triggered, when I push the save button.

 Date theDate = wdContext.currentContextElement().getCtx_startDate();
  
	 wdContext.currentContextElement().setDynamicDate(theDate);

Ctx_startDate is the date context that is read. DynamicDate is the context of the textview. Both are of the type Date.

I selected 07/30/2005

During debugging:

wdContext.currentContextElement().getCtx_startDate(); = 07/29/2005

theDate = 07/29/2005

the date that is saved in my xml file is 07/29/2005 but the textview that is bound to the DynamicDate should also be like the debugg value 07/29/2005 but it is 07/30/2005.

What is going on?

Former Member
0 Kudos

Thanks in advance a thousand times for your efforts mate

Former Member
0 Kudos

Andreas,

r u storing the date value in the xml file?what to do?we have tried every possibilities .may be the last one is try storing it on the dB directly and c or else move the value from one view to another view text element and c.

The problem comes only when u move the date value from one end to the other.confusing.Reward points if its success .

Do reply trying this.

Regards,

Nagarajan.

Former Member
0 Kudos

Nagarajan,

I collect the data from the inputfields and create a xml document, store it in KM. The costumer does not want a databasetable. But that is not the issue. When debugging the getContext gets a value that is one day less. the getter Method of SAP is the issue.... I gues

Regards, Normen

Former Member
0 Kudos

Andreas,

or else try to get the system date directly and store it.for getting the systemdate the query is getdate().

Atleast this is the least possibility we can try now.

Regards,

Nagarajan.

Former Member
0 Kudos

Hm?

I can not follow you? I do not want to have the current date. The User should pick a start, end and golive date of a project. So I need to get the context of the inputField..

Regards, Normen

Former Member
0 Kudos

Hi Andreas,

get the date in the input field,by selecting it from the automatic date selection itself and try to print it in the textview and c whether the entered date is correct or not.

the variable should not be string it should be date.

<b>Date</b> x=wdContext.currentcontextElement.get(contextatt);

wdContext.currentcontextElement.set(x);

Hope this helps u.

Regards,

Nagarajan.

Remember to import java.sql.date;

Former Member
0 Kudos

Hi Nagarajan

The code is like the following:

static Date pStartDateOrig = null;
pStartDateOrig = wdContext.currentContextElement().getCtx_startDate();

Ctx_startDate is the Context Element of the Type Date. So that should be ok. In order to get the Date selector I had to map the input field with that context element of the type date. As I select the Date with the selector (not typing manually), it is still the wrong date, one day less of the selected date.

I created a textview and mapped it also to that content, as you said. But it only shows you the initial content. Once you select a date, the textview isn't refreshed.

I also tried your method like :

Date startDate = wdContext.currentContextElement().getCtx_startDate();
		wdContext.currentContextElement().setCtx_startDate(startDate);

Which is unfortunately does not work. But what should it do? it gets the value of context and writes it again into it, or did I missunderstand your tip. Thanks, Andi