2005 Apr 25 10:56 AM
Hi,
i need to rename files on the application server.
I've found some sourcecode in a SAP Cookbook to run commands on the application server which looks like this
OPEN DATASET
'D:\Test\test.txt'
FOR OUTPUT
FILTER
C:\winnt\system32\cmd.exe /c ren <old_filename> <new_filename>
IN TEXT MODE.
The problem is, that sometimes it works pretty good, sometimes it only looks pretty good (RC = 0) but the filename has not changed and sometimes it even dumps.
I've been searching for functions but had no luck,
is there another possibility to rename filenames on the application server?
Tia
Timo
2005 Apr 25 11:01 AM
Hi Timo,
The best way is to set up an external command via transaction SM69. Here you can establish the command and its parameters.
Once the command is set up, you can execute it using the function module SXPG_COMMAND_EXECUTE.
BTW - You can test commands are working via transaction SM49.
Hope that helps.
Cheers,
Brad
2005 Apr 26 10:06 AM
Hi Timo
As Brad pointed out, you can acheive it setting up external command using Transaction SM69.
You can make a DOS command file with place holders
Example: file name- test.cmd (simply make a notepad file and save it as cmd file with following contents):
ren %1 %2
The advantage with making such a file is that we can even give more than one command.
SM69: (create)
Command name : ztest1
Operating Sysyem : Windows NT (case sensitive)
Operating System Command : c:\usr\sap\test.cmd
Addition Parameters Allowed : X
In order to achieve the renaming functionality in the program, call function: SXPG_COMMAND_EXECUTE where we supply command name (ztest1 as per above example) and additional parameters(for place holders).
Hope that will serve your purpose
Regards
Ashish Jain
ashishjain@ko-india.com
2016 Jul 18 10:30 AM
For Windows NT: Operating System Command
Rename = "cmd /c ren"
Copy = "cmd /c copy"
Delete = "cmd /c del"
It's never to late to reply