*---------------------------------------------------------------------* * FORM upload_file_to_server *---------------------------------------------------------------------* * [+] Uploads the data of a local file to the server *---------------------------------------------------------------------* FORM upload_file_to_server USING p_file_in TYPE localfile p_file_out TYPE localfile. TYPES: BEGIN OF lt_file_data, line(600) TYPE c, END OF lt_file_data. DATA: lv_file_data TYPE lt_file_data, li_file_data TYPE STANDARD TABLE OF lt_file_data. * Open the server file for writing. Checks for write error too. OPEN DATASET p_file_out FOR OUTPUT IN TEXT MODE. IF sy-subrc <> 0. WRITE: / 'Error opening output file'. EXIT. ENDIF. * Upload data into the table CALL FUNCTION 'UPLOAD' EXPORTING filename = p_file_in filetype = 'ASC' TABLES data_tab = li_file_data EXCEPTIONS others = 99. IF sy-subrc <> 0. WRITE: / 'Error uploading data'. EXIT. ENDIF. * Copy the data from the table to the server file LOOP AT li_file_data INTO lv_file_data. TRANSFER lv_file_data TO p_file_out. ENDLOOP. CLOSE DATASET p_file_out. CLOSE DATASET p_file_in. ENDFORM.