Stephon_Gordon
Stephon_Gordon

Reputation: 45

Moving file to another directory in ABAP

I have got a service running in a specific directory in 5-second-intervals which is picking up an XML file created in that directory sending it for some necessary authorization checks to another client and then requesting a response file.

My issue is that my Z_PROGRAM creating the XML file might take longer than 5 seconds as a result of the file's size. Therefore creating the file in that specific directory is not preferable. I thought about creating a new folder in that directory called "temporary" and creating the file inside that folder, then once I'm done with it, moving it back outside for the service to pick it up.

Is there any way to move files from one directory to another via ABAP code only?

Copying the file manually is not an option since the problem that I have during file creation still persists. I need 2 alternatives, one used for local directories and one for application server directories. Any ideas?

Upvotes: 0

Views: 6561

Answers (3)

HatriGt Ace
HatriGt Ace

Reputation: 43

You can simply use System Call Commands to perform actions in Application Directory.

CALL 'SYSTEM' 
  ID 'COMMAND' 
  FIELD 'mv /usr/sap/temporary/File.xml
            /usr/sap/final/file.xml'

Upvotes: 0

charbel kisso
charbel kisso

Reputation: 11

there is no explicit move command in ABAP code that move or copy files between directories in application server.

there is two tips can be helpfull in your case. if you are writing big file you may seperate the logic behind collecting data and writing file. I would say don't execute transfer data inside your loop. instead collect you data into an internal table once you're done, loop over this internal table and write direclty strings without any delay you should be able to write a big files upp to several hundred of MB under 1 sec.

next tips is to not modify your program, or if you are using function modules to construct xml is, write to a temp directory after finishing, then have another program open you file on source directory by read dataset and directly write data to the new directory again just strings without interruptions.

you should be ok if you just write strings.

Upvotes: 0

mkysoft
mkysoft

Reputation: 5758

Generally, we create another empty file for completed files after the file creation process ends. Third parties must be firstly checked empty file is there. Example:

data file.csv
data file.ok

If you already completed your integration and it is not easy to make any change with third parties, I prefer using OS level file moving commands. Sample document here. You can use mv for Linux server and move for Windows. If your file is big, you will get same problem with OPEN DATASET concept. We have ARCHIVFILE_SERVER_TO_SERVER FM for moving files but it is also using OPEN DATASET.

Upvotes: 1

Related Questions