Skip to Content
author's profile photo
Former Member

data archiving

Hi Sap Gurus,

I have to do document archving. I have specified my requirement here.

1.The program should provide a parameter field (screen field) for entering the path to the source directory, this ensures that the code must not be changed if the file location changes.

2.The program will be executed in a batch mode, so in order to do that, an interval must be specified which basically populates the source directory name in the function call.

3.Generate a file list of every file available in this directory, SAP provides low-level system calls to perform UNIX commands like ls u2013ld <source dir>

4.Extract the relevant information from the file list, UNIX usually returns directory specific information, which is not needed.

5.Error handling, implementing a reasonable error handling in case a file cannot be read or archived, renaming the source file to something like <filename>.error might be helpful to identify any faulty documents in the input directory.

I have to write an ABAP program for the above specified requirement. To simply say have to retrieve the file from from the UNIX paath and have to archive and store in sap and have to delete the file from UNIX path.

Can any one done this already. Could you help me .

Thanks

Renuka.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

3 Answers

  • author's profile photo
    Former Member
    Sep 04, 2008 at 05:41 PM

    For delete you can use my below code .

    DATA: i_physical LIKE rlgrap-filename.

    • Check file exists

    i_physical = ( User Input file name ).

    OPEN DATASET i_physical.

    IF sy-subrc <> 0.

    • File does not exist so we don't care

    ELSE.

    CLOSE DATASET i_physical.

    DELETE DATASET i_physical.

    IF sy-subrc <> 0.

    MESSAGE e016(rp) WITH 'Problem deleting file: ' i_physical.

    ELSE.

    WRITE: 'File: - ',

    i_physical,

    ' deleted successfully'.

    ENDIF.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 04, 2008 at 05:45 PM

    For download and error handling ...

    • download the file

    IF i_ftftype = 'ASC'.

    CALL FUNCTION 'C13Z_FILE_DOWNLOAD_ASCII'

    EXPORTING

    i_file_front_end = i_ftfront

    i_file_appl = i_ftappl

    i_file_overwrite = i_flg_overwrite

    IMPORTING

    e_flg_open_error = l_flg_open_error

    e_os_message = l_os_message

    EXCEPTIONS

    fe_file_open_error = 1

    fe_file_exists = 2

    fe_file_write_error = 3

    ap_no_authority = 4

    ap_file_open_error = 5

    ap_file_empty = 6

    OTHERS = 7.

    ELSE.

    CALL FUNCTION 'C13Z_FILE_DOWNLOAD_BINARY'

    EXPORTING

    i_file_front_end = i_ftfront

    i_file_appl = i_ftappl

    i_file_overwrite = i_flg_overwrite

    IMPORTING

    e_flg_open_error = l_flg_open_error

    e_os_message = l_os_message

    EXCEPTIONS

    fe_file_open_error = 1

    fe_file_exists = 2

    fe_file_write_error = 3

    ap_no_authority = 4

    ap_file_open_error = 5

    ap_file_empty = 6

    OTHERS = 7.

    ENDIF.

    IF sy-subrc <> 0.

    x_flg_stay = true.

    CASE sy-subrc.

    WHEN 1.

    MESSAGE i155 WITH i_ftfront l_os_message.

    • Datei &1 konnte nicht geöffnet werden

    WHEN 2.

    • file already exists, ask if file can be overwritten

    CALL FUNCTION 'C14A_POPUP_ASK_FILE_OVERWRITE'

    IMPORTING

    e_flg_continue = l_flg_continue

    EXCEPTIONS

    OTHERS = 1.

    IF l_flg_continue = true.

    x_flg_stay = false.

    PERFORM l_exec_file_download

    USING

    i_ftfront

    i_ftappl

    true

    i_ftftype

    CHANGING

    x_flg_stay.

    ENDIF.

    WHEN 3.

    MESSAGE i156 WITH i_ftfront.

    • Fehler beim Lesen/Schreiben der Datei &1

    WHEN 4.

    MESSAGE i157 WITH i_ftappl.

    • Sie haben keine Lese-Berechtigung für die Datei &1

    WHEN 5.

    MESSAGE i155 WITH i_ftappl l_os_message.

    • Datei &1 konnte nicht geöffnet werden

    WHEN 6.

    MESSAGE i171 WITH i_ftappl.

    • Die Datei &1 ist leer

    WHEN OTHERS.

    MESSAGE i158 WITH i_ftappl i_ftfront.

    • Fehler beim Transfer der Datei &1 nach &2

    ENDCASE.

    ELSE.

    IF l_flg_open_error = true.

    x_flg_stay = true.

    MESSAGE i155 WITH i_ftappl l_os_message.

    • Datei &1 konnte nicht geöffnet werden

    ELSE.

    MESSAGE s159 WITH i_ftappl i_ftfront.

    • Datei &1 wurde nach &2 übertragen

    ENDIF.

    ENDIF.

    Add comment
    10|10000 characters needed characters exceeded

  • author's profile photo
    Former Member
    Sep 05, 2008 at 01:10 AM

    SOLVED

    Add comment
    10|10000 characters needed characters exceeded