SAP HR-Default Employee Watermark

Employees pictures are being displayed in various application in SAP, including Fiori apps. When there isn’t any picture loaded in SAP for an employee there are two different watermarks that appear in the picture frame. These watermarks are nothing but male.jpg and female.jpg images loaded in MIME repository. Watermark to be used is decided based on flag P0002-GESCH. If P0002-GESCH = female then use female.jpg else male.jpg.

/SAP/PUBLIC/BUSINESSSUITE/TM/ICONS/female.jpg /SAP/PUBLIC/BUSINESSSUITE/TM/ICONS/female.jpg
/SAP/PUBLIC/BUSINESSSUITE/TM/ICONS/male.jpg /SAP/PUBLIC/BUSINESSSUITE/TM/ICONS/male.jpg

Of course, this logic may not fit on all cases and change would be required. Below information is useful to make such changes.

Two places where I have found (and had to make changes) these images are being supplied to front-end.

Class CL_HCM_PHOTO_API

Fiori applications uses method CL_HCM_PHOTO_API=>GET_EMPLOYEE_PHOTO to get employees picture. Within this method logic branch out to method CL_HCM_PHOTO_API=>GET_DUMMY_PHOTO to get default male/female picture in case picture of employee is not in database.

Method CL_HCM_PHOTO_API=>GET_DUMMY_PHOTO is where call is made to get Infotype 0002 of employee check their gender and URL of image is passed over.

TRY.
      CALL METHOD lo_read_infotype->read_single
        EXPORTING
          tclas         = cl_hrpa_tclas=>tclas_employee
          pernr         = iv_pernr
          infty         = '0002'
          subty         = space
          objps         = space
          sprps         = if_hrpa_read_infotype=>unlocked
          begda         = sy-datlo
          endda         = sy-datlo
          mode          = if_hrpa_read_infotype=>last_intersecting_record
          no_auth_check = abap_true
        IMPORTING
          pnnnn         = ls_p0002.
    CATCH cx_hrpa_violated_assertion.
      CLEAR ls_p0002.
  ENDTRY.

  IF ls_p0002-gesch = '2'. "female
    lo_client->request->set_header_field( name  = '~request_uri'
                                          value = gv_url_female ).
  ELSE. "male or unknown
    lo_client->request->set_header_field( name  = '~request_uri'
                                          value = gv_url_male ).
  ENDIF.

Class CL_HRPAD_IL

Webdynpro ESS applications uses class CL_HRPAD_IL=>GET_PHOTO to get employees picture and this is where URL of default picture is returned if FM HRWPC_RFC_EP_READ_PHOTO_URI failed to get employees picture.

      CALL METHOD cl_hrpa_masterdata_factory=>get_read_infotype
        IMPORTING
          read_infotype = lr_read_infotype.
      CALL METHOD lr_read_infotype->read_single
        EXPORTING
          tclas         = 'A'
          pernr         = iv_pernr
          infty         = '0002'
          subty         = space
          objps         = space
          sprps         = if_hrpa_read_infotype=>unlocked
          begda         = sy-datlo
          endda         = sy-datlo
          mode          = if_hrpa_read_infotype=>last_intersecting_record
          no_auth_check = abap_true
        IMPORTING
          pnnnn         = ls_p0002
*         PNNNN2        =
*         PREF          =
*         DATA_EXISTS   = ls_data_exists
*         MISSING_AUTH  =
        .
      IF ls_p0002 IS NOT INITIAL.
        IF ls_p0002-gesch = '2'.
          ev_photo_url = '/SAP/PUBLIC/BUSINESSSUITE/TM/ICONS/female.jpg'.
        ELSE. " Male OR unkown
          ev_photo_url = '/SAP/PUBLIC/BUSINESSSUITE/TM/ICONS/male.jpg'.
        ENDIF.
      ENDIF.

Below are some more method where this happens but I am not aware where are they used.

CL_HIER_VIS_PHOTO_URL

Method GET_PHOTO_URLS

READ TABLE lt_person_id INTO ls_person_id WITH KEY cp_id = ls_temp_url-cp_id.
IF ls_person_id-sex = '1'. "Female
    CONCATENATE lv_absolute_url gc_pic_url_female INTO ls_photo_url-pic_url.
ELSE. " Male (OR) unknown
    CONCATENATE lv_absolute_url gc_pic_url_male_or_default INTO ls_photo_url-pic_url.
ENDIF.

