HR Employee Image upload/download

上传下载员工照片(HR Photo)
REPORT z_barry_hr_photo_upload.
DATA: sapobjid LIKE sapb-sapobjid,
sappfad LIKE sapb-sappfad.
DATA: gd_path TYPE string ,
filetab TYPE TABLE OF file_info WITH HEADER LINE,
count TYPE i.
DATA: filename(40) TYPE c ,
fileext(10) TYPE c ,
len TYPE i .
PARAMETERS: filepath LIKE rlgrap-filename.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR filepath.
CALL METHOD cl_gui_frontend_services=>directory_browse
EXPORTING
window_title = 'File Directory'
initial_folder = 'C:/'
CHANGING
selected_folder = gd_path.
CALL METHOD cl_gui_cfw=>flush.
CONCATENATE gd_path '' INTO filepath.
START-OF-SELECTION.
gd_path = filepath .
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = gd_path
filter = '*.jpg'
CHANGING
file_table = filetab[]
count = count
EXCEPTIONS
cntl_error = 1
directory_list_files_failed = 2
wrong_parameter = 3
error_no_gui = 4
not_supported_by_gui = 5
OTHERS = 6.
LOOP AT filetab.
SPLIT filetab-filename AT '.' INTO filename fileext.
len = STRLEN( filename ) .
IF len <> 8 .
MESSAGE e000(oo) WITH '文件名长度必须等于8位'.
ENDIF.
ENDLOOP.
LOOP AT filetab.
CONCATENATE gd_path '/' filetab-filename INTO sappfad.
CONCATENATE filetab-filename+0(8) '0002' INTO sapobjid.
CALL FUNCTION 'ARCHIV_CREATE_FILE'
EXPORTING
ar_object = 'HRICOLFOTO'
object_id = sapobjid
sap_object = 'PREL'
doc_type = 'JPG'
path = sappfad
EXCEPTIONS
error_conectiontable = 1
error_parameter = 2
error_archiv = 3
error_upload = 4
error_kernel = 5
no_entry_possible = 6
error_comunicationtable = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE : / 'Upload ',sappfad,'To pernr ',filetab-filename+0(8),'Sccuess!'.
ENDIF.
ENDLOOP.
REPORT z_barry_hr_photo_down.
DATA: comps2 TYPE STANDARD TABLE OF scms_doinf WITH HEADER LINE,
comp_names TYPE STANDARD TABLE OF scms_donam WITH HEADER LINE.
PARAMETERS p_pernr LIKE pa0001-pernr.
PERFORM photo_down USING p_pernr 'A' '18000101' '99991231' 'D:/abc.jpg' .
*&---------------------------------------------------------------------*
*& Form URL_GET
*&---------------------------------------------------------------------*
FORM photo_down USING p_pernr LIKE pernr-pernr
p_tclas LIKE pspar-tclas
p_begda LIKE prelp-begda
p_endda LIKE prelp-endda
path TYPE c .
DATA: l_connect_info LIKE toav0,
l_exists(1) TYPE c .
CALL FUNCTION 'HR_IMAGE_EXISTS'
EXPORTING
p_pernr = p_pernr
p_tclas = p_tclas
p_begda = p_begda
p_endda = p_endda
IMPORTING
p_exists = l_exists
p_connect_info = l_connect_info
EXCEPTIONS
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
EXIT.
ENDIF.
CALL FUNCTION 'SCMS_DOC_READ_FILES'
EXPORTING
stor_cat = space
crep_id = l_connect_info-archiv_id
doc_id = l_connect_info-arc_doc_id
path = path
frontend = 'X'
TABLES
comps = comps2
comp_names = comp_names
EXCEPTIONS
bad_storage_type = 1
bad_request = 2
unauthorized = 3
not_found = 4
conflict = 5
internal_server_error = 6
error_http = 7
error_signature = 8
error_config = 9
error_hierarchy = 10
error_download = 11
error_open = 12
error_parameter = 13
error = 14
OTHERS = 15.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 .
ENDIF.
ENDFORM. "photo_down
PA30如何显示员工照片
HR Employee Image upload/download_第1张图片
1.双击小图片可以弹出完整的照片
2.如果想程序实现照片显示,可以参考FM:HR_IMAGE_INIT的取照片URL方法
3.PA30显示照片的程序:/1PAPAXX/HDR_FORMS_IMAGES
转自: http://blogold.chinaunix.net/u1/40527/showart.php?id=1715647

你可能感兴趣的:(image,header,Path,hierarchy,conflict,照片)