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: 

sy-subrc 801

0 Kudos

I have written a program to simply strip the timestamp off ftp'd files.

I identify the filename and the use 'SXPG_COMMAND_EXECUTE' to call a custom command ZMV which calls the OS mv command to rename the file. I have tested this in my test environment, but when I moved to production, the program runs, but returns an 801 and the files are not renamed. Google hasn't been very helpful on this one. Anyone know what my issue is?

1 ACCEPTED SOLUTION

venkateswaran_k
Active Contributor

Hi

What is the Operating system command - you are executing in this FM.

This FM - should return a table (protocol table). Check what are the entries in that table in debug

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = your command
OPERATINGSYSTEM = your Operating system
TARGETSYSTEM = SY-HOST
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE = 'X'
ADDITIONAL_PARAMETERS = your Parameters
IMPORTING
STATUS = your status
TABLES
EXEC_PROTOCOL = IT_CMD_OUTPUT "Return table(ur gt_log) <=== check this table

Check this IT_CMD_OUTPUT table and update what is the log it says.

Regards,

Venkat

10 REPLIES 10

venkateswaran_k
Active Contributor

Hi

What is the Operating system command - you are executing in this FM.

This FM - should return a table (protocol table). Check what are the entries in that table in debug

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
COMMANDNAME = your command
OPERATINGSYSTEM = your Operating system
TARGETSYSTEM = SY-HOST
STDOUT = 'X'
STDERR = 'X'
TERMINATIONWAIT = 'X'
TRACE = 'X'
ADDITIONAL_PARAMETERS = your Parameters
IMPORTING
STATUS = your status
TABLES
EXEC_PROTOCOL = IT_CMD_OUTPUT "Return table(ur gt_log) <=== check this table

Check this IT_CMD_OUTPUT table and update what is the log it says.

Regards,

Venkat

0 Kudos

The OS command is mv

Reply to answers as comments, not as answers. Do what Venkat says. What does IT_CMD_OUTPUT contain? Also, what is your OS? Some variant of unix, I guess?

0 Kudos

When I run the program interactively (debugger) I am getting SY-SUBRC = 2 (Command not found). This is not the same as the 801 I'm getting when run as system user in batch. I have confirmed that the command exists in SXPGCOSTAB.

0 Kudos
plott722 Can you answer Venkat and Matthew questions please?

0 Kudos

I get a RC = 2 when running via the debugger. I get the 801 when running in batch. The ask above was "Check what are the entries in that table in debug" - but I don't get the 801 when stepping through the program.

Here is my log:

abap-log.png

Sandra_Rossi
Active Contributor
0 Kudos

You say "sy-subrc = 801", how is that possible? After CALL FUNCTION ... the possible values of sy-subrc are defined via EXCEPTIONS and 801 is probably not assigned to one of these exceptions (usually 1 to often not more than 20).

You say "Google is not helpful", but you should first look at SAP notes.

sy-subrc would be 2 if the command is not found if you write this (because here the exception command_not_found is to assign the value 2 to sy-subrc):

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
    ...
    EXCEPTIONS
        no_permission                 = 1
        command_not_found             = 2
        ...

Solution: check what Venkat and Matthew proposed.

So, turns out that in our Dev and Test systems the ZMV (mv) command was created with OPSYSTEM = UNIX

However, in our Prod system this was create with OPSYSTEM = 'AIX'.

Thanks for all the help!

0 Kudos

Thanks for the feedback.

To clarify the situation for future visitors:

  • The exception COMMAND_NOT_FOUND is raised by SXPG_COMMAND_EXECUTE if the command in parameter COMMANDNAME for the operating system in parameter OPERATINGSYSTEM does not exist in SM49/SM69.
  • At the same time, you get the message LC2 "Error 801 when executing external command on (xpgid=0,convid=.)" in the System Log (SM21).

matt
Active Contributor
0 Kudos

I'm not going further with this issue, due to the unclear information. My guess based on years of experience that it's an authorisation problem.

OP - ask Basis to check the permissions on the directory.