‎2008 Jul 08 1:11 PM
Hi,
I have to create an ABAP program dynamically. The program name(to be created) will be provided in the selection screen and the logic of the program will be available in an internal table & also in a local PC file. Is there any Function Module available in SAP to create the program dynamically by using the code which is available in the internal table. The program should be saved in the Local Object.
Can someone help me on this issue. Thanks in advance.
Best Regards,
Paddu.
‎2008 Jul 08 1:15 PM
Hello,
See this: [http://help.sap.com/saphelp_nw04/helpdata/en/9f/db996e35c111d1829f0000e829fbfe/frameset.htm]
Regards.
‎2008 Jul 08 1:15 PM
Hello,
See this: [http://help.sap.com/saphelp_nw04/helpdata/en/9f/db996e35c111d1829f0000e829fbfe/frameset.htm]
Regards.
‎2008 Jul 08 1:20 PM
Hi
U need to use only INSERT REPORT statament:
INSERT REPORT <REPORT NAME> FROM <ITAB>.
Max
‎2008 Jul 08 1:46 PM
Hi
INSERT REPORT <prog> FROM <itab>.Hope it will solve your problem.
Thanks & Regards
Nikunj Shah
‎2008 Jul 08 3:01 PM
Hello Paddu.
This code fullfills your requirement. Only has the resctriction that all the file names must be in uppercase.
REPORT zcreate_report.
* TYPES
TYPES: BEGIN OF ty_code,
line TYPE char255,
END OF ty_code.
* CLASSES
CLASS cl_gui_frontend_services DEFINITION LOAD.
* INTERNAL TABLES
DATA: data_tab TYPE STANDARD TABLE OF file_info.
DATA: wa TYPE file_info.
DATA: ti_code TYPE STANDARD TABLE OF ty_code.
* VARIABLES
DATA: name TYPE PROGNAME.
DATA: count TYPE i.
DATA: bytecount TYPE i.
DATA: filename TYPE string.
* SELECTION-SCREEN
PARAMETERS: p_dir TYPE string OBLIGATORY DEFAULT 'C:\test\'.
*** START-OF-SELECTION
START-OF-SELECTION.
CLEAR count.
CALL METHOD cl_gui_frontend_services=>directory_list_files
EXPORTING
directory = p_dir
files_only = 'X'
directories_only = space
CHANGING
file_table = data_tab
count = count.
IF count EQ 0.
MESSAGE i000(zsd1) WITH 'No files found'.
EXIT.
ENDIF.
LOOP AT data_tab INTO wa.
CALL FUNCTION 'AIPC_CONVERT_TO_UPPERCASE'
EXPORTING
i_input = wa-filename
IMPORTING
e_output = wa-filename.
CONCATENATE p_dir wa-filename INTO filename.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
IMPORTING
filelength = bytecount
TABLES
data_tab = ti_code
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
OTHERS = 17.
CHECK sy-subrc EQ 0.
READ TABLE ti_code TRANSPORTING NO FIELDS INDEX 1.
CHECK sy-subrc EQ 0.
name = wa-filename.
INSERT REPORT name FROM ti_code.
ENDLOOP.
Regards.
Valter Oliveira.