Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member188598
Contributor
0 Kudos

ISSUE: The usage of DOT/COMMA as decimal separator (radix point) is different in different geographies. We faced issues where user cannot fill a decimal numeric field due to the IE /portal language setting defined for the user. For most users in SAP NetWeaver Portal, the user profile was not updated with preferred language,and the browser settings determined the preferred language when user logged in to the application. for e.g., a user with Polish language setting in browser trying to use DOT as decimal separator got below error for format as inPolish comma is considered as decimal formatter.

SAP WAS Dot/Comma is determined by the local settings of the application language. The determination is based on the following order of preference:

  1. Language indicator for the user – set in the portal profile
  2. Language preference set in the browser
  3. Language set for Web Dynpro Application
  4. Language set for the System – OS level
  5. Language set for Java Virtual Machine 


SOLUTION: The solution was implemented by making code changes to determine user locale and convert the number based on locale.

  • Here on application load, the behaviour of  the number format was determined by above mentioned order of preference of local language settings.
  • The number format for all numeric type inputs then is changed based on the language settings
  • When user action like validate/save/submit happens, the source code internally determines the number format based on user settings and differentiates between dot/comma as decimal separator and passes the information for further processing.

Below is the sample code snippet used:

Convert the numeric value to string first:

                  String ValToConvert = String.valueOf(numeric field);

Create a method for checking Locale and pass this string as a parameter:

                  public java.lang.String mLocaleBasedFormatNumber( java.lang.String ValToConvert )  {

                   //@@begin mLocaleBasedFormatNumber()

                             String ConvertedVal = null;

                                 try

                                         {

                                                   java.util.Locale sessionLocale = WDClientUser.getCurrentUser().getLocale();
                                                    if(null == sessionLocale){
                                                       sessionLocale = WDResourceHandler.getCurrentSessionLocale();
                                                                                              }
                                            NumberFormat formatter = NumberFormat.getNumberInstance(sessionLocale);
                                            if(null != ValToConvert && !"".equalsIgnoreCase(ValToConvert.trim()))

                                                                                          {
                                             Number number = formatter.parse(ValToConvert);

                                             ConvertedVal = number.toString();
                                                                                                 }

                                             }                             
                                                catch (Exception e) {
                                                                                 wdComponentAPI.getMessageManager().reportException(e.getMessage());

                                                                              }

                  return ConvertedVal;
                    //@@end
            }

Labels in this area