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: 

Moving file

Former Member
0 Kudos

Hi Group,

How to move the file from one directory to another on

application server.

6 REPLIES 6

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You need to copy it and delete the old. Here is a sample program.



report zrich_0001.

parameters: d1 type localfile default '/usr/sap/TST/<b>OLD</b>/Data1.txt',
            d2 type localfile default '/usr/sap/TST/<b>NEW</b>/Data1.txt'.

data: itab type table of string with header line.

start-of-selection.

* Read old
  open dataset d1 for input in text mode.
  if sy-subrc = 0.
    do.
      read dataset d1 into itab.
      if sy-subrc <> 0.
        exit.
      endif.
      append itab.
    enddo.
  endif.
  close dataset d1.

* Copy to new 
  open dataset d2 for output in text mode.
  loop at itab.
    transfer itab to d2.
  endloop.
  close dataset d2.
  
* Delete the old  
  delete dataset d1.

Regards,

Rich Heilman

Manohar2u
Active Contributor
0 Kudos

1. You can do with programatically using data sets.

Read the file

Write into new Location

Delete the old file.

2. Create on OS level command in SM69 ( You can test the same with SM49). Basis person will help you in creating OS command.

Then use SXPG_EXECUTE_COMMAND to move the file.

Regds

Manohar

andreas_mann3
Active Contributor
0 Kudos

hi,

look here:

A.

Former Member
0 Kudos

Hi

You can do a FTP command see the demo programs: RSFTP00*

Max

Former Member
0 Kudos

Use Function module - ARCHIVFILE_SERVER_TO_SERVER

Former Member
0 Kudos

Hi nitin,

1. Exactly for this purpose

i have developed an INDEPENDENT SUBROUTINE (FORM)

in which we pass

a) old file name

b) new file name

and it will rename the file

(This will work in WINDOWS Operating system)

(we can modify it very little for other OS also_

2. just copy paste in new program.

3.

Report abc.

*----


PERFORM MYRENAME USING 'D:\CCC.TXT' 'DDD.TXT'.

*----


  • FORM

*----


form myrename USING oldfile newfile.

data : pm(200) type c.

concatenate '/C REN ' oldfile newfile

INTO PM separated by space.

CALL FUNCTION 'GUI_RUN'

EXPORTING

COMMAND = 'CMD'

PARAMETER = pm

  • CD =

  • IMPORTING

  • RETURNCODE =

.

endform. "myrename

regards,a

amit m.