*&---------------------------------------------------------------------*
*& Report Z_BARRY_FTP_MAINTAIN *
*& *
*&---------------------------------------------------------------------*
*& 用简单的方式维护单条记录的数据 *
*& *
*&---------------------------------------------------------------------*
REPORT z_scm_ftp_maintain .
TABLES: zscm_ftp, sscrfields.
DATA: ans TYPE c,
suc TYPE c.
PARAMETERS: p_host(20) TYPE c OBLIGATORY ,
p_user(20) TYPE c OBLIGATORY LOWER CASE,
p_pass(20) TYPE c OBLIGATORY LOWER CASE.
SELECTION-SCREEN FUNCTION KEY 1.
INITIALIZATION.
sscrfields-functxt_01 = text-001 .
SELECT SINGLE * FROM zscm_ftp .
IF sy-subrc = 0.
p_host = zscm_ftp-host.
p_user = zscm_ftp-usr .
p_pass = zscm_ftp-pwd .
ENDIF.
AT SELECTION-SCREEN OUTPUT.
LOOP AT SCREEN.
CASE screen-name.
WHEN 'P_PASS'.
screen-invisible = 1.
ENDCASE.
MODIFY SCREEN.
ENDLOOP.
AT SELECTION-SCREEN.
IF sy-ucomm = 'FC01'.
PERFORM connect_check.
ELSEIF sy-ucomm = 'ONLI'.
IF suc <> 'X'.
MESSAGE e000(z900) WITH '请先测试连接通过'.
ENDIF.
ENDIF.
START-OF-SELECTION.
CALL FUNCTION 'POPUP_TO_CONFIRM'
EXPORTING
titlebar = '确认更新'
text_question = '确认更新FTP数据?'
IMPORTING
answer = ans. "1、 2、 A
IF ans <> '1' .
LEAVE PROGRAM .
ENDIF .
zscm_ftp-host = p_host.
zscm_ftp-usr = p_user.
zscm_ftp-pwd = p_pass.
MODIFY zscm_ftp .
IF sy-subrc = 0.
WRITE 'Success!'.
ENDIF.
*&---------------------------------------------------------------------*
*& Form connect_check
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM connect_check.
DATA: mi_key TYPE i VALUE 26101957,
mi_handle TYPE i,
slen TYPE i .
DATA: ftp_pass(30) TYPE c.
ftp_pass = p_pass.
slen = strlen( ftp_pass ).
CLEAR suc.
CALL 'AB_RFC_X_SCRAMBLE_STRING'
ID 'SOURCE' FIELD ftp_pass
ID 'KEY' FIELD mi_key
ID 'SCR' FIELD 'X'
ID 'DESTINATION' FIELD ftp_pass
ID 'DSTLEN' FIELD slen.
CALL FUNCTION 'FTP_CONNECT'
EXPORTING
user = p_user
password = ftp_pass
host = p_host
rfc_destination = 'SAPFTPSCM'
IMPORTING
handle = mi_handle
EXCEPTIONS
not_connected = 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.
MESSAGE i000(z900) WITH '测试成功,可以F8保存新的FTP信息'.
suc = 'X'.
CALL FUNCTION 'FTP_DISCONNECT'
EXPORTING
handle = mi_handle
EXCEPTIONS
OTHERS = 1.
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. " connect_check
阅读(3839) | 评论(0) | 转发(0) |