<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<html>
<head>
<title>Z_TESTE_YY_23_F01</title>
</head>
<body bgcolor="#FFFFE0">
<font size="3" face = "Arial" color="#000000"><b>Code listing for: Z_TESTE_YY_23_F01</b></font>
<br>
<font size="3" face = "Arial" color="#000000"><b>Description: Include Z_TESTE_YY_23_F01</b></font>
<hr>
<pre width="100">
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& 包含 Z_TESTE_YY_23_F01</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
DEFINE def_process.
END-OF-DEFINITION.
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Form frm_beging_procedure</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& --> p1 text</font>
<font color ="#0000FF">*& <-- p2 text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
FORM frm_beging_procedure .
"链接FTP
PERFORM frm_connect_ftp.
"执行FTP功能
PERFORM frm_ftp_execute.
ENDFORM.
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Form frm_connect_ftp</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& --> p1 text</font>
<font color ="#0000FF">*& <-- p2 text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
FORM frm_connect_ftp .
DATA:lv_pwd_len TYPE i.
CLEAR:lv_pwd_len.
gv_pwrd = p_pwrd.
lv_pwd_len = strlen( gv_pwrd ).
"对密码进行加密处理
CALL FUNCTION 'HTTP_SCRAMBLE'
EXPORTING
source = gv_pwrd
sourcelen = lv_pwd_len
key = gc_key
IMPORTING
destination = gv_pwrd.
"链接FTP
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = p_user
password = gv_pwrd
host = p_host
rfc_destination = gc_rfc_des
IMPORTING
handle = gv_handle
EXCEPTIONS
not_connected = 1
OTHERS = 2.
IF sy-subrc <> 0.
MESSAGE e001(00) WITH '无法连接FTP!'.
ELSE.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 20 "进度
text = '链接FTP成功!'. "显示文本
ENDIF.
ENDFORM.
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Form frm_ftp_execute</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& --> p1 text</font>
<font color ="#0000FF">*& <-- p2 text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
FORM frm_ftp_execute .
DATA:lv_ucomm TYPE sy-ucomm.
DATA:ls_up_path TYPE c LENGTH 200,
ls_up_file TYPE c LENGTH 200,
ls_up_fname TYPE c LENGTH 200,
ls_dw_path TYPE c LENGTH 200,
ls_dw_fname TYPE c LENGTH 200.
CLEAR:lv_ucomm,ls_up_fname,ls_up_file,ls_up_path,gt_ftp_com.
FREE:gt_ftp_com.
lv_ucomm = sy-ucomm.
"指定FTP文件路线
IF gv_ftp_path IS NOT INITIAL.
CONCATENATE 'cd' p_fpath INTO gt_ftp_com SEPARATED BY space.
APPEND gt_ftp_com.
ENDIF.
CASE lv_ucomm.
WHEN 'UPLOAD'.
"获取文件夹路径,文件名,文件全路径
PERFORM frm_get_uppath CHANGING ls_up_path ls_up_file ls_up_fname.
"指定本地文件路径
CONCATENATE 'lcd' ls_up_path INTO gt_ftp_com SEPARATED BY space.
APPEND gt_ftp_com.
"指定本地文件文件名
CONCATENATE 'put' ls_up_fname INTO gt_ftp_com SEPARATED BY space.
APPEND gt_ftp_com.
"执行FTP指令
PERFORM frm_execute_handle TABLES gt_ftp_com.
WHEN 'DOWNLOAD'.
"获取下载路径
PERFORM frm_get_dwpath CHANGING ls_dw_path.
"获取FTP文件名
PERFORM frm_get_fname CHANGING ls_dw_fname.
"检查文件是否存在
PERFORM frm_check_dw USING ls_dw_path ls_dw_fname.
"指定本地文件路径
CONCATENATE 'lcd' ls_dw_path INTO gt_ftp_com SEPARATED BY space.
APPEND gt_ftp_com.
"指定获取文件名
CONCATENATE 'get' ls_dw_fname INTO gt_ftp_com SEPARATED BY space.
APPEND gt_ftp_com.
"执行FTP指令
PERFORM frm_execute_handle TABLES gt_ftp_com.
WHEN 'ITAB_DL'.
"获取FTP文件名
PERFORM frm_get_fname CHANGING ls_dw_fname.
<font color ="#0000FF">* "复制FTP文件到R3</font>
<font color ="#0000FF">* PERFORM frm_copy_file USING ls_dw_fname.</font>
"读取FTP文件
PERFORM frm_read_file USING ls_dw_fname.
WHEN OTHERS.
"断开FTP,RFC链接
PERFORM frm_ftp_disconnect.
ENDCASE.
"断开FTP,RFC链接
PERFORM frm_ftp_disconnect.
ENDFORM.
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Form FRM_FTP_DISCONNECT</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& --> p1 text</font>
<font color ="#0000FF">*& <-- p2 text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
FORM frm_ftp_disconnect .
"断开FTP连接
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = gv_handle.
"断开RFC连接
CALL FUNCTION 'RFC_CONNECTION_CLOSE'
EXPORTING
destination = gc_rfc_des
EXCEPTIONS
destination_not_open = 1
OTHERS = 2.
ENDFORM.
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& Form frm_execute_uploda</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
<font color ="#0000FF">*& --> p1 text</font>
<font color ="#0000FF">*& <-- p2 text</font>
<font color ="#0000FF">*&---------------------------------------------------------------------*</font>
FORM frm_execute_handle TABLES pt_ftp_path STRUCTURE gt_ftp_com.
DATA:BEGIN OF lt_rs_data OCCURS 0,
line(100) TYPE c,
END OF lt_rs_data.
CLEAR:lt_rs_data.
FREE:lt_rs_data.
LOOP AT pt_ftp_path FROM 1.
"执行FTP指令
CALL FUNCTION 'FTP_COMMAND'
EXPORTING
handle = gv_handle
command = pt_ftp_path-cmd
compress = gc_compress
TABLES
data = lt_rs_data
EXCEPTIONS
tcpip_error = 1
command_error = 2
data_error = 3
OTHERS = 4.
IF sy-subrc <> 0.
PERFORM frm_ftp_disconnect.
MESSAGE e001(00) WITH '操作执行失败!'.
EXIT.
ELSE.
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
EXPORTING
percentage = 100
ABAP小码奴
- 粉丝: 47
- 资源: 2
最新资源
- 适用于 Raspberry Pi 的 Adafruit 库代码.zip
- 章节2:编程基本概念之python程序的构成
- 适用于 Python 的 LINE 消息 API SDK.zip
- 宝塔面板安装及关键网络安全设置指南
- 适用于 Python 的 AWS 开发工具包.zip
- 适用于 Python 3 的 Django LDAP 用户身份验证后端 .zip
- 基于PBL-CDIO的材料成型及控制工程课程设计实践与改革
- JQuerymobilea4中文手册CHM版最新版本
- 适用于 Python 2 和 3 以及 PyPy (ws4py 0.5.1) 的 WebSocket 客户端和服务器库.zip
- 适用于 AWS 的 Python 无服务器微框架.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