Page tree
Skip to end of metadata
Go to start of metadata

Business context

The CRM WebUI provides a list called "Recent Items" starting with SAP CRM 7.0. Users can personalize the number of displayed via Personalize -> Personalize Navigation Bar -> Recent Items:

By default this Value is set to 5. It seems that there is no customizing possibility to change the default of this value for all users of a Business Role. With the help of Stephen Johannes sending this tweet I was able to provide a solution.

Alternative Solution

When you've applied the Note 1701936 - Enabling system wide personalization then you can use transaction SPERS_MAINT to set this parameters.

Solution

*&---------------------------------------------------------------------*
*& Report  Z_SET_CRM_PERS_RECENT_OBJECTS
*&
*&---------------------------------------------------------------------*
*& Set Personalization Object CRM_PERS_RECENT_OBJECTS
*& based on the info from help.sap.com:
*&
*& Maintaining Personalization Objects Automatically
*& http://help.sap.com/saphelp_crm70/helpdata/EN/48/c6e7447a004da5e10000000a421937/frameset.htm
*&
*&---------------------------------------------------------------------*

REPORT  z_set_crm_pers_recent_objects.

CONSTANTS: pers_key TYPE spers_key VALUE 'CRM_PERS_RECENT_OBJECTS'.
DATA: users    TYPE TABLE OF str_agrs.
FIELD-SYMBOLS: <fs_user>  LIKE LINE OF users.
DATA: number_ok  TYPE i,
      user_error TYPE i.

DATA: lt_recobj_pers TYPE crmt_ui_recobj_pers,
      ls_recobj_pers TYPE crms_ui_recobj_pers.


PARAMETERS: role    TYPE agr_name,
            ui_prof TYPE crmt_ui_profile,
            max_num TYPE crm_pers_recent_objects_num DEFAULT 10.

START-OF-SELECTION.

  CALL FUNCTION 'ESS_USERS_OF_ROLE_GET'
    EXPORTING
      role       = role
    TABLES
      role_users = users.

  ls_recobj_pers-profile = ui_prof.
  ls_recobj_pers-max_num  = max_num.
  APPEND ls_recobj_pers TO lt_recobj_pers.

  LOOP AT users ASSIGNING <fs_user>.

    " set data
    CALL METHOD cl_pers_admin=>set_data
        EXPORTING
          p_pers_key          = pers_key
          p_uname             = <fs_user>-uname
          p_pers_data         = lt_recobj_pers
*          p_append            = 'X'
*          p_modify            = 'X'
*          p_write_through     = 'X'
        EXCEPTIONS
          pers_key_not_found  = 1
          data_type_error     = 2
          user_does_not_exist = 3
          OTHERS              = 4.
    CASE sy-subrc.
      WHEN 0.
        ADD 1 TO number_ok.
      WHEN 1.
        WRITE: / 'pers_key_not_found for user', <fs_user>-uname.
        ADD 1 TO user_error.
      WHEN 2.
        WRITE: / 'data_type_error for user', <fs_user>-uname.
        ADD 1 TO user_error.
      WHEN 3.
        WRITE: / 'user_does_not_exist', <fs_user>-uname.
        ADD 1 TO user_error.
    ENDCASE.
  ENDLOOP.

  WRITE: / 'Sucessfull changed Users: ', number_ok.
  WRITE: / 'Users with errors: ', user_error.

1 Comment

  1. Unknown User (103f71w7t)

    Nice work Gregor and Stephen, this is a very useful tip.