Ensure that user settings are aligned with source data

Jimbo's picture

SAP expects date and number information to be formatted a certain way, but it varies based upon local standards and is configured for each client. When writing software and testing in a development system the software depends on the localized standards in the programmer's User Profile. The User Profile can be changed using transaction SU3 or by clicking through the menu with System → User Profile → Own Data.

If the quality assurance or production systems have different localizations by default or if the software is to be run by somebody other than the programmer it can cause catastrophic failures. For example, in the US the number system has a period for the decimal point and a comma for the thousands separator. The number 1,000 when handed to SAP with a European User Profile would not be 1 instead of 1000. SAP using a European User Profile interprets the comma as a decimal separator and ignores the periods. The date 11/12/2011 could be November 12th in the United States or December 11th in the EU.

An easy way to ensure that the user profile loading the data has the correct localizations is to check the settings when converting data. The user settings are kept in the USR01 table as shown below. This example is for a hybrid profile that uses the DDMMYYYY format from Europe and the US decimal format.

Add this snippet of code to the User-Defined Routines section of the LSMW project or in the FORM_ROUTINES section of the LSMW object. It compares compares the localizations of the currently-logged-in user to the desired settings and warns when they are not aligned. Change the DATFM and DCPFM for the desired date format and decimal format respectively.

Form CheckSettings.
  data: lvUSR01 like USR01.

  select * from USR01 into lvUSR01 where BNAME eq sy-uname.
    if lvUSR01-DATFM ne '1'.
      write: / 'The date format for this user is not set correctly.'
       color col_negative.
    if lvUSR01-DCPFM ne 'X'.
      write: / 'The decimal format for this user is not set correctly.'
       color col_negative.

Add this snippet to the BEGIN_OF_PROCESSING section of the LSMW object. This calls the form that we created above. It's that simple.

perform CheckSettings.
Programming Language: