正文部分
DATA: hdl TYPE i, key TYPE i VALUE 26101957, dstlen TYPE i, blob_length TYPE i. DATA filepath TYPE string . DATA: BEGIN OF blob OCCURS 0, line(100) TYPE x, END OF blob. PARAMETERS: user(64) TYPE c , pwd(64) TYPE c , host(64) TYPE c , filename(80) TYPE c , name2(80) TYPE c, dest LIKE rfcdes-rfcdest DEFAULT 'SAPFTP'. PARAMETERS: p_file LIKE rlgrap-filename DEFAULT 'c:\test.xls'. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. PERFORM get_p_file USING p_file text-006. START-OF-SELECTION. TRANSLATE user TO lowER CASE. CALL 'AB_RFC_X_SCRAMBLE_STRING' ID 'SOURCE' FIELD pwd ID 'KEY' FIELD key ID 'SCR' FIELD 'X' ID 'DESTINATION' FIELD pwd ID 'DSTLEN' FIELD dstlen. CALL FUNCTION 'FTP_CONNECT' EXPORTING user = user password = pwd host = host rfc_destination = dest IMPORTING handle = hdl. CALL FUNCTION 'FTP_SERVER_TO_R3' EXPORTING handle = hdl fname = filename IMPORTING blob_length = blob_length TABLES blob = blob. filepath = p_file . CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename = filepath filetype = 'BIN' TABLES data_tab = blob. CALL FUNCTION 'FTP_DISCONNECT' EXPORTING handle = hdl. *&---------------------------------------------------------------------* *& Form get_p_file *&---------------------------------------------------------------------* * text *----------------------------------------------------------------------* * -->P_P_FILE text * -->P_TEXT_006 text *----------------------------------------------------------------------* FORM get_p_file USING l_filename l_text. CALL FUNCTION 'WS_FILENAME_GET' EXPORTING def_filename = space def_path = l_filename mask = ',*.xls ,*.xls.' mode = 'O' title = l_text IMPORTING filename = l_filename EXCEPTIONS inv_winsys = 04 no_batch = 08 selection_cancel = 12 selection_error = 16. ENDFORM. " get_p_file