Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Function Module to create a program in SE38

Former Member
0 Likes
2,157

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,457

Hello,

See this: [http://help.sap.com/saphelp_nw04/helpdata/en/9f/db996e35c111d1829f0000e829fbfe/frameset.htm]

Regards.

4 REPLIES 4
Read only

Former Member
0 Likes
1,458

Hello,

See this: [http://help.sap.com/saphelp_nw04/helpdata/en/9f/db996e35c111d1829f0000e829fbfe/frameset.htm]

Regards.

Read only

Former Member
0 Likes
1,457

Hi

U need to use only INSERT REPORT statament:

INSERT REPORT <REPORT NAME> FROM <ITAB>.

Max

Read only

Former Member
0 Likes
1,457

Hi

INSERT REPORT <prog> FROM <itab>.

Hope it will solve your problem.

Thanks & Regards

Nikunj Shah

Read only

valter_oliveira
Active Contributor
0 Likes
1,457

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.