Application Development and Automation 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: 
Read only

Issues using FM - SXPG_COMMAND_EXECUTE

Former Member
0 Likes
1,867

Hello,

I have a requirement to create a unique folder in the SAP Application server based on the Production Order number and to dump certain files into this folder.

I have no issues creating the contents of the file, but am having issues creating the folder.

Below is how I am trying to acheive what I want.

z_dir = '/sapfiles/200/machinefiles/laser/&order/'.

REPLACE '&order' WITH z_char7 INTO z_dir.

where Z_char7 is the Production Order number.

In SM69, I have created an Operating System Command with

Command Name = ZTEST

Operating System Command = mkdir

When I test this using additional parameters as /sapfiles/200/machinefiles/laser/1111 [for example], the folder is created.

In my program, I use the FM SXPG_COMMAND_EXECUTE to execute my ZTEST operating system command name with the below parameters.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

COMMANDNAME = 'ZTEST'

ADDITIONAL_PARAMETERS = z_dir

  • OPERATINGSYSTEM = SY-OPSYS

  • TARGETSYSTEM = SY-HOST

  • DESTINATION =

  • STDOUT = 'X'

  • STDERR = 'X'

  • TERMINATIONWAIT = 'X'

  • TRACE =

  • DIALOG =

  • IMPORTING

  • STATUS =

  • EXITCODE =

  • TABLES

  • EXEC_PROTOCOL =

EXCEPTIONS

NO_PERMISSION = 1

COMMAND_NOT_FOUND = 2

PARAMETERS_TOO_LONG = 3

SECURITY_RISK = 4

WRONG_CHECK_CALL_INTERFACE = 5

PROGRAM_START_ERROR = 6

PROGRAM_TERMINATION_ERROR = 7

X_ERROR = 8

PARAMETER_EXPECTED = 9

TOO_MANY_PARAMETERS = 10

ILLEGAL_COMMAND = 11

WRONG_ASYNCHRONOUS_PARAMETERS = 12

CANT_ENQ_TBTCO_ENTRY = 13

JOBCOUNT_GENERATION_ERROR = 14

OTHERS = 15

.

The above FM in my program doesnt work.

Could you please let me know if I am missing anything or direct me to any other suitable method.

Thank you,

Satish

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,571

The FM seems to be fine. Please try to execute th FM directly from SE37. There are sometimes few authorization issue when this FM is called. Check out what exception the FM is throwing and try to investigate it around that.

If FM gets executed correctly then check in debug mode that variable Z_DIR is getting correct value. make sure that variable Z_DIR should be of type "sxpgcolist-parameters".

2 REPLIES 2
Read only

Former Member
0 Likes
1,572

The FM seems to be fine. Please try to execute th FM directly from SE37. There are sometimes few authorization issue when this FM is called. Check out what exception the FM is throwing and try to investigate it around that.

If FM gets executed correctly then check in debug mode that variable Z_DIR is getting correct value. make sure that variable Z_DIR should be of type "sxpgcolist-parameters".

Read only

0 Likes
1,571

Thanks Richa.

The variable z_dir had the wrong type.