Skip to Content
Author's profile photo Former Member

Fiori Default Theme / FLP Customizing default theme parameter and Personalization (SPERS_OBJ)(/UI2/USER_PROFILE)

Fiori Default Theme / FLP Customizing default theme parameter and Personalization

As we know we can change the default theme parameter with tcode /UI2/NWBC_CFG_CUST.

This default theme parameter will be applied for the users who have not changed their theme from user preferences previously.

Let’s assume that customized and defaulted theme is THEME_A. The users who have not changed their theme through Fiori->User Preferences will see THEME_A as their default theme. But if they change their theme to some other theme like THEME_B through Fiori->User Preferences they will not get effected from customized default theme. They will be seeing THEME_B whatever the default theme is. This is because of the personalization data which is defaulted for the user with the activity of changing theme.
We can see the values in table SPERS_OBJ with keys ‘PERS_KEY’ as ‘/UI2/USER_PROFILE’ and ‘OBJECT_ID’ as username.

If we have a value set for the user in this tabke it will not get the defaulted theme from customizing. And will use the theme defined here.
There are multiple ways to handling this issue. Two ways explained for quick reference.

1-)  From SU01 – Personalization Tab you can reset the values for ‘/UI2/USER_PROFILE’. This activity will delete the table records in SPERS_OBJ with keys ‘PERS_KEY’ as ‘/UI2/USER_PROFILE’ and ‘OBJECT_ID’ as username and customized default theme will be shown instead.

2-)For mass operations on personalization data specific to the theme in order to update ‘/UI2/USER_PROFILE’ value for users you can use a program as below. You can also enhance the program different way of usages.

REPORT zfiori_theme.

TABLES: suid_st_bname.
DATA: lt_spers_obj TYPE TABLE OF spers_obj WITH HEADER LINE.
DATA: lv_spers_fld TYPE spers_fld.

DATA: BEGIN OF tp_s_user_profile_base,
        uname           TYPE syuname,
        id              TYPE string,
        shell_type      TYPE string,
        value           TYPE string,
        data_type       TYPE string,
        edit_state      TYPE i,
        validation_mask TYPE string,
      END OF tp_s_user_profile_base .
DATA: s_obj  TYPE RANGE OF spers_obj-object_id,
      sr_obj LIKE LINE OF s_obj.

DATA: lv_uname TYPE sy-uname.
DATA: pers_data      LIKE TABLE OF tp_s_user_profile_base,
      pers_data_list TYPE spers_adt.

SELECT-OPTIONS: s_user FOR suid_st_bname-bname.
PARAMETERS p_theme TYPE /ui2/nwbc_cfg_param_value.

START-OF-SELECTION.

  LOOP AT s_user REFERENCE INTO DATA(lsr_user).
    CLEAR: sr_obj.
    sr_obj-sign = lsr_user->sign.
    sr_obj-option = lsr_user->option.
    sr_obj-low = lsr_user->low.
    sr_obj-high = lsr_user->high.
    APPEND sr_obj TO s_obj.
  ENDLOOP.

  SELECT * FROM spers_obj INTO TABLE lt_spers_obj
    WHERE pers_type EQ 'U'
      AND object_id IN s_obj
      AND pers_key EQ '/UI2/USER_PROFILE'
      AND fieldname EQ 'VALUE'.

END-OF-SELECTION.

  lv_spers_fld = p_theme.

  LOOP AT lt_spers_obj.

    CLEAR: pers_data, pers_data[], lv_uname.

    lv_uname = lt_spers_obj-object_id.

    CALL METHOD cl_pers_admin=>get_data
      EXPORTING
        p_pers_key       = '/UI2/USER_PROFILE'
        p_uname          = lv_uname
        p_user_data_only = ' '
      IMPORTING
        p_pers_data      = pers_data
        p_pers_data_list = pers_data_list.

    LOOP AT pers_data ASSIGNING FIELD-SYMBOL(<fs_pers>).
      <fs_pers>-value = lv_spers_fld.
    ENDLOOP.

    CALL METHOD cl_pers_admin=>set_data
      EXPORTING
        p_pers_key          = '/UI2/USER_PROFILE'
        p_uname             = lv_uname
        p_pers_data         = pers_data
      EXCEPTIONS
        pers_key_not_found  = 1
        data_type_error     = 2
        user_does_not_exist = 3
        not_set_to_default  = 4
        pers_key_locked     = 5
        OTHERS              = 6.
    IF sy-subrc EQ 0.
      WRITE:/ lv_uname, (50) 'Updated'.
    ELSE.
      WRITE:/ lv_uname, (50) 'NON-Error'.
    ENDIF.
  ENDLOOP.

