cancel
Showing results for 
Search instead for 
Did you mean: 

SXPG_COMMAND_EXECUTE

Former Member
0 Kudos

Hi,

I am trying to run SXPG_COMMAND_EXECUTE FM. but in one client it raises the exception "No Permission". and in the other client it raises "Command not found". Can you please guide me how do I rectify both of these exceptions.

Thank You,

SB.

Accepted Solutions (1)

Accepted Solutions (1)

former_member188685
Active Contributor
0 Kudos

Hi Check the command in sm69

The command name identified COMMANDNAME and OPERATINGSYSTEM has not been defined in the maintenance function (Transaction SM69).

Former Member
0 Kudos

Hi Vijay,

In SM69 my

command name is :- Z_MY_COMMAND

Operating system is AIX

Type is Customer

Operating system command is mv

Parameters for OS is blank

Additonal parameters allowed checkbox is checked.

This info is avaliable for me in both of the clients... I checked this by going to Tcode SM49 in both clients...

In my second client (where is throws exception "No Permission"... If I do not have authorization for S_LOG_COM , S_RZL_ADM... then how do I get that??....

For the first client where it says "Command not found" how should I rectify this??

Please help.

Thank You.

former_member188685
Active Contributor
0 Kudos

Hi for the Authorizations you need to contact Basis team .

<b>case2</b>

<b>for testing check the sy-subrc it might be 12, so change it to 0 and try to see the results...

after that check the command also....

But i think in this case also you should get command not found.</b>

case1;

you have authorizations, but command faield...

i think passing may be wrong, or command not maintained fully...

check them also using sy-subrc

regards

vijay

former_member188685
Active Contributor
0 Kudos

can you give the code how you are passing it to FM..

regards

vijay

former_member188685
Active Contributor
0 Kudos

Hi

Are you still facing some problem with that ..

please let me know..

regards

vijay

Former Member
0 Kudos

REPORT ZREPORT.

DATA: FILENAME(100) VALUE 'C:\Testfiles\AP-INT-001 TEST FILE.txt',

FILENAME1(100) VALUE '/holdarchlogs/outbound/testfile.txt',

FILENAME1_ARCH_DIR(100) VALUE '/tmp/testfile.txt',

Z_MY_COMMAND TYPE SXPGCOLIST-NAME,

FINAL_ARCHIVE_DIR TYPE SXPGCOLIST-PARAMETERS,

MSGS(256),

G_FILE TYPE STRING.

DATA: BEGIN OF T_DATATAB OCCURS 0,

LINE(1000),

END OF T_DATATAB.

DATA: T_MOVETODIR LIKE BTCXPM OCCURS 0 WITH HEADER LINE.

G_FILE = FILENAME.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

FILENAME = G_FILE

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = ' '

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

TABLES

DATA_TAB = T_DATATAB

  • EXCEPTIONS

  • FILE_OPEN_ERROR = 1

  • FILE_READ_ERROR = 2

  • NO_BATCH = 3

  • GUI_REFUSE_FILETRANSFER = 4

  • INVALID_TYPE = 5

  • NO_AUTHORITY = 6

  • UNKNOWN_ERROR = 7

  • BAD_DATA_FORMAT = 8

  • HEADER_NOT_ALLOWED = 9

  • SEPARATOR_NOT_ALLOWED = 10

  • HEADER_TOO_LONG = 11

  • UNKNOWN_DP_ERROR = 12

  • ACCESS_DENIED = 13

  • DP_OUT_OF_MEMORY = 14

  • DISK_FULL = 15

  • DP_TIMEOUT = 16

  • OTHERS = 17

.

IF SY-SUBRC <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ENDIF.

  • open file

OPEN DATASET FILENAME1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT

MESSAGE MSGS.

IF SY-SUBRC <> 0.

WRITE: 'File could not be opened', MSGS.

ENDIF.

  • transfering data.

LOOP AT T_DATATAB.

TRANSFER T_DATATAB TO FILENAME1.

ENDLOOP.

  • Close file.

CLOSE DATASET FILENAME1.

  • command = 'mv /holdarchlogs/outbound/seema1.txt /tmp/seema1.txt'.

    • command = 'mv /holdarchlogs/outbound/seema.txt /tmp/seema1.txt

  • CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND ID 'TAB' FIELD TABL-SYS.

  • Achieving the above functionality by using FM

CONCATENATE FILENAME1 FILENAME1_ARCH_DIR INTO

FINAL_ARCHIVE_DIR SEPARATED BY SPACE.

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

COMMANDNAME = Z_MY_COMMAND

ADDITIONAL_PARAMETERS = FINAL_ARCHIVE_DIR

OPERATINGSYSTEM = SY-OPSYS

  • TARGETSYSTEM = SY-HOST

  • DESTINATION =

  • STDOUT = 'X'

  • STDERR = 'X'

  • TERMINATIONWAIT = 'X'

  • TRACE =

  • IMPORTING

  • STATUS =

  • EXITCODE =

TABLES

EXEC_PROTOCOL = T_MOVETODIR

  • 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

.

IF SY-SUBRC = 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

WRITE: 'SUCCESS'.

ENDIF.

Former Member
0 Kudos

Your path to the command may be wrong on the system where it is giving you the "command not found" message. After that, if the command is found, it then determined that you don't have the necessary <b>operating system</b> level authorizations for the command.

Are these really two clients or two systems? Can you go to the corresponding AIX box and run the MV command?

Srinivas

former_member188685
Active Contributor
0 Kudos

try to uncomment the exceptions while calling FM.

and Keep a Break point in the FM where it is raising No permission, and Command not found...

what happened to other way..

CALL 'SYSTEM' ID 'COMMAND' FIELD COMMAND ID 'TAB' FIELD TABL-SYS.

is it working..

please let me know...

regards

vijay

Former Member
0 Kudos

Well that command was not accepted by the other team and they said that it was a bad way of programming... ... So only I am trying to find an alternative.

former_member188685
Active Contributor
0 Kudos

Try to check the Parameters once which you are passing to Fm.

regards

vijay

former_member188685
Active Contributor
0 Kudos

Try to check it once, Tomorrow i will find out..from

your posts

Former Member
0 Kudos

DO u know How do I get authorization for object s_log_com & s_rzl_adm ??

former_member188685
Active Contributor
0 Kudos

COntact BASIS team ....

what happend, if your Problem solves then please close the thread and reward for helpful answers

vijay

Former Member
0 Kudos

hi,

Can you tell me what is additional parameter and what should be passed to it??

-SB

former_member188685
Active Contributor
0 Kudos

Check whether you have Maintained properly or not

to test that call this fm and find out your command is in the command list...

    CALL FUNCTION 'SXPG_COMMAND_LIST_GET'
         EXPORTING
              COMMANDNAME     = COMMANDNAME
              OPERATINGSYSTEM = '*'
         TABLES
              COMMAND_LIST    = COMMAND_LIST
         EXCEPTIONS
              OTHERS          = 1.

    IF SY-SUBRC <> 0 .
       RAISE X_ERROR .
    ENDIF

Former Member
0 Kudos

Hi,

I am able to run this in the first client (where it was saying command not found)...

Regarding the second client where no_permission error was thrown I may get the permission from someone in the authorizing team ...

Thank a lot for all your help .....

Former Member
0 Kudos

Please reward and close the thread.

Thanks,

Srinivas

former_member188685
Active Contributor
0 Kudos

please close the thread and reward points for helpful answers..

vijay

Former Member
0 Kudos

Last time... I was able to move this file with the help of this FM.. but if I am writing this FM in the same program then immediately the files are getting moved to the destination folders... What I want is that after the files get processed by the other (opposite) application system ... then the files should move to the destination folder .... Does it means that I have to write this FM in a seperate program and schedule it in background??

former_member188685
Active Contributor
0 Kudos

Yeah do it separately,, then code according to your logic..

regards

vijay

Former Member
0 Kudos

ok thank you....

Answers (7)

Answers (7)

Former Member
0 Kudos

You should ask your basis team for it.

Former Member
0 Kudos

Besides SAP authorization checks, you also need the necessary authorization to execute the command in the OS.

Former Member
0 Kudos

Try giving a ? in the Parameters for operating system command in the command, since u have to pass filenames.

Also check the commands in tables SXPGCOTABE, SXPGCOSTAB. In the FM they look for the command by passing command name and OS.

Former Member
0 Kudos

Are you using the FM in the following manner

data : w_name like SXPGCOLIST-NAME.

data : w_para like SXPGCOLIST-PARAMETERS.

data : it_result like BTCXPM occurs 0 with header line.

Where w_name is the command name and

w_para is the parameter in your case it should be the file name .

CALL FUNCTION 'SXPG_COMMAND_EXECUTE'

EXPORTING

COMMANDNAME = w_name

ADDITIONAL_PARAMETERS = w_para

OPERATINGSYSTEM = sy-opsys

TABLES

EXEC_PROTOCOL = it_result

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.

former_member188685
Active Contributor
0 Kudos

hi please reward for helpful answers..

regards

vijay

former_member188685
Active Contributor
0 Kudos

You need Authorizations to run , because of that it gave no permission.

Command is not maintained in sm69, so it gave command not found..

regards

vijay

former_member188685
Active Contributor
0 Kudos

for no permission this is the reason,.,.,

The AUTHORITY-CHECK of the user's authorization for the authorization obejct S_LOG_COM failed. The user is not authorized to execute the command with the specified arguments in thte target system.

Former Member
0 Kudos

Hi

You need authorizaions on objects S_LOG_COM , S_RZL_ADM .

Also to be able to able to execute this FM you should have the OS commands defined in SM69.

Regards

Kalidas

Message was edited by: Kalidas Cheroolil