*&---------------------------------------------------------------------* *& Report ZHRR_011 *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zhrr_011. TABLES pa0000. DATA:py_table LIKE TABLE OF pa0000 WITH HEADER LINE. DATA mess TYPE c. 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. SELECTION-SCREEN ULINE . SELECTION-SCREEN COMMENT /1(50) comm11. SELECTION-SCREEN COMMENT /1(80) comm12. INITIALIZATION. comm11 = ' 输入注意事项 '. comm12 = '1.图片需以员工号命名,员工号不足8位时,需前补0,例如00100553. 2.请选择文件夹,文件夹下所有的图片将上传.'. 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 ) . CONCATENATE gd_path '\' filetab-filename INTO sappfad. CONCATENATE filetab-filename+0(8) '0002' INTO sapobjid. IF len >= 8. IF filetab-filename+0(8) CO ' 0123456789'. SELECT SINGLE * INTO CORRESPONDING FIELDS OF py_table FROM pa0000 WHERE pa0000~pernr = filetab-filename+0(8) AND begda <= sy-datum AND endda >= sy-datum. IF sy-subrc = 0. 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 : / '上传 ',sappfad,'员工号 ',filetab-filename+0(8),'Sccuess!'. ENDIF. ELSE. WRITE : / '上传 ',sappfad,'员工号 ',filetab-filename+0(8),'员工号不存在!'. ENDIF. ELSE. WRITE : / '上传 ',sappfad,'员工号 ',filetab-filename+0(8),'员工号不存在!'. endif. ELSE. WRITE : / '上传 ',sappfad,'员工号 ',filetab-filename+0(8),'员工号不存在!'. ENDIF. ENDLOOP.
^_^很多人都把资料锁进了note里,以后还怎么百度呢^_^