cancel
Showing results for 
Search instead for 
Did you mean: 

date format

Former Member
0 Kudos

Hello all,

I have input fields bound to context of simple type date in my web dynpro application. The default date format is MM/dd/yyyy. However the first time I select a date it turns to dd.MM.yyyy. Subsequent clicks return to MM/dd/yyyy. However when the dd.MM.yyyy format is being displayed I cannot hit the submit button to perform action(it gives me an error 'please give value in form MM/dd/yyyy') How can i fix this?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

vijayakhanna_raman
Active Contributor
0 Kudos

Hi vijay

Send your code so that the actual problem can be found.

Regards

Vijayakhanna Raman

Former Member
0 Kudos

Hello Raman,

I do not have any code. I just created a context value of type date and assiged it to an input field.

Thank You

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Vijay,

I got this problem when I was trying to set a date in a particular format. I also had input fields bound to context of simple type date in my web dynpro application.

For the first time, it comes in dd/MM/yyyy but in subsequent times it changes back to MM/dd/yyyy.

But since my requirement was to have the Date Format to a particular type dd/MM/yyyy. I fixed it by changing the user language everywhere.

If you also want to have a fixed date format, you can refer to my reply in this post

Thanks & Regards,

Shubham

Former Member
0 Kudos

Hello Subham,

Thank you for your answer.I have a few questions though.

1)How do i change the userlanguage in the Web AS?

2)Since I would have no control over the regional settings of the User how can i work around this problem?

Thanks

Former Member
0 Kudos

Hello Vijay,

The user language can be changed in user admin of WAS. Click on Modify icon after listing and selecting the user.

To do regional settings on users machine is always tough as the customers do not want to do that on user machines.

We released a document to the customer stating how to set the required date format for a user.

If that is tough in your case then the only two options:

1) You have to create a local dictionary type in your project of type date. In the Enumeration Tab hard code the format you want. With this the restriction is that you will have date in only one format and user if want to change the format they have to change the code.

2) Set the date format programatically.

SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");

String datString= "20040131";

try{

java.util.Date parsedDate = df.parse(datString);

}

catch (ParseException ex){

}

Here you have an option to give a configuration view to the user where he can set the date format. Here instead of hardcoding the dateformat you read the user input from the same place where you earlier stored user entered format(say R/3 table or PCD if you are using portals).

Hope this helps.

Regards,

Shubham

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Shubham,

let me just give you some background information on how the Web Dynpro Runtime determines the current session locale. I also describe the locale issue when using JCO destinations.

Regards, Bertram

<b>1) How is the language determined when using a JCODestination (logical System name)?</b>

SY-LANGU in R/3 is determined by the language, which is used to connect to the R/3 system (via a JCO Client Connection). The methods used to determine this language on the J2EE side are the following:

<b>A)</b> If the JCO Client Connection was determined manually via API by the application developer and associated manually (WDDynamicRFCModel.setJcoClient(JCO.Client client) ), then exactly the language used to create the JCO Client is used. Unless the application has programmed this appropriately, the language CAN NOT be modified or configured at a later point in time => this method should not be used for productive scenarios, but is ok for demos and prototyping!

<b>B)</b> If a logical system name was configured and is being used (this is the case by default when using Adaptive RFC), then the destination must be configured using the WD ContentAdmin. It is possible to configure two different logon methods:

- SSO User: In this case, the language is determined from the (J2EE) logon user's locale.

- defined User: The logon user's locale IS NOT used to determine the language! In this case, the language configured in the WD Content Admin is used when connecting to R/3. <u><i>Exception</i>: It is possible to leave the language empty. In this case the below specified method for determining the locale is used. The determined locale will then be used to determine the language to use for the JCO Client Connection</u>.

<b>2) How ist the current locale determined on the J2EE side? </b>

Web Dynpro Applications run either in authenticated mode, or in anonymous mode (no authentication)