Class CL_HRASR00_FPM_UTILITIES – HCM P&F FPM Utility Class

Method GET_DEFAULT_PHOTO

    READ TABLE <lt_p0002> INTO <ls_p0002> INDEX 1.
    IF sy-subrc IS INITIAL.
      ASSIGN COMPONENT 'GESCH' OF STRUCTURE <ls_p0002> TO <lv_gender>.
*   get picture
      IF <lv_gender> = 1."male
        CONCATENATE  c_icon_uri c_male INTO ev_pic_uri.
      ELSE.
        CONCATENATE  c_icon_uri c_female INTO ev_pic_uri.
      ENDIF.
    ENDIF.

CL_HRASR00_PB_SPROFILE_PIC – Short Profile utility class

Method GET_DEFAULT_PHOTO

    TRY.
        CALL FUNCTION 'HR_READ_INFOTYPE'
          EXPORTING
            pernr           = iv_pernr
            infty           = '0002'
            begda           = sy-datum
            endda           = sy-datum
          TABLES
            infty_tab       = <lt_p0002>
          EXCEPTIONS
            infty_not_found = 1
            OTHERS          = 2.
        READ TABLE <lt_p0002> INTO <ls_p0002> INDEX 1.
        IF sy-subrc IS INITIAL.
          ASSIGN COMPONENT 'GESCH' OF STRUCTURE <ls_p0002> TO <lv_gender>.
*       get picture
        IF <lv_gender> = 1."male
          CONCATENATE  c_icon_uri c_male INTO ev_pic_uri.
        ELSE.
          CONCATENATE  c_icon_uri c_female INTO ev_pic_uri.
        ENDIF.
        ENDIF.

      CATCH cx_sy_dyn_call_illegal_func.
        RETURN.
    ENDTRY.

CL_HRPAO_SHORTPRF_UTILITY – Utility class for PAO Short profile

Method GET_PHOTO_URL_FOR_OBJECT

      CALL METHOD cl_hrtmc_cp_basic_utilities=>get_picture_url
        EXPORTING
          iv_person_id    = ls_hrperson-personid
          iv_pernr        = lv_pernr
          iv_sex_value    = lv_gender
        IMPORTING
          ev_picture_url  = ev_photo_url.

      " Check if photo is real one or default
      IF ev_photo_url IS NOT INITIAL.
        IF ev_photo_url CS 'male.jpg' OR ev_photo_url CS 'female.jpg'.
          IF ls_p0002-gesch = '2'. "Female
            ev_photo_url = gc_pic_url_female.
          ELSE. " Male (OR) unknown
            ev_photo_url = gc_pic_url_male_or_default.
          ENDIF.
          ev_photo_available = abap_false.
        ELSE.
          ev_photo_available = abap_true.
        ENDIF.
      ELSE.
        IF ls_p0002-gesch = '2'. "Female
          ev_photo_url = gc_pic_url_female.
        ELSE. " Male (OR) unknown
          ev_photo_url = gc_pic_url_male_or_default.
        ENDIF.
        ev_photo_available = abap_false.
      ENDIF.

CL_HRTMC_CP_BASIC_UTILITIES – Utility Class for Talents

Method : GET_PICTURE_URL

    IF lv_sex_value = 1.                               "XREN1387230
      lv_dummy_icon_id = gc_female_mime_pic.
    ELSE.
      lv_dummy_icon_id = gc_male_mime_pic.
    ENDIF.

CL_HR_STREAMWORK_API – Streamwork Integration APIs

Method : GET_BACKEND_USER_PHOTO_URL

        CALL METHOD lo_read_infotype->read_single
          EXPORTING
            tclas         = 'A'
            pernr         = lv_pernr
            infty         = '0002'
            subty         = space
            objps         = space
            sprps         = if_hrpa_read_infotype=>unlocked
            begda         = sy-datum
            endda         = sy-datum
            mode          = if_hrpa_read_infotype=>last_intersecting_record
            no_auth_check = abap_false
          IMPORTING
            pnnnn         = ls_p0002.

        IF ls_p0002 IS NOT INITIAL.
          IF ls_p0002-gesch = '2'. "Female
            ev_user_photo_url = gc_pic_url_female.
          ELSE. " Male (OR) unknown
            ev_user_photo_url = gc_pic_url_male_or_default.
          ENDIF.
        ELSE." Male (OR) unknown
          ev_user_photo_url = gc_pic_url_male_or_default.
        ENDIF.

Leave a Reply