Jump to Download with a ABAP specific Program. To download in abap the file, you can ask for/ develop a new ABAP custom Program. Close the file on the application server using CLOSE DATASET ABAP statement. Below program uses OPEN DATASET, TRANSFER.
Submitted by Harini Gopinath, Hexaware Technologies.
Program to download any program (With all its Includes) given in the selection screen to the file location specified on the selection screen:************************************************************************ *PROGRAM INFORMATION * ************************************************************************ *PROGRAM : ZPROGRAM_DOWNLOAD * *TITLE : Download Program with includes to a folder in PC * *OWNER : Harini Gopinath * *AUTHOR : Harini Gopinath * *COMPANY NAME :Hexaware Technologies * ---------------------------------------------------------------------- *PROGRAM FUNCTION: * *This program is used to download any program with all its includes to *
any location on PC selected by the use * ---------------------------------------------------------------------- *PROGRAM TYPE....: Type1 : Executable (please dont change the code) * ************************************************************************ REPORT zprogram_download. DATA : itab TYPE TABLE OF string, itab4 TYPE TABLE OF string, g_string TYPE string, g_c(7) TYPE c, g_stokes TYPE stokes, itab1 LIKE TABLE OF g_c, itab2 TYPE TABLE OF stokes, wa_itab2 LIKE LINE OF itab2, g_tabix TYPE sy-tabix, g_text TYPE repti, itab3 TYPE TABLE OF sstmnt. DATA: frontendslashseparator TYPE string. DATA: slashseparatortouse TYPE string. DATA: frontendopsystem TYPE string. CONSTANTS: unix TYPE string VALUE 'UNIX'. CONSTANTS: non_unix TYPE string VALUE 'not UNIX'. TYPES : g_file TYPE rlgrap-filename. *Program name to be dowloaded. SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001. PARAMETERS : p_prgnam TYPE progname DEFAULT 'ZUSEREXIT'. SELECTION-SCREEN END OF BLOCK b1. SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-003. PARAMETERS: pfolder TYPE rlgrap-filename DEFAULT 'E:ANIL'. SELECTION-SCREEN: END OF BLOCK b2. *INITIALIZATION. AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_prgnam. IF p_prgnam IS NOT INITIAL. ENDIF. *-----------------------------------------------------------------------
Display a directory picker window *----------------------------------------------------------------------- AT SELECTION-SCREEN ON VALUE-REQUEST FOR pfolder. DATA: objfile TYPE REF TO cl_gui_frontend_services. DATA: pickedfolder TYPE string. DATA: initialfolder TYPE string. DATA : i_dynpread TYPE TABLE OF dynpread, wa_dynpread TYPE dynpread. wa_dynpread-fieldname = 'PFOLDER'. APPEND wa_dynpread TO i_dynpread.
Determine the frontend operating system type. IF sy-batch IS INITIAL. PERFORM determinefrontendopsystem USING frontendslashseparator frontendopsystem. ENDIF. g_c = 'INCLUDE'. APPEND g_c TO itab1.
START-OF-SELECTION. *Populate an internal table with the report name specified in the *selection screen READ REPORT p_prgnam INTO itab. *If report exists. IF itab IS NOT INITIAL. *Use the system code for obtaining any include in the report. SCAN ABAP-SOURCE itab TOKENS INTO itab2 STATEMENTS INTO itab3 KEYWORDS FROM itab1. *Get the tokens if any. IF itab2 IS NOT INITIAL. APPEND LINES OF itab TO itab4. REFRESH : itab. LOOP AT itab2 INTO g_stokes. *For downloading includes if any in the program. IF g_stokes-str = 'INCLUDE'. g_tabix = sy-tabix + 1. CONTINUE. ENDIF. *Get the include names if any using read to itab2. READ TABLE itab2 INTO wa_itab2 INDEX g_tabix. IF sy-subrc EQ 0. WRITE : wa_itab2-str TO g_text. *Getting the include code into an internal table. READ REPORT g_text INTO itab. APPEND LINES OF itab TO itab4. REFRESH : itab. ENDIF. ENDLOOP. *download the file into a file on the pc. PERFORM dowload_file USING itab4[] pfolder. *Printing the whole program on the screen. LOOP AT itab4 INTO g_string. WRITE : / g_string. ENDLOOP. ELSE. *download the program to pc path. PERFORM dowload_file USING itab[] pfolder. *Display the code on the screen. LOOP AT itab INTO g_string. WRITE : / g_string. ENDLOOP. ENDIF. ELSE. WRITE : / 'Program with that name doesnt exist'. ENDIF. &--------------------------------------------------------------------- *& Form dowload_file &---------------------------------------------------------------------
text ----------------------------------------------------------------------
-->P_ITAB4[] text
-->P_PFOLDER text ---------------------------------------------------------------------- FORM dowload_file USING p_itab4 p_pfolder. DATA: objfile TYPE REF TO cl_gui_frontend_services. DATA : filenamewithpath TYPE string. CONCATENATE pfolder ' p_prgnam INTO filenamewithpath. CONDENSE filenamewithpath. CREATE OBJECT objfile. CALL METHOD objfile->gui_download EXPORTING filename = filenamewithpath filetype = 'ASC'
PERFORM displaystatus USING statusmessage 3. ENDIF. ENDFORM. ' dowload_file &--------------------------------------------------------------------- *& Form determinefrontendopsystem &---------------------------------------------------------------------
text ----------------------------------------------------------------------
-->P_FRONTENDSLASHSEPARATOR text
-->P_FRONTENDOPSYSTEM text ---------------------------------------------------------------------- FORM determinefrontendopsystem USING separator operatingsystem. DATA: platformid TYPE i VALUE 0. DATA: objfile TYPE REF TO cl_gui_frontend_services. CREATE OBJECT objfile. CALL METHOD objfile->get_platform RECEIVING platform = platformid EXCEPTIONS cntl_error = 1 error_no_gui = 2 not_supported_by_gui = 3. CASE platformid. WHEN objfile->platform_windows95 OR objfile->platform_windows98 OR objfile->platform_nt351 OR objfile->platform_nt40 OR objfile->platform_nt50 OR objfile->platform_mac OR objfile->platform_os2 OR 14. 'XP separator = '. operatingsystem = non_unix. WHEN OTHERS. separator = '/'. operatingsystem = unix. ENDCASE. ENDFORM. ' determinefrontendopsystem