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

upload zprograms into sap

Former Member
0 Likes
1,069

hi guys,

how to upload zprograms into sap?is there any program to upload zprograms into sap from a txt format?

plz send the code.

bye

7 REPLIES 7
Read only

Former Member
0 Likes
1,017

Hi pavan,

Yes we can upload zprograms into sap from presentaion server, Go to---> Utilities> More utilities---> upload.

There we can browse what ever file we need to upload.

Is this what you want ??

Hope this will helps you.

Regards,

Surender.B.V.

Read only

0 Likes
1,017

what i mean is , i want to upload all files at a time in sap from presentation server.

(whose name starts with zp*, like that).

since i got hundreds of programs. plz suggests me.

Read only

0 Likes
1,017

Hi Pavan

your req to upload into sap all at once is not possible... all you can do is

in the slection screen you can create few parameters.. which allow to browse for files on the presentation server..

in the code.. you need to call gui_upload FM for all those files.. and get data into internal table.. and do you manupulations and update the tables in SAP you wanted..

Hope this helps..

Award points if helpful..

Read only

Former Member
0 Likes
1,017

If it is a single program , try this

goto SE38

create the program and go in change mode

in menu Utilities->more utilities>upload/download--->upload the program

Read only

0 Likes
1,017

there is bunch of zprograms to upload into sap from presentation server.

is there any program to upload many zprograms into sap from presentation server.

Read only

former_member189059
Active Contributor
0 Likes
1,017

Hello,

Try this program, it should work

however the programs created will not have any development package or description


*&---------------------------------------------------------------------*
*& Report  ZKRIS_UPLOADALL
*&
*&---------------------------------------------------------------------*
*& Author  : Kris Donald
*& Date    : 12-11-2007
*& Purpose : To read all text files in a directory and write it to pgms
*&---------------------------------------------------------------------*
*& Date Changed by Tag Description
*&
*&---------------------------------------------------------------------*

REPORT  zkris_uploadall.

SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE lv_b1ttl.
PARAMETERS: p_dir(512) DEFAULT 'C:'.
PARAMETERS: p_hide AS CHECKBOX.
SELECTION-SCREEN END OF BLOCK b1.

*----------------------------------------------------------------------*
* Initialization                                                       *
*----------------------------------------------------------------------*
INITIALIZATION.
* sets the value for the title of the parameters block
  lv_b1ttl = 'Parameters'.

*----------------------------------------------------------------------*
* at selection screen                                                  *
*----------------------------------------------------------------------*

AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_dir.

  DATA: initial_folder TYPE string.
  DATA: selected_folder TYPE string.
  initial_folder = p_dir.

  CALL METHOD cl_gui_frontend_services=>directory_browse
    EXPORTING
*    window_title         =
      initial_folder       = initial_folder
    CHANGING
      selected_folder      = selected_folder
    EXCEPTIONS
      cntl_error           = 1
      error_no_gui         = 2
      not_supported_by_gui = 3
      OTHERS               = 4
          .
  IF sy-subrc <> 0.
    WRITE:/ 'Error number', sy-subrc.
    EXIT..
  ENDIF.

  p_dir = selected_folder.

*----------------------------------------------------------------------*
* start-of-selection                                                   *
*----------------------------------------------------------------------*

START-OF-SELECTION.

  DATA: it_file_table TYPE STANDARD TABLE OF file_info.
  DATA: wa_file_table LIKE LINE OF it_file_table.

  TYPES: BEGIN OF x_sourcecode_type,
    line(1023),
    END OF x_sourcecode_type.
  DATA: it_sourcecode TYPE x_sourcecode_type OCCURS 0 WITH HEADER LINE.

  DATA: lv_count TYPE i.
  DATA: lv_directory TYPE string.
  DATA: lv_file TYPE string.
  DATA: lv_progname LIKE trdir-name.
  DATA: lv_length TYPE i.

  lv_directory = p_dir.
  CALL METHOD cl_gui_frontend_services=>directory_list_files
    EXPORTING
      directory                   = lv_directory
      filter                      = '*.TXT'
      files_only                  = 'X'
*    directories_only            =
    CHANGING
      file_table                  = it_file_table
      count                       = lv_count
    EXCEPTIONS
      cntl_error                  = 1
      directory_list_files_failed = 2
      wrong_parameter             = 3
      error_no_gui                = 4
      not_supported_by_gui        = 5
      OTHERS                      = 6
          .
  IF sy-subrc <> 0.
    WRITE:/ 'Error number', sy-subrc.
    EXIT.
  ENDIF.

  DELETE it_file_table WHERE filelength = 0.
*LOOP AT it_file_table INTO wa_file_table.
*  WRITE:/ wa_file_table-filename.
*ENDLOOP.

  LOOP AT it_file_table INTO wa_file_table.

    CONCATENATE p_dir '\' wa_file_table-filename INTO lv_file.

    CALL FUNCTION 'GUI_UPLOAD'
      EXPORTING
        filename                      = lv_file
        filetype                      = 'ASC'
*   HAS_FIELD_SEPARATOR           = ' '
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
       dat_mode                      = 'X'
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
      TABLES
        data_tab                      = it_sourcecode
     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
              .
    IF sy-subrc <> 0.
      WRITE:/'Please ensure that file', lv_file,
        'resides on your local PC'.
      EXIT.
    ENDIF.

*  loop at it_sourcecode.
*    write:/ it_sourcecode-line.
*  endloop.

    IF p_hide = 'X'.
      it_sourcecode-line = '*@#@@[SAP]'.
      INSERT it_sourcecode INDEX 1.
    ENDIF.

    lv_length = STRLEN( wa_file_table-filename ).
    lv_length = lv_length - 4.

    lv_progname = wa_file_table-filename(lv_length).

    INSERT REPORT lv_progname FROM it_sourcecode.
    IF sy-subrc = 0.
      WRITE:/ 'File', lv_progname, 'successfully written to program'.
    ELSE.
      WRITE:/ 'Error while writing to program', lv_progname.
      continue.
    ENDIF.

    REFRESH it_sourcecode.
    CLEAR it_sourcecode.

  ENDLOOP.

Read only

Former Member
0 Likes
1,017

Hi..

I have prg to download all the Zprograms with package wise ...if can change it to upload that could fine..

let me know do U need it or not.

regards

sg