首页 > 代码库 > FTP
FTP
...忘了写FTP,今天看到个FTP操作才想起来。。。玛德制杖
RSFTP002 执行 FTP 命令
RSFTP003 FTP 放置/获取测试
RSFTP004 FTP 复制
RSFTP006 FTP 命令列表
RSFTP007 测试 FB:FTP_SERVER_TO_R3 / FTP_R3_TO_SERVER
RSFTP009 通过验证测试 FTP 放置
02执行command,03put/get
一般常用的就是上传文件到FTP和下载。
FUNCTION ZCRM_SEND_PDF_TO_FTP. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" VALUE(OBJECT_ID) TYPE CRMT_OBJECT_ID OPTIONAL *" VALUE(GUID) TYPE CRMT_OBJECT_GUID OPTIONAL *"---------------------------------------------------------------------- DATA:LV_XSTRING TYPE XSTRING. DATA:LV_LEN TYPE I. DATA LV_HANDLE TYPE I. DATA LV_FNAME TYPE CHAR100. DATA:LV_SF TYPE TDSFNAME VALUE ‘ZCRM_SERVICE_04‘. DATA: LV_USER TYPE ZE_FTP_USER VALUE ‘crm‘. DATA LV_PASSWORD TYPE ZE_FTP_PW VALUE ‘crm‘. DATA:LV_HOST TYPE ZE_FTP_HOST VALUE ‘172.16.53.48‘. DATA:GT_TAB TYPE TABLE OF BLOB, GW_TAB LIKE LINE OF GT_TAB. IF OBJECT_ID IS INITIAL. WAIT UP TO 5 SECONDS. SELECT SINGLE A~OBJECT_ID B~ZZCON_FAX INTO (OBJECT_ID,LV_FNAME) FROM CRMD_ORDERADM_H AS A LEFT JOIN CRMD_SERVICE_H AS B ON A~GUID = B~GUID WHERE A~GUID = GUID. ELSE. SELECT SINGLE A~OBJECT_ID B~ZZCON_FAX INTO (OBJECT_ID,LV_FNAME) FROM CRMD_ORDERADM_H AS A LEFT JOIN CRMD_SERVICE_H AS B ON A~GUID = B~GUID WHERE A~OBJECT_ID = OBJECT_ID. ENDIF. CALL FUNCTION ‘ZSRV_PRINT_TO_PDF‘ EXPORTING IV_SAMRTFORM = LV_SF IV_GUID = GUID IV_OBJECT_ID = OBJECT_ID IMPORTING FILE = LV_XSTRING. CALL FUNCTION ‘SCMS_XSTRING_TO_BINARY‘ EXPORTING BUFFER = LV_XSTRING IMPORTING OUTPUT_LENGTH = LV_LEN TABLES BINARY_TAB = GT_TAB. CALL FUNCTION ‘ZCRM_FTP_CONNECT‘ EXPORTING IV_FTP_USER = LV_USER IV_HOST = LV_HOST IMPORTING EV_HANDLE = LV_HANDLE CHANGING IV_PASSWORD = LV_PASSWORD EXCEPTIONS NOT_CONNECTED = 1 OTHERS = 2. IF SY-SUBRC <> 0. EXIT. ENDIF. CONCATENATE LV_FNAME ‘XXXX.pdf‘ INTO LV_FNAME. CALL FUNCTION ‘FTP_R3_TO_SERVER‘ EXPORTING HANDLE = LV_HANDLE FNAME = LV_FNAME BLOB_LENGTH = LV_LEN TABLES BLOB = GT_TAB[] EXCEPTIONS TCPIP_ERROR = 1 COMMAND_ERROR = 2 DATA_ERROR = 3 OTHERS = 4. IF SY-SUBRC <> 0. ENDIF. CALL FUNCTION ‘FTP_DISCONNECT‘ EXPORTING HANDLE = LV_HANDLE. ENDFUNCTION.
ZSRV_PRINT_TO_PDF是获取SMARTFORMS打印的FDP流
FUNCTION zcrm_ftp_connect. *"---------------------------------------------------------------------- *"*"Local Interface: *" IMPORTING *" REFERENCE(IV_FTP_USER) TYPE ZE_FTP_USER *" REFERENCE(IV_HOST) TYPE ZE_FTP_HOST *" EXPORTING *" REFERENCE(EV_HANDLE) TYPE I *" CHANGING *" REFERENCE(IV_PASSWORD) TYPE ZE_FTP_PW *" EXCEPTIONS *" NOT_CONNECTED *"---------------------------------------------------------------------- CONSTANTS cons_key TYPE i VALUE 26101957. DATA:lv_slenth TYPE i. * 连接FTP服务器 lv_slenth = STRLEN( iv_password ). CALL FUNCTION ‘HTTP_SCRAMBLE‘ EXPORTING SOURCE = iv_password sourcelen = lv_slenth key = cons_key IMPORTING destination = iv_password. * Open the ftp server. CALL FUNCTION ‘FTP_CONNECT‘ EXPORTING user = iv_ftp_user password = iv_password host = iv_host rfc_destination = ‘SAPFTPA‘ IMPORTING handle = ev_handle EXCEPTIONS not_connected = 1 OTHERS = 2. IF sy-subrc NE 0. MESSAGE e007(zhntcrm01) RAISING not_connected. ENDIF. ENDFUNCTION.
FTP
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。