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

How do we archive ABAP program to local machine?

Former Member
0 Likes
1,593

hi, im new to abap and would like to know are there any ways to save the abap program on to my own local machine instead of the server so to have a safe back up copy if the server ever fails.

hi, im new to abap and would like to know are there any ways to save the abap program on to my own local machine instead of the server so to have a safe back up copy if the server ever fails.

8 REPLIES 8
Read only

Former Member
0 Likes
1,410

In abap editor(se38) go throgh the menu path utilities>more utilities->upload/download.

regards

shiba dutta

Read only

former_member189059
Active Contributor
0 Likes
1,410

Try this program

the default setting of Z% would download all z programs

report zdownload.
tables tadir.

types: begin of t_type,
line(256),
end of t_type.
data rep_table type standard table of t_type with
non-unique default key initial size 500.
data: file type string,"RLGRAP-FILENAME.
path type string.
parameter: obj_name like tadir-obj_name default 'Z%'.
select-options: object for tadir-object default 'PROG',
author for tadir-author default sy-uname,
devclass for tadir-devclass.
data: begin of it_table occurs 0,
obj_name like tadir-obj_name,
end of it_table.
data: begin of wa_table,
obj_name like tadir-obj_name,
end of wa_table.
data: message_text type string.
***********************************************************************

start-of-selection.
  if devclass-high <> ''.
    concatenate 'C:BACKUP-' sy-datum+6(2) '.' sy-datum+4(2) '.'
    sy-datum+0(4) '-' sy-sysid '-' devclass-low
    '-' devclass-high ''
    into path.
  else.
    concatenate 'C:BACKUP-' sy-datum+6(2) '.' sy-datum+4(2) '.'
    sy-datum+0(4) '-' sy-sysid '-' devclass-low
    ''
    into path.
  endif.
  condense path no-gaps.
  select obj_name
  into table it_table
  from tadir
  where obj_name like obj_name and
  object in object and
  author in author and
  devclass in devclass.
  sort it_table by obj_name.
  loop at it_table into wa_table.

    read report wa_table-obj_name into rep_table.
    if wa_table-obj_name cs ''.
    else.
      clear file.
      concatenate path wa_table-obj_name '.TXT' into file.
      if sy-subrc = 0.
* CALL FUNCTION 'DOWNLOAD'
* EXPORTING
* FILENAME = FILE
* FILETYPE = 'ASC' "ASC, WK1, DBF, DAT, bin
* MODE = ' ' "Mode ' ' = Rewrite Mode 'A' = Appending
* TABLES
* DATA_TAB = REP_TABLE.
* WRITE: / 'File Saved Successfully'.
        call function 'GUI_DOWNLOAD'
        exporting
* BIN_FILESIZE =
        filename = file
        filetype = 'ASC'
* APPEND = 'X'
* WRITE_FIELD_SEPARATOR = 'X'
* HEADER = '00'
* TRUNC_TRAILING_BLANKS = ' '
* WRITE_LF = 'X'
* COL_SELECT = ' '
* COL_SELECT_MASK = ' '
* DAT_MODE = ' '
* CONFIRM_OVERWRITE = ' '
* NO_AUTH_CHECK = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* WRITE_BOM = ' '
* TRUNC_TRAILING_BLANKS_EOL = 'X'
* IMPORTING
* FILELENGTH =
        tables
        data_tab = rep_table
* FIELDNAMES =
        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.
          write :/ 'File download error,Message code:',sy-subrc,
          ' creating file ',file.
        endif.
      else.
        write: / 'Error Occured'.
      endif.
    endif.
  endloop.
  message_text = 'FILE(S) CREATED IN FOLDER'.
  concatenate message_text path into message_text separated by space.
  message message_text type 'I'.

Read only

Former Member
0 Likes
1,410

hey thanks guys, but what if i wan to save it to my desktop, the location is 'C:\Documents and Settings\Administrator\Desktop' , the 'Documents and Settings' the space in between, how do i define it, the program cant recognize the space in between, it automatically creates a new folder call Documentsandsettings without the space.

Read only

0 Likes
1,410

There was a condense no-gaps statement in between

you just have to remove it

see the code below

REPORT zdownload.
TABLES tadir.

TYPES: BEGIN OF t_type,
  line(256),
  END OF t_type.

DATA rep_table TYPE STANDARD TABLE OF t_type WITH
NON-UNIQUE DEFAULT KEY INITIAL SIZE 500.

DATA: file TYPE string,"RLGRAP-FILENAME.
path TYPE string.

PARAMETER: obj_name LIKE tadir-obj_name DEFAULT 'Z%'.

SELECT-OPTIONS: object FOR tadir-object DEFAULT 'PROG',
author FOR tadir-author DEFAULT sy-uname,
devclass FOR tadir-devclass.

DATA: BEGIN OF it_table OCCURS 0,
  obj_name LIKE tadir-obj_name,
  END OF it_table.

DATA: BEGIN OF wa_table,
  obj_name LIKE tadir-obj_name,
  END OF wa_table.

DATA: message_text TYPE string.
***********************************************************************

START-OF-SELECTION.
  IF devclass-high <> ''.
    CONCATENATE 'C:Documents and SettingsAdministratorDesktopBackup-' sy-datum+6(2) '.' sy-datum+4(2) '.'
    sy-datum+0(4) '-' sy-sysid '-' devclass-low
    '-' devclass-high ''
    INTO path.
  ELSE.
    CONCATENATE 'C:Documents and SettingsAdministratorDesktopBACKUP-' sy-datum+6(2) '.' sy-datum+4(2) '.'
    sy-datum+0(4) '-' sy-sysid '-' devclass-low
    ''
    INTO path.
  ENDIF.
  CONDENSE path.
  
  SELECT obj_name INTO TABLE it_table FROM tadir
    WHERE obj_name LIKE obj_name AND
    object IN object AND
    author IN author AND
    devclass IN devclass.

  SORT it_table BY obj_name.
  LOOP AT it_table INTO wa_table.

    READ REPORT wa_table-obj_name INTO rep_table.
    IF wa_table-obj_name CS ''.
    ELSE.
      CLEAR file.
      CONCATENATE path wa_table-obj_name '.TXT' INTO file.
      IF sy-subrc = 0.
        CALL FUNCTION 'GUI_DOWNLOAD'
          EXPORTING
            filename                = file
            filetype                = 'ASC'
          TABLES
            data_tab                = rep_table
          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.
          WRITE :/ 'File download error,Message code:',sy-subrc,
          ' creating file ',file.
        ENDIF.
      ELSE.
        WRITE: / 'Error Occured'.
      ENDIF.
    ENDIF.
  ENDLOOP.
  message_text = 'FILE(S) CREATED IN FOLDER'.
  CONCATENATE message_text path INTO message_text SEPARATED BY space.
  MESSAGE message_text TYPE 'I'.

Read only

Former Member
0 Likes
1,410

Can i ask one more qns, instead of saving the program text files only, can i save the whole package to the local machine including the GUI?

Read only

0 Likes
1,410

No, this should work only for reports

Read only

Former Member
0 Likes
1,410

hmm, so there is no other way to save the whole package to the local machine? thanks kriss

Read only

0 Likes
1,410

Put the package in a request, release the request (in se09) and download the data and co files

they are in the application server folder /usr/sap/trans/data/ and /usr/sap/trans/cofiles/

keep these files as your backup

later on, you can import them as a transport request from transaction STMS