1

Is there a way to specify the current working directory for the system command executed by the function module SXPG_COMMAND_EXECUTE?

I do not see any parameter which would allow me to do that either by defining the command in transaction SM69 or on the list of IMPORTING parameters in SE37.

It looks like by default such commands are started in DIR_HOME which can be viewed by the transaction AL11. Do I have any control over that?

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Jagger
  • 10,350
  • 9
  • 51
  • 93

3 Answers3

1

There isn't a way of doing it via `SM69' unfortunately. I think the only solution is to create a script and call that.

I was going to suggest wrapping the statements in a SM69 command defined as a call to sh with parameters of -c 'cd <dir> && /path/to/command' but unfortunately that doesn't work. According to note 401095 wildcards are not permitted. When I tested, && was translated into a single &, causing the command to fail.

mjturner
  • 1,035
  • 7
  • 16
0

Would be good if you access this information using FM FILE_GET_NAME_USING_PATH (export the script name for which you want to find the physical directory). The recieving path can be used in SXPG_COMMAND_EXECUTE.

0

Because the external commands I called were actually .bat files I solved this by putting the following expression at the beginning of each and every one.

cd /d %~dp0

This Stackoverflow question helped a lot actually.

Jagger
  • 10,350
  • 9
  • 51
  • 93