Application Development 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: 

To move a file within the FTP server.

Former Member
0 Kudos
127

Hi Experts,

I have a requirement to write a ABAP proagram to move a xml file(600MB size) to a archive directory within the same FTP server.

Requirements:

source file should be deleted after archiving.

target file name = <source file name + timestamp>.

should archive everyday at 10:00 am

Please guide or refer to sample program.

Thanks in advance.

MK

2 REPLIES 2

Former Member
0 Kudos
74

Please suggest on how to achieve the above requirement.

0 Kudos
74

Hi MK,

May be this is use full for you.... let me know if you have any questions.

data: begin of itab occurs 0,

rec(1000) type c,

end of itab.

data: wa(1000) type c.

data : l_ref type REF TO CX_SY_FILE_IO,

l_text type string.

data: p_file type localfile.

data: p_file1 type localfile,

l_dummy type n.

data: ifile type table of salfldir with header line.

data: lv_date type sy-datum,

lv_time type sy-uzeit.

lv_date = sy-datum.

Lv_time = sy-uzeit.

selection-screen begin of block b1 with frame title text-001.

parameters: p_sorc type salfile-longname,

P_fname(30) type c,

p_dest type salfile-longname.

selection-screen end of block b1.

concatenate p_dest lv_date lv_time into p_dest.

at selection-screen.

if p_sorc is initial.

message e000(ps) with 'Enter the Source file- mandatory'.

endif.

if p_dest is initial.

message e000(ps) with 'Enter the target file-mandatory'.

endif.

call function 'RZL_READ_DIR_LOCAL'

EXPORTING

name = p_sorc

TABLES

file_tbl = ifile

EXCEPTIONS

argument_error = 1

not_found = 2

others = 3.

loop at ifile.

concatenate p_sorc '/' ifile-name into p_file.

concatenate p_dest '/' ifile-name into p_file1.

clear itab.

refresh itab.

OPEN DATASET p_file IN TEXT MODE ENCODING DEFAULT FOR INPUT.

if sy-subrc = 0.

open dataset p_file1 for output in text mode encoding default.

if sy-subrc = 0.

do.

try.

read dataset p_file into wa.

if sy-subrc <> 0.

exit.

endif.

transfer wa to p_file1.

catch CX_SY_FILE_IO into l_ref.

l_text = l_ref->get_text( ).

write: /'sub Directory found under', l_text.

l_dummy = l_dummy + 1.

exit.

endtry.

enddo.

endif.

if l_dummy > 0.

write : / p_file , 'Was not copied to' , p_file1.

else.

write : / p_file , 'Was copied to ' , p_file1 .

endif.

endif.

close dataset p_file.

delete dataset p_file.

close dataset p_file1.

clear l_dummy.

endloop.

Reward points..

---Anji