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

Copying Files in application server

Former Member
0 Likes
3,316

Hi,

I'm having this program that's supposed to copy files from directories within the application server

into other directories there.

I used the method "copy_files_local" as advised in another thread of the class cl_cts_language_file_io.

The problem is that I'm getting an exception when it uses the 'esp_get_file_attributes' function with sy-subrc=2

meaning it failed to read the file's attributes.

  CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
        EXPORTING
             file_name              = im_source_file
             dir_name               = im_source_directory
        IMPORTING
             file_size              = lv_source_file_size
        EXCEPTIONS
             read_directory_failed  = 1
             read_attributes_failed = 2
             OTHERS                 = 3.


I for now just used hard codes for the directories and files addresses as I wanted to see if that method works first.

According to the raised exception I assume it's not the cause of the problem but here's the call method code anyway.


CALL METHOD cl_cts_language_file_io=>copy_files_local
   EXPORTING
     im_source_file           = 'P&G_URI.btw'
     im_source_directory      = '\sapprdap1_MIG'
     im_target_file           = 'P&G_URI.btw'
     im_target_directory      = '\hq-plabels-dev'
     im_overwrite_mode        = SPACE

   EXCEPTIONS
     open_input_file_failed   = 1
     open_output_file_failed  = 2
     write_block_failed       = 3
     read_block_failed        = 4
     close_output_file_failed = 5
     others                   = 6
         .
     IF sy-subrc = 0.
       MESSAGE 'Operation Succeeded' TYPE 'S'.
     ELSE.
       MESSAGE 'Operation Failed' TYPE 'E'.
     ENDIF.




Any ideas?


Thanks in advance,

Daniel.

Hi,

I'm having this program that's supposed to copy files from directories within the application server

into other directories there.

I used the method "copy_files_local" as advised in another thread of the class cl_cts_language_file_io.

The problem is that I'm getting an exception when it uses the 'esp_get_file_attributes' function with sy-subrc=2

meaning it failed to read the file's attributes.

  CALL FUNCTION 'EPS_GET_FILE_ATTRIBUTES'
        EXPORTING
             file_name              = im_source_file
             dir_name               = im_source_directory
        IMPORTING
             file_size              = lv_source_file_size
        EXCEPTIONS
             read_directory_failed  = 1
             read_attributes_failed = 2
             OTHERS                 = 3.


I for now just used hard codes for the directories and files addresses as I wanted to see if that method works first.

According to the raised exception I assume it's not the cause of the problem but here's the call method code anyway.


CALL METHOD cl_cts_language_file_io=>copy_files_local
   EXPORTING
     im_source_file           = 'P&G_URI.btw'
     im_source_directory      = '\sapprdap1_MIG'
     im_target_file           = 'P&G_URI.btw'
     im_target_directory      = '\hq-plabels-dev'
     im_overwrite_mode        = SPACE

   EXCEPTIONS
     open_input_file_failed   = 1
     open_output_file_failed  = 2
     write_block_failed       = 3
     read_block_failed        = 4
     close_output_file_failed = 5
     others                   = 6
         .
     IF sy-subrc = 0.
       MESSAGE 'Operation Succeeded' TYPE 'S'.
     ELSE.
       MESSAGE 'Operation Failed' TYPE 'E'.
     ENDIF.




Any ideas?


Thanks in advance,

Daniel.

7 REPLIES 7
Read only

Former Member
0 Likes
2,257

Hi,

Did you checked for authorizations for writing into that directory ? You are getting subrc = 2 which says that it is not able to create an output file in that location.

Read only

0 Likes
2,257

Yeah there shouldn't be a problem in that regard.

Read only

0 Likes
2,257

As also suggested by Sander, check if the directory has been maintained in tcode AL11. SAP system can only access the directories listed in AL11. So, if it is not there then it has to be added.

Read only

former_member192854
Active Participant
0 Likes
2,257

Normally your 'regular' server directory will be something like:

/usr/interface/<SYSID>/

have you checked AL11 that this directory is available?

Read only

Former Member
0 Likes
2,257

Hi Daniel,

Application server Operating system is windows ? If No then directory will start with /sapprdap1_MIG

Thanks & Regards,

Arun

Read only

0 Likes
2,257

yes it is windows.

I tried different variations of this, lastly tried this one looking carefully for caption and got sy-subrc=5.

** Addresses are the same as last time, for some reason when I pasted the addresses here it copied them partially.

    im_source_file           = 'P&G_Uri.btw'
     im_source_directory    =  '\\hq-plabels-dev\Labels\RLabel'
     im_target_file           = 'P&G_Uri.btw'
     im_target_directory      = '\\sapprdap1\inventory\MBMM_MIGO'
     im_overwrite_mode        = SPACE

Read only

0 Likes
2,257

Please check for authorizations using the function module AUTHORITY_CHECK_DATASET

for the output directory