<!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
最新资源
- 基于java+springboot+mysql+微信小程序的高校宿舍信息管理系统 源码+数据库+论文(高分毕业设计).zip
- 圣诞树代码编程python
- 基于java+springboot+mysql+微信小程序的高校就业招聘系统 源码+数据库+论文(高分毕业设计).zip
- tesseract5.5.0源码包
- 基于java+springboot+mysql+微信小程序的高校毕业生就业信息系统 源码+数据库+论文(高分毕业设计).zip
- 基于迟滞控制器的DC-AC逆变器研究simulink实现.rar
- 基于布雷格曼Split Bregman去噪的荧光漫反射迭代重建光学断层扫描Matlab代码.rar
- 基于动态窗口法DWA的机器人路径规划研究附Matlab代码.rar
- 基于改进遗传算法的卡车和两架无人机旅行推销员问题(D2TSP)附Matlab代码.rar
- 基于多目标粒子群优化算法的冷热电联供型综合能源系统运行优化Matlab代码.rar
- 基于分时电价策略的家庭能量系统优化附Matlab代码.rar
- 基于概率距离削减法、蒙特卡洛削减法的风光场景不确定性削减附Matlab代码.rar
- 基于后向自动微分的盲反卷积算法MNAD及其在滚动轴承故障诊断中的应用Matlab代码.rar
- 基于精英遗传算法的电动汽车有序充电方法研究附Matlab代码.rar
- 基于模型预测控制对PMSM进行FOC控制Simulink实现.rar
- 基于快速傅里叶变换FFT、窗函数法、希尔伯特-黄变换、小波变换电力系统同步相量计算研究附Matlab代码.rar
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