Copy the following code.
This is what it does :
1. If you want programs, just give parameters like who is the author, what is the development class. The program downloads all the programs matching the above and creates one file each for the program.
2. If you want function modules, you need to give function modules names specifically. You may explore more how to automate the same.
*&---------------------------------------------------------------------**& Report ZPGM_DOWNLOAD
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT zpgm_download.
TABLES : tadir,
tfdir.
DATA: BEGIN OF itab OCCURS 0,
line(255) TYPE c,
END OF itab.
DATA : BEGIN OF ipgm OCCURS 0,
pgm TYPE tadir-obj_name,
END OF ipgm.
data : i_tfdir type standard table of tfdir
with header line
initial size 0.
DATA : l_file TYPE string,
l_ftype TYPE char10.
SELECT-OPTIONS : s_pgm FOR tadir-obj_name,
s_auth FOR tadir-author,
s_func for tfdir-funcname,
s_dev FOR tadir-devclass.
PARAMETERS : p_rep RADIOBUTTON GROUP rg1,
p_func RADIOBUTTON GROUP rg1.
IF p_rep = 'X'.
SELECT obj_name
FROM tadir
INTO TABLE ipgm
WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name IN s_pgm
AND author IN s_auth
AND devclass IN s_dev.
LOOP AT ipgm.
REFRESH itab.
READ REPORT ipgm-pgm INTO itab.
CONCATENATE 'c:\' ipgm-pgm '.TXT' INTO l_file.
l_ftype = 'ASC'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = l_ftype
filename = l_file
append = ' '
write_field_separator = 'X'
confirm_overwrite = 'X'
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
ELSEIF p_func = 'X'.
SELECT *
FROM tfdir
INTO TABLE i_tfdir
WHERE funcname IN s_func.
* CONCATENATE 'SAPLZCA_WIMO' 'U' '19' INTO ipgm-pgm.
* ipgm-pgm = ipgm-pgm+3.
* READ REPORT ipgm-pgm INTO itab.
* CONCATENATE 'c:\' ipgm-pgm '.TXT' INTO l_file.
LOOP AT i_tfdir.
CONCATENATE i_tfdir-pname 'U' i_tfdir-include into ipgm-pgm.
ipgm-pgm = ipgm-pgm+3.
READ REPORT ipgm-pgm INTO itab.
CONCATENATE 'c:\' i_tfdir-funcname '.TXT' INTO l_file.
l_ftype = 'ASC'.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filetype = l_ftype
filename = l_file
append = ' '
write_field_separator = 'X'
confirm_overwrite = 'X'
TABLES
data_tab = itab
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
ENDLOOP.
ENDIF.
| < Prev | Next > |
|---|





