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
阅读(6231) | 评论(4) | 转发(0) |