Human Capital Management Blogs by Members
Gain valuable knowledge and tips on SAP SuccessFactors HCM suite and human capital management market from member blog posts. Share your insights with a post of your own.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
3,159
Migrating employee photos from SAP HR to SuccessFactors can be done in multiple ways.

  1. Bulk download photos from SAP and upload to SuccessFactors

  2. Use the ODATA  API.

  3. Link to photos hosted on a different web server


Every method has it's advantages and disadvantages and the best approach will depend on the customer's requirement.

In this article, we will look at approach 1, which downloads all the photos available in SAP and uploads them to SuccessFactors. The details and prerequisites are explained well in note 2094242.

Prerequisites

Bulk photo upload through SuccessFactors SFTP is available only to Enterprise Subscription clients only and not for Professional Edition at the time of this writing. Please read through 2094242 for updated information.

Steps

  • Copy and create program ZMIGRATE_EMP_PHOTOS_SFSF in your production system

  • Execute for desired selection of employees. The program supports both online and batch modes

  • The program output contains the following

    • Downloaded Employee photos

    • CSV metadata file necessary for batch upload in SFTP

    • Failures if any in ALV



  • Once the photos and metadata csv file are downloaded, upload them onto your SuccessFactors SFTP folder under /photos. Reach out to Cloud Product Support in case of any issues.

  • Once the upload is processed, SuccessFactors system will send an email with the job results.


It is also possible to further modify this program to support option 3 using  FM SCMS_AO_URL_READ. This FM returns the url links to photos and this will also need further configuration w.r.t crossdomain access. Please look at CL_HIER_VIS_PHOTO_URL->GET_PHOTO_URLS if you would like to explore this.

Welcome any comments / suggestions. Hope this adds to your SFSF migration arsenal.
*&---------------------------------------------------------------------*
*& Report ZMIGRATE_EMP_PHOTOS_SFSF
*&
*&---------------------------------------------------------------------*
*& Program to Migrate Employee Photos from SAP to SuccessFactors
*& Photo download based on FM PAD_PHOTO_UPDATE_GET_DETAIL
*& Metadata file and Photo signatures based on SAP note 2094242
*&---------------------------------------------------------------------*

REPORT zhtr_emp_photo_dwnld.
DATA: lt_connections TYPE TABLE OF toav0.
DATA: ls_connections TYPE toav0.
DATA: lv_doc_type TYPE toadd-doc_type.
DATA: ls_return TYPE bapiret2.
DATA: ls_employee_number TYPE toav0-object_id.

DATA: lc_update_start_date TYPE sy-datum VALUE '18000101'.
DATA: lc_update_end_date TYPE sy-datum VALUE '99991231'.

DATA: lt_photo_archive TYPE TABLE OF tbl1024.
DATA: ls_photo_archive TYPE tbl1024.
DATA: lt_messages TYPE bapiret2_tab.
DATA: lv_filename TYPE string.
DATA: lt_out_file TYPE TABLE OF string.
DATA: lv_out_file TYPE string.

DATA: BEGIN OF gt_pernr OCCURS 0,
pernr LIKE pernr-pernr,
uname LIKE p0105-usrid.
DATA: END OF gt_pernr.


NODES:pernr, peras, person.
INFOTYPES: 0105.

PARAMETERS: p_file TYPE rlgrap-filename.

GET peras.
* Collect the Employees based on selection
rp_provide_from_last p0105 '0001' pn-begda pn-endda.
gt_pernr-uname = p0105-usrid.
gt_pernr-pernr = peras-pernr.
APPEND gt_pernr.



END-OF-SELECTION.
lv_out_file = 'Username,Filename'.
APPEND lv_out_file TO lt_out_file.
* Prepare and dowload files
PERFORM get_and_store.
* Display errors
PERFORM display_alv.


*&---------------------------------------------------------------------*
*& Form get_and_store
*&---------------------------------------------------------------------*
* Retrieve Photos and download files
*----------------------------------------------------------------------*
FORM get_and_store.
LOOP AT gt_pernr.
CLEAR: ls_employee_number, ls_return, ls_connections.
REFRESH: lt_connections, lt_photo_archive.
CONCATENATE gt_pernr-pernr '%' INTO ls_employee_number.

* Function Module to get count of photos for an Employee with the date,
* Content Repository Information and Archive-Document-Id

CALL FUNCTION 'ARCHIV_GET_CONNECTIONS'
EXPORTING
object_id = ls_employee_number
documenttype = 'HRICOLFOTO'
from_ar_date = lc_update_start_date
until_ar_date = lc_update_end_date
TABLES
connections = lt_connections
EXCEPTIONS
nothing_found = 1
OTHERS = 2.


