*&---------------------------------------------------------------------* *& Report ZMIGRATEREQUEST *&---------------------------------------------------------------------* *& *&---------------------------------------------------------------------* REPORT zmigraterequest NO STANDARD PAGE HEADING . TYPE-POOLS: trwbo, stms. TABLES: sscrfields. DATA: retcode , len TYPE i, tra_dir TYPE text255, request LIKE e070-trkorr, system LIKE tmscsys-sysnam, req_infos TYPE stms_wbo_requests WITH HEADER LINE. DATA: filename LIKE sdbah-actid, extension LIKE sdbad-funct. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE t1. PARAMETERS: p_down RADIOBUTTON GROUP typ USER-COMMAND sele DEFAULT 'X'. PARAMETERS: p_upld RADIOBUTTON GROUP typ. SELECTION-SCREEN END OF BLOCK b1. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE t2. PARAMETERS: p_file TYPE char255 LOWER CASE MODIF ID m2, p_clnt TYPE mandt DEFAULT sy-mandt MATCHCODE OBJECT h_t000 MODIF ID m2, p_view AS CHECKBOX DEFAULT 'X' MODIF ID m2. SELECTION-SCREEN END OF BLOCK b2. SELECTION-SCREEN BEGIN OF BLOCK b3 WITH FRAME TITLE t3. PARAMETERS:p_reqnum TYPE trkorr MODIF ID m3, p_folder TYPE char128 DEFAULT 'C:\' LOWER CASE MODIF ID m3. SELECTION-SCREEN END OF BLOCK b3. INITIALIZATION. system = sy-sysid. CALL FUNCTION 'RSPO_R_SAPGPARAM' EXPORTING name = 'DIR_TRANS' IMPORTING value = tra_dir EXCEPTIONS error = 1 OTHERS = 0. IF tra_dir IS INITIAL. MESSAGE e000(oo) WITH 'DIR_TRANS目录未找到'. ENDIF. AT SELECTION-SCREEN OUTPUT. t1 = '选择功能'. t2 = '上传参数'. t3 = '下载参数'. %_p_down_%_app_%-text = '下载请求到本机'. %_p_upld_%_app_%-text = '上传请求'. %_p_file_%_app_%-text = '文件'. %_p_clnt_%_app_%-text = '上传到Client'. %_p_view_%_app_%-text = '传输前查看请求内容'. %_p_reqnum_%_app_%-text = '请求号'. %_p_folder_%_app_%-text = '下载到文件夹'. LOOP AT SCREEN. CASE screen-group1. WHEN 'M2'. IF p_down = 'X'. screen-active = '0'. ELSE. screen-active = '1'. ENDIF. WHEN 'M3'. IF p_down = 'X'. screen-active = '1'. ELSE. screen-active = '0'. ENDIF. ENDCASE. MODIFY SCREEN. ENDLOOP. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_reqnum. DATA: request_header TYPE trwbo_request_header, is_selection TYPE trwbo_selection. is_selection-reqstatus = 'R'. CALL FUNCTION 'TR_PRESENT_REQUESTS_SEL_POPUP' EXPORTING iv_organizer_type = '' is_selection = is_selection IMPORTING es_selected_request = request_header. p_reqnum = request_header-trkorr. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_folder. DATA: folder TYPE string. CALL METHOD cl_gui_frontend_services=>directory_browse CHANGING selected_folder = folder EXCEPTIONS cntl_error = 1 error_no_gui = 2 OTHERS = 3. p_folder = folder. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING def_path = 'C:\' mask = ',请求控制文件(K*.*),K*.*,ALL File(*.*),*.*.' mode = 'O' IMPORTING filename = p_file EXCEPTIONS inv_winsys = 1 no_batch = 2 selection_cancel = 3 selection_error = 4 OTHERS = 5. START-OF-SELECTION. PERFORM check_input . CASE 'X'. WHEN p_down. PERFORM downrequest . WHEN p_upld. PERFORM read_req. PERFORM uprequest. IF p_view = 'X'. PERFORM viewrequest. ELSE. PERFORM import_request. ENDIF. ENDCASE. *&--------------------------------------------------------------------* *& Form check_input *&--------------------------------------------------------------------* FORM check_input. CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN' EXPORTING iv_adminfunction = 'TADD' EXCEPTIONS e_no_authority = 1 e_invalid_user = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. IF p_down = 'X'. IF p_reqnum = '' OR p_folder = ''. MESSAGE s000(oo) WITH '必须输入请求号和本机文件夹'. STOP. ENDIF. ELSE. IF p_clnt = '' OR p_file = '' . MESSAGE s000(oo) WITH '必须输入文件名和Client'. STOP. ELSE. CALL FUNCTION 'SPLIT_FILENAME' EXPORTING long_filename = p_file IMPORTING pure_filename = filename pure_extension = extension. CONCATENATE extension filename INTO request. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form downrequest *&---------------------------------------------------------------------* FORM downrequest . DATA: lappfile LIKE rcgfiletr-ftappl, lguifile LIKE rcgfiletr-ftfront. len = strlen( p_folder ) - 1. IF p_folder+len CA '/\'. p_folder+len = ''. ENDIF. CONCATENATE tra_dir '/data/R ' p_reqnum+4(6) '.' p_reqnum(3) INTO lappfile. CONCATENATE p_folder '\R' p_reqnum+4(6) '.' p_reqnum(3) INTO lguifile. PERFORM down_file USING lappfile lguifile. CONCATENATE tra_dir '/cofiles/K ' p_reqnum+4(6) '.' p_reqnum(3) INTO lappfile. CONCATENATE p_folder '\K' p_reqnum+4(6) '.' p_reqnum(3) INTO lguifile. PERFORM down_file USING lappfile lguifile. MESSAGE s000(oo) WITH '成功下载到' lguifile. ENDFORM. " downrequest *&--------------------------------------------------------------------* *& Form DOWN_FILE *&--------------------------------------------------------------------* FORM down_file USING applfile frontfile . DATA: lappfile LIKE rcgfiletr-ftappl, lguifile LIKE rcgfiletr-ftfront, err_flg LIKE boole-boole, err_txt(100) TYPE c. lappfile = applfile . lguifile = frontfile . sy-cprog = 'RC1TCG3Y'. CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY' EXPORTING i_file_front_end = lguifile i_file_appl = lappfile i_file_overwrite = 'X' IMPORTING e_flg_open_error = err_flg e_os_message = err_txt EXCEPTIONS fe_file_open_error = 1 fe_file_exists = 2 fe_file_write_error = 3 ap_no_authority = 4 ap_file_open_error = 5 ap_file_empty = 6 OTHERS = 7. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. IF err_flg = 'X'. MESSAGE e000(oo) WITH err_txt. ENDIF. ENDFORM. " DOWN_FILE *&--------------------------------------------------------------------* *& Form read_req *&--------------------------------------------------------------------* FORM read_req. CALL FUNCTION 'TMS_MGR_READ_TRANSPORT_REQUEST' EXPORTING iv_request = request iv_target_system = system IMPORTING et_request_infos = req_infos[] EXCEPTIONS read_config_failed = 1 table_of_requests_is_empty = 2 system_not_available = 3 OTHERS = 4. READ TABLE req_infos INDEX 1. IF req_infos-e070 IS NOT INITIAL . CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = '确认' text_question = '请求文件已存在,是否覆盖?' default_button = '1' IMPORTING answer = retcode. IF retcode <> '1'. MESSAGE s000(oo) WITH '用户终止'. STOP. ENDIF. ENDIF. ENDFORM. *&---------------------------------------------------------------------* *& Form UPLOADREQUEST *&---------------------------------------------------------------------* FORM uprequest . DATA: lappfile LIKE rcgfiletr-ftappl. CONCATENATE tra_dir '/cofiles/' filename '.' extension INTO lappfile . PERFORM up_file USING lappfile p_file . len = strlen( p_file ) - 11. p_file+len(1) = 'R'. CONCATENATE tra_dir '/data/R' filename+1 '.' extension INTO lappfile . PERFORM up_file USING lappfile p_file . CALL FUNCTION 'TMS_MGR_FORWARD_TR_REQUEST' EXPORTING iv_request = request iv_target = system iv_tardom = '' iv_tarcli = '' iv_source = system iv_srcdom = '' iv_import_again = 'X' iv_monitor = 'X' iv_verbose = '' EXCEPTIONS OTHERS = 99. 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. *&--------------------------------------------------------------------* *& Form UP_FILE *&--------------------------------------------------------------------* FORM up_file USING applfile frontfile . DATA: lappfile LIKE rcgfiletr-ftappl, lguifile LIKE rcgfiletr-ftfront, err_flg LIKE boole-boole, err_txt(100) TYPE c. lappfile = applfile . lguifile = frontfile . sy-cprog = 'RC1TCG3Y'. CALL FUNCTION 'C13Z_FILE_UPLOAD_BINARY' EXPORTING i_file_front_end = lguifile i_file_appl = lappfile i_file_overwrite = 'X' IMPORTING e_flg_open_error = err_flg e_os_message = err_txt EXCEPTIONS fe_file_not_exists = 1 fe_file_read_error = 2 ap_no_authority = 3 ap_file_open_error = 4 ap_file_exists = 5 OTHERS = 6. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. IF err_flg = 'X'. MESSAGE e000(oo) WITH err_txt. ENDIF. ENDFORM. "UP_FILE *&--------------------------------------------------------------------* *& *&--------------------------------------------------------------------* FORM import_request. DATA: it_clients TYPE stms_clients. CALL FUNCTION 'TR_AUTHORITY_CHECK_ADMIN' EXPORTING iv_adminfunction = 'IMPS' EXCEPTIONS e_no_authority = 1 e_invalid_user = 2 OTHERS = 3. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4. ENDIF. APPEND p_clnt TO it_clients. CALL FUNCTION 'TMS_UI_IMPORT_TR_REQUEST' EXPORTING iv_system = system iv_request = request iv_tarcli = p_clnt iv_some_active = space it_clients = it_clients EXCEPTIONS cancelled_by_user = 1 import_request_denied = 2 import_request_failed = 3 OTHERS = 4. IF sy-subrc <> 0. MESSAGE ID sy-msgid TYPE 'E' NUMBER sy-msgno WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 . ENDIF. CALL FUNCTION 'TMS_UIQ_IMPORT_QUEUE_DISPLAY' EXPORTING iv_system = system EXCEPTIONS OTHERS = 99. ENDFORM. *&---------------------------------------------------------------------* *& Form viewrequest *&---------------------------------------------------------------------* FORM viewrequest. DATA queue TYPE tmscsys. SELECT SINGLE * INTO queue FROM tmscsys WHERE sysnam = system. CALL FUNCTION 'TMS_UI_SHOW_TRANSPORT_REQUEST' EXPORTING iv_request = request iv_target_system = '' is_queue = queue EXCEPTIONS show_transport_request_failed = 1 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 . ENDIF. CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING titlebar = '确认' text_question = '是否继续传输?' text_button_1 = '传输' text_button_2 = '退出,不传输' icon_button_1 = 'ICON_IMPORT_TRANSPORT_REQUEST' default_button = '2' display_cancel_button = 'X' IMPORTING answer = retcode. IF retcode = '1'. PERFORM import_request. ELSE. IF req_infos-e070 IS INITIAL. CALL FUNCTION 'TMS_MGR_MAINTAIN_TR_QUEUE' EXPORTING iv_command = 'DELFROMBUFFER' iv_system = system iv_domain = '' iv_request = request iv_tarcli = '' iv_monitor = 'X' iv_verbose = '' EXCEPTIONS OTHERS = 99. ENDIF. ENDIF. ENDFORM. "viewrequest
标签:sy,TR,上传下载,程序,request,iv,file,ENDIF,TYPE From: https://www.cnblogs.com/Anyohh233/p/17980239