Sep 15, 2007 - Home » SAP ABAP » SAP ABAP Tutorial. Downloading Data in Internal table of CSV file. See a sample program below. Program 2 - (Replace or Append data to existing file) This file download program uses older techniques but achieves a perfectly acceptable solution which also allows the user to append data to an existing file. REPORT ZPOPUP_REPLACE. DATA: ld_filename TYPE string, ld_path TYPE string, ld_fullpath TYPE string, ld_result TYPE i. Types: begin of t_datatab, row(500) type c, end of t_datatab. Data: it_datatab type STANDARD TABLE OF t_datatab, wa_datatab like line of it_datatab. ![]() Wa_datatab-row = 'sdsds'. Append wa_datatab to it_datatab. * Display save dialog window CALL METHOD cl_gui_frontend_services=>file_save_dialog EXPORTING * window_title = ' ' DEFAULT_EXTENSION = 'XLS' default_file_name = 'accountsdata' INITIAL_DIRECTORY = 'c: temp ' CHANGING filename = ld_filename path = ld_path fullpath = ld_fullpath user_action = ld_result. * Check user did not cancel request CHECK ld_result EQ '0'. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING filename = ld_fullpath filetype = 'ASC' * APPEND = 'X' write_field_separator = 'X' * CONFIRM_OVERWRITE = 'X' TABLES data_tab = it_datatab[] 'need to declare and populate EXCEPTIONS file_open_error = 1 file_write_error = 2 OTHERS = 3. Program 2 - (Replace or Append data to existing file) This file download program uses older techniques but achieves a perfectly acceptable solution which also allows the user to append data to an existing file. REPORT ZPOPUP_APPEND. * Internal table to store export data DATA: begin of it_excelfile occurs 0, row(500) type c, end of it_excelfile. DATA: rc TYPE sy-ucomm, ld_answer TYPE c, ld_filename type string. PARAMETERS: p_file like rlgrap-filename default 'C: TEST'. It_excelfile-row = 'sdsds'. Hollywood film rambo first blood 3 hd movie download. Append it_excelfile. CALL FUNCTION 'WS_QUERY' EXPORTING query = 'FE' 'File Exist? Filename = p_file IMPORTING return = rc. Ld_filename = p_file. 'If File alread exists CALL FUNCTION 'POPUP_TO_CONFIRM' EXPORTING * TITLEBAR = ' ' * DIAGNOSE_OBJECT = ' ' text_question = 'File Already exists!!' Text_button_1 = 'Replace' * ICON_BUTTON_1 = ' ' text_button_2 = 'New name' * ICON_BUTTON_2 = ' ' * DEFAULT_BUTTON = '1' * DISPLAY_CANCEL_BUTTON = 'X' * USERDEFINED_F1_HELP = ' ' * START_COLUMN = 25 * START_ROW = 6 * POPUP_TYPE = IMPORTING answer = ld_answer * TABLES * PARAMETER = EXCEPTIONS text_not_found = 1 OTHERS = 2. * Option 1: Overwrite ********************* IF ld_answer EQ '1'. CALL FUNCTION 'GUI_DOWNLOAD' EXPORTING * BIN_FILESIZE = filename = ld_filename 'File Name filetype = 'ASC' * IMPORTING * FILELENGTH = TABLES data_tab = it_excelfile 'Data table EXCEPTIONS file_write_error = 1 no_batch = 2 gui_refuse_filetransfer = 3 invalid_type = 4 OTHERS = 5. IF sy-subrc 0. MESSAGE i003(zp) WITH 'There was an error during Excel file creation'(200). 'Causes short dump if removed and excel document was open ENDIF. * Option 2: New name. ********************* ELSEIF ld_answer EQ '2'. CALL FUNCTION 'DOWNLOAD' EXPORTING filename = p_file 'File name filetype = 'ASC' 'File type * col_select = 'X' 'COL_SELECT * col_selectmask = 'XXXXXXXXXXXXXXXXXXXXXXXXXX' * 'COL_SELECTMASK filetype_no_show = 'X' 'Show file type selection?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |