Saturday, March 15, 2014
CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD method is used to upload file from PC.
REPORT ztest_download. "&-------------------------------------------------------------* "& Declarations "&-------------------------------------------------------------* TYPES: BEGIN OF ty_pa0001, pernr TYPE pa0001-pernr, bukrs TYPE pa0001-bukrs, werks TYPE pa0001-werks, persg TYPE pa0001-persg, ename TYPE pa0001-ename, END OF ty_pa0001. DATA:it_pa0001 TYPE STANDARD TABLE OF ty_pa0001. DATA:wa_pa0001 TYPE ty_pa0001. DATA:it_filetable TYPE filetable. DATA ls_filetable LIKE LINE OF it_filetable. DATA gv_rc TYPE i. "&-------------------------------------------------------------* "& Selection-screen "&-------------------------------------------------------------* PARAMETERS: p_file TYPE string. "&-------------------------------------------------------------* "& At Selection-Screen "&-------------------------------------------------------------* AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file. CALL METHOD cl_gui_frontend_services=>file_open_dialog EXPORTING window_title = 'Open file' * default_extension = * default_filename = * file_filter = * with_encoding = * initial_directory = * multiselection = CHANGING file_table = it_filetable rc = gv_rc * user_action = * file_encoding = * EXCEPTIONS * file_open_dialog_failed = 1 * cntl_error = 2 * error_no_gui = 3 * not_supported_by_gui = 4 * others = 5 . IF sy-subrc <> 0. * Implement suitable error handling here ELSE. READ TABLE it_filetable INTO ls_filetable INDEX 1. p_file = ls_filetable-filename. ENDIF. "&-------------------------------------------------------------* "& Start Of selection "&-------------------------------------------------------------* START-OF-SELECTION. CALL METHOD cl_gui_frontend_services=>gui_upload EXPORTING filename = p_file filetype = 'ASC' has_field_separator = 'X' * header_length = 0 * read_by_line = 'X' * dat_mode = SPACE * codepage = SPACE * ignore_cerr = ABAP_TRUE * replacement = '#' * virus_scan_profile = * isdownload = SPACE * IMPORTING * filelength = * header = CHANGING data_tab = it_pa0001 * isscanperformed = SPACE EXCEPTIONS file_open_error = 1 file_read_error = 2 no_batch = 3 gui_refuse_filetransfer = 4 invalid_type = 5 no_authority = 6 unknown_error = 7 bad_data_format = 8 header_not_allowed = 9 separator_not_allowed = 10 header_too_long = 11 unknown_dp_error = 12 access_denied = 13 dp_out_of_memory = 14 disk_full = 15 dp_timeout = 16 not_supported_by_gui = 17 error_no_gui = 18 OTHERS = 19 . IF sy-subrc <> 0. * Implement suitable error handling here ELSE. LOOP AT it_pa0001 INTO wa_pa0001. WRITE:/ wa_pa0001. ENDLOOP. ENDIF.
Followers
Popular Posts
- ABAP - ALV Report example with steps
- ABAP - Sending email with pdf attachment
- ABAP - Step by step tutorial on Smart Forms - Template Node
- SAP Adobe Form - Steps to create simple ADOBE Form and calling it from ABAP Program
- SAP ABAP - CL_ABAP_CHAR_UTILITIES class usage
- ABAP - Multiple value selection from F4 help for SELECT-OPTIONS
- Execute ABAP Report using SUBMIT statement
- ABAP - Select all or Deselect all in ALV or Check box handling in ALV
- Web Dynpro ABAP ALV - ON_CLICK event
- ABAP - Dynamic WHERE clause
0 comments:
Post a Comment
Your useful comments, suggestions are appreciated.Your comments are moderated.