If you want to create Excel download button at selection screen, you can check below method.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | TABLES: sscrfields. INITIALIZATION. PERFORM init_data. PERFORM file_download. *&———————————————————————* *& Form INIT_DATA *&———————————————————————* * text *———————————————————————-* * –> p1 text * <– p2 text *———————————————————————-* FORM INIT_DATA . sscrfields-functxt_01 = text-f01. ENDFORM. ” INIT_DATA *&———————————————————————* *& Form FILE_DOWNLOAD *&———————————————————————* * text *———————————————————————-* * –> p1 text * <– p2 text *———————————————————————-* FORM FILE_DOWNLOAD . DATA : t_dfname TYPE rlgrap-filename VALUE ‘C:\’, t_filename TYPE string. * download file name CALL FUNCTION ‘F4_FILENAME’ EXPORTING program_name = sy-repid dynpro_number = sy-dynnr IMPORTING file_name = t_dfname. * file name t_filename = t_dfname. IF t_filename IS INITIAL OR t_filename = ‘C:\’. MESSAGE ‘파일 경로를 입력해 주세요.’ TYPE ‘I’. STOP. ENDIF. * download template CALL FUNCTION ‘GUI_DOWNLOAD’ EXPORTING filename = t_filename filetype = ‘DAT’ TABLES data_tab = <gt_table>. CALL FUNCTION ‘MS_EXCEL_OLE_STANDARD_DAT’ EXPORTING file_name = t_dfname TABLES data_tab = <gt_table> fieldnames = it_head EXCEPTIONS file_not_exist = 1 filename_expected = 2 communication_error = 3 ole_object_method_error = 4 ole_object_property_error = 5 invalid_pivot_fields = 6 download_problem = 7 OTHERS = 8. IF sy-subrc <> 0. MESSAGE ‘Excel Open Error’ TYPE ‘I’. “#EC NOTEXT STOP. ENDIF. ENDFORM. ” FILE_DOWNLOAD |
Responses to “ABAP Create Excel Download button at Selection Screen”