To run a WD Application in authenticated mode, the application property "sap.authentification" must be set to "true". (Select Application in the IDE-> Tab "Application Properties" -> "New" -> "Pre Defined" -> press "Browse" -> select "Authentication" -> "OK" -> Value "true"

Determination of the locale depends entirely on whether running in authenticated mode or in anonymous mode:

<u><i>Anonymous (Authentication="false"):</i></u> WD does not know which user is logged on, therefore it can not determine the user's configured locale. Instead, WD attempts to determine the locale from the browser. This usually works (depending on browser, operating system and selected rendering technology, e.g. SSR or Smart Client) This is based on the Regional Settings (at least in Windows). Nevertheless, only the language and the country are determined by the regional settings, other information is ignored (such as currency format or decimal places, etc.)

<u><i>Authentication="true":</i></u> in this case, WD presumes a successfully logged on user. If no user yet exists, then the user can be created using the User Management. The default is to use the SAP J2EE Engine's local User management, which allows creating users directly via the user logon screen, when starting a WD application in a new browser session. When creating a user, the country and language can be selected. It would therefore also be possible, to select "German" in the country "Switzerland", for example. If this were the case, then data would be displayed and formatted using Swiss conventions (such as Time, Date, Currencies, Decimals, etc.)

In productive scenarios, applications normally run in authenticated mode, while development and testing often takes place in a anonymous mode. This may lead to different language determination and therefore different behavior.

=> the Regional Setting of the browser/operating system should not be interpreted as the central place to configure the locale settings, but rather the user specific settings configured in the User Management (UME)

Last but not least it remains to be mentioned, that if a WD app is running in the portal, then the configured locale of the portal user is used (or the default locale of the portal) This is true both for anonymous as well as authenticated WD applications.

Former Member
0 Kudos

Hello Bertram,

My Web Dynpro applications are running within the portal. As you say they should use the portal locale , but even then the date format changes on the first time I use the date picker and reverts back to is original format only on the second pick. I still can't figure out how to resolve this.

Regards

Answer from Bertram Ganz:

Hi,

Thank you for this question. What you are reporting looks to me like a bug in the system. The channel for such questions is the Service Marketplace http://service.sap.com/. Please post it there.

Best regards, Bertram

Message was edited by: Bertram Ganz

Former Member
0 Kudos

Hi Bertram,

Thanks a lot for giving the detailed insight on this issue.

Just few more questions.

Suppose when creating the user's, we do not select the country and user language. Then how does this works?

Another question is if I have multiple browser language, with and without the above condition, then how does it works?

Thanks a lot again for your detailed explanation.

Regards,

Shubham

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Shubham,

The following section (extracted from the <a href="http://help.sap.com/saphelp_nw04/helpdata/en/f4/d95664da179b4db731e21c2e470b72/frameset.htm">Web Dynpro documentation in the SAP NetWeaver Online Help</a>) describes the mechanism used by the Web Dynpro Java Runtime to calculate the session locale:

The session locale is the locale that is specified for the current user by the user management engine (UME). The fallback sequence is:

<i>1) In case of an authenticated or anonymous user, the locale specified by the URL-parameter sap-locale is returned.

<b>Note:</b>

The URL-parameter sap-locale should only be used by the application developer for testing purposes. In live scenarios the session locale should be specified based on either the user, the browser or the application locale.

2) In case of an authenticated user, the locale specified for this user is returned.

3) Otherwise, the locale specified by the browser settings ("accept-language" HTTP header) is returned if existing.

4) Otherwise the default locale specified in the application properties is returned if existing.

5) Otherwise the default locale specified in the Web Dynpro system properties is returned if existing.

6) Otherwise the default locale of the VM is returned.</i>

The session locale calculated by the Web Dynpro Runtime (last column) is passed as input to the java.lang.ResourceBundle class loaded by the SAP J2EE Engine. This class uses the following fallback sequence to load a physically existing resource bundle:

  • load resource bundle for WD calculated locale

  • if not existing: load resource bundle for the default locale of the VM

  • if not existing: load resource bundle without language suffix, which always exists

<b>Important Note</b> – <u><i>Session locale and Portal integration</i></u>

When the Web Dynpro application is running inside the SAP Enterprise Portal the session locale is retrieved via URL-parameter. In this case the locale calculation processes described in the above table is not done by the Web Dynpro Runtime.

<b>Note</b> – <u><i>Session locale, URL-parameter sap-locale and client session</i></u>

The locale information is associated to the client session not to the Web Dynpro application (addressed via URL). A new client session can be created by clicking the explorer icon in the Windows toolbar. CTRL+N does not work, because in this case only a new client window instance is being created. The URL-parameter sap-locale is only read once per client session.

Best regards, Bertram

Former Member
0 Kudos

This is a bug, open an OSS on it. I had similar problems with date field bindings but it was to do with rendering.