* If no Photo exists Generate Message
IF sy-subrc <> 0.
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
type = 'I'
cl = 'HR_SE_PA'
number = '001'
IMPORTING
return = ls_return.
ls_return-message_v1 = gt_pernr-pernr.
APPEND ls_return TO lt_messages.
CONTINUE.
ENDIF.


* Sort the table to get the most recent Entry
SORT lt_connections BY ar_date DESCENDING.
READ TABLE lt_connections INTO ls_connections INDEX 1.

* Function Module to get the Binary MIME object of the Photo
CALL FUNCTION 'ARCHIVOBJECT_GET_TABLE'
EXPORTING
archiv_id = ls_connections-archiv_id
document_type = lv_doc_type
archiv_doc_id = ls_connections-arc_doc_id
TABLES
binarchivobject = lt_photo_archive
EXCEPTIONS
error_archiv = 1
error_communicationtable = 2
error_kernel = 3
OTHERS = 4.


* If no MIME object exists Generate Message
IF sy-subrc <> 0.
CALL FUNCTION 'BALW_BAPIRETURN_GET2'
EXPORTING
type = 'E'
cl = 'HR_SE_PA'
number = '000'
IMPORTING
return = ls_return.
ls_return-message_v1 = gt_pernr-pernr.
APPEND ls_return TO lt_messages.
CONTINUE.
ENDIF.
CLEAR lv_filename.
lv_filename = |{ p_file }{ gt_pernr-pernr }.jpg|.
lv_out_file = |{ gt_pernr-uname },{ gt_pernr-pernr }.jpg|.
APPEND lv_out_file TO lt_out_file.

IF sy-batch IS INITIAL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_filename
filetype = 'BIN'
TABLES
data_tab = lt_photo_archive
EXCEPTIONS
OTHERS = 1.
ELSEIF sy-batch = abap_true.
TRY .
OPEN DATASET lv_filename FOR OUTPUT IN BINARY MODE.
IF sy-subrc = 0.
LOOP AT lt_photo_archive INTO ls_photo_archive.
TRANSFER ls_photo_archive TO lv_filename.
ENDLOOP.
ELSE .
ls_return-message = 'Failure-Unable to open the path'.
ls_return-message_v1 = gt_pernr-pernr.
ls_return-message_v2 = lv_filename.
APPEND ls_return TO lt_messages.
CONTINUE.
ENDIF.
CLOSE DATASET lv_filename.

CATCH cx_sy_file_authority.
ls_return-message = 'Failure-Authorisation to file location'.
ls_return-message_v1 = gt_pernr-pernr.
ls_return-message_v2 = lv_filename.
APPEND ls_return TO lt_messages.
CONTINUE.
ENDTRY.
ENDIF.
"ls_alv_output-status = 'Success'.
CLEAR lv_filename.

ENDLOOP.
PERFORM meta_file_create.
ENDFORM. "get_and_store


*&---------------------------------------------------------------------*
*& Form display_alv
*&---------------------------------------------------------------------*
* Display Errors in List
*----------------------------------------------------------------------*
FORM display_alv .
DATA functions TYPE REF TO cl_salv_functions_list.
DATA: gr_table TYPE REF TO cl_salv_table.
*... Create Instance
CALL METHOD cl_salv_table=>factory
IMPORTING
r_salv_table = gr_table
CHANGING
t_table = lt_messages.



functions = gr_table->get_functions( ).
functions->set_all( ).
*... Display Table
gr_table->display( ).


ENDFORM. "display_alv
*&---------------------------------------------------------------------*
*& Form meta_file_create
*&---------------------------------------------------------------------*
* SFSF needs Metadata file linking user names to photos
* This Metadata file is stored here
*----------------------------------------------------------------------*
FORM meta_file_create.
lv_filename = |{ p_file }employee_photos_{ sy-datum }.csv|.
IF sy-batch IS INITIAL.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = lv_filename
TABLES
data_tab = lt_out_file
EXCEPTIONS
OTHERS = 1.
ELSEIF sy-batch = abap_true.
TRY .
OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
LOOP AT lt_out_file INTO lv_out_file.
TRANSFER lv_out_file TO lv_filename.
ENDLOOP.
ELSE .
ls_return-message = 'Failure-Unable to open the path'.
ls_return-message_v1 = lv_filename.
APPEND ls_return TO lt_messages.
ENDIF.
CLOSE DATASET lv_filename.

CATCH cx_sy_file_authority.
ls_return-message = 'Failure-Authorisation to file location'.
ls_return-message_v1 = lv_filename.
APPEND ls_return TO lt_messages.
ENDTRY.
ENDIF.
ENDFORM. "meta_file_create
2 Comments
Labels in this area