Assigned Tags

      5 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Wouter Lemaire
      Wouter Lemaire

      Great blog post! Resetting the values using SU01 didn't work for me. Deleting in the table did the trick! Many thanks for sharing!

       

      Author's profile photo Tim Holtschneider
      Tim Holtschneider

      Hi,

      I enhanced the report above to be able to delete personalization and change only where necessary.

      *&---------------------------------------------------------------------*
      *& Report ZFIORI_THEME
      *&---------------------------------------------------------------------*
      *& The report will set a default Fiori Theme to all chosen users.
      *&---------------------------------------------------------------------*
      REPORT zfiori_theme.
      
      TABLES: usr02.
      
      TYPES: BEGIN OF tp_s_user_profile_base,
               uname           TYPE syuname,
               id              TYPE string,
               shell_type      TYPE string,
               value           TYPE string,
               data_type       TYPE string,
               edit_state      TYPE i,
               validation_mask TYPE string,
             END OF tp_s_user_profile_base,
             BEGIN OF tp_usr,
               bname TYPE xubname,
             END OF tp_usr.
      
      DATA: lv_uname          TYPE sy-uname,
            lt_usr            TYPE TABLE OF tp_usr,
            lt_pers_data      TYPE TABLE OF tp_s_user_profile_base,
            lt_pers_data_list TYPE spers_adt.
      
      FIELD-SYMBOLS: <fs_usr>  TYPE tp_usr,
                     <fs_pers> TYPE tp_s_user_profile_base.
      
      
      SELECT-OPTIONS: s_user FOR usr02-bname OBLIGATORY.
      PARAMETERS:
        p_del   TYPE c AS CHECKBOX,
        p_theme TYPE /ui2/nwbc_cfg_param_value LOWER CASE MATCHCODE OBJECT /ui5/themes OBLIGATORY.
      
      
      START-OF-SELECTION.
      
        SELECT bname FROM usr02 INTO TABLE lt_usr
          WHERE bname IN s_user
            AND gltgb GE sy-datum.
      
      
      END-OF-SELECTION.
      
        TRANSLATE p_theme TO LOWER CASE.
      
        LOOP AT lt_usr ASSIGNING <fs_usr>.
      
          CLEAR: lt_pers_data, lt_pers_data[], lv_uname.
          lv_uname = <fs_usr>-bname.
      
      
      
          CALL METHOD cl_pers_admin=>get_data
            EXPORTING
              p_pers_key          = '/UI2/USER_PROFILE'
              p_uname             = lv_uname
              p_user_data_only    = ' '
            IMPORTING
              p_pers_data         = lt_pers_data
              p_pers_data_list    = lt_pers_data_list
            EXCEPTIONS
              pers_key_not_found  = 1
              data_type_error     = 2
              no_data_found       = 3
              user_does_not_exist = 4
              not_set_to_default  = 5
              OTHERS              = 6.
      
          " Delete personalization
          IF sy-subrc EQ 0 AND p_del EQ abap_true.
            cl_pers_admin=>delete_data_user(
              EXPORTING
                p_pers_key          = '/UI2/USER_PROFILE'
                p_uname             = lv_uname
              EXCEPTIONS
                pers_key_not_found  = 1
                user_does_not_exist = 2
                not_set_to_default  = 3
                internal_error      = 4
                OTHERS              = 5 ).
            IF sy-subrc EQ 0.
              WRITE:/ lv_uname, (50) '- theme personilzation deleted for user'.
            ELSE.
              WRITE:/ lv_uname, (50) '- ERROR during deletion'.
            ENDIF.
      
            " Add personalization
          ELSEIF sy-subrc NE 0 AND p_del NE abap_true.
      
            "Only apply changes of theme
            READ TABLE lt_pers_data WITH KEY value = p_theme TRANSPORTING NO FIELDS.
            IF sy-subrc NE 0.
      
              " user does not have any personalization yet.
              IF lt_pers_data IS INITIAL.
                APPEND INITIAL LINE TO lt_pers_data ASSIGNING <fs_pers>.
                <fs_pers>-uname      = lv_uname.
                <fs_pers>-id         = 'THEME'.
                <fs_pers>-shell_type = 'FLP'.
                <fs_pers>-value      = p_theme.
                <fs_pers>-edit_state = 0.
              ELSE.
                LOOP AT lt_pers_data ASSIGNING <fs_pers>.
                  <fs_pers>-value = p_theme.
                ENDLOOP.
              ENDIF.
      
              CALL METHOD cl_pers_admin=>set_data
                EXPORTING
                  p_pers_key          = '/UI2/USER_PROFILE'
                  p_uname             = lv_uname
                  p_pers_data         = lt_pers_data
                EXCEPTIONS
                  pers_key_not_found  = 1
                  data_type_error     = 2
                  user_does_not_exist = 3
                  not_set_to_default  = 4
                  pers_key_locked     = 5
                  OTHERS              = 6.
      
              IF sy-subrc EQ 0.
                WRITE:/ lv_uname, (50) '- theme updated for user'.
              ELSE.
                WRITE:/ lv_uname, (50) '- ERROR: theme not assigned to user'.
              ENDIF.
      
            ELSE.
              WRITE:/ lv_uname, (50) '- theme already assign to user'.
            ENDIF.
          ELSE.
            WRITE:/ lv_uname, (50) '- no changes made'.
          ENDIF.
        ENDLOOP.

       

      Author's profile photo Siegfried Weber
      Siegfried Weber

      Hi Tim,

      Thanks a lot.

       

      This Report helps a lot.

      Kind regards

      Sigi

      Author's profile photo Naresh Chandan N R
      Naresh Chandan N R

      Hello Tim Sir,

      This report of yours has saved my ass. Thank you much.

      Best Regards,

      Naresh

      Author's profile photo Walter Smith
      Walter Smith

      Great blog post, thank you.

      Walter Smith2

      Walter Smith2

      Yaniv Bar