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

The mv command could not work with SXPG_COMMAND_EXECUTE

fanglin_ye
Participant
0 Likes
2,543

hello all,

i want to use the function SXPG_COMMAND_EXECUTE to move files from one folder to another on application server. So i created a command "Z_MV" using TC sm69. The additional_parameters for the function call SXPG_COMMAND_EXECUTE looks like "/home/transfer/fnn/in/*.xml /home/transfer/fnn/archiv". So i think, that should be equals to that i call the command "mv /home/transfer/fnn/in/*.xml /home/transfer/fnn/archiv" direct on the application server. But in practice it does not work. I got the error: mv: cannot access /home/transfer/fnn/in/*.xml. Could someone help me? thx.

regards,

Fanglin

8 REPLIES 8
Read only

Former Member
0 Likes
1,833

Can you go onto the server and execute your command?  If not then there is no way that SAP can.

Neal

Read only

0 Likes
1,833

hello Neal,

of course i can raun the command "mv /home/transfer/fnn/in/*.xml /home/transfer/fnn/archiv" on the server. On the server the SunOS is installed.

regards,

Fanglin

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,833

Can you please share with us how you have defined the external OS command?

BR,

Suhas

Read only

0 Likes
1,833

Hello Suhas,

hier is the screenshot about the external command:

Read only

0 Likes
1,833

I don't see a parameter in the command. I think you need to define that as well. Place a & in Parameter field to be able to use a parameter in your command

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,833

Can i ask you test the OS command directly via SM49/SM69?

@Peter - AFAIK that defining the params is not required as long as the "Additional parameters allowed" checkbox is checked

BR,

Suhas

PS - You can turn on the trace as well

Read only

0 Likes
1,833

hello Suhas,

i have changed my parameter in ABAP code:

from "/home/transfer/fnn/in/*.xml /home/transfer/fnn/archiv" to ""/home/transfer/fnn/in/Sample.xml /home/transfer/fnn/archiv"."

Then the function call "SXPG_COMMAND_EXECUTE" works. I think the command "mv" has problem with wildcard (e.g. *.xml) in function call "SXPG_COMMAND_EXECUTE".

regards,

Fanglin

Read only

KiranJ
Active Participant
0 Likes
1,833

Hi, check below,   DATA : ld_add_prmtrs TYPE sxpgcolist-parameters,         ld_status TYPE extcmdexex-status,                              ld_exitcode TYPE extcmdexex-exitcode,                    lt_btcxpm TYPE TABLE OF btcxpm,         lt_result_tab TYPE TABLE OF string,         ls_result LIKE LINE OF lt_result_tab,         ld_lines TYPE i,         ld_source(70) TYPE c,         ld_target(70) TYPE c,         ld_filename(70) TYPE c.   TRANSLATE filename TO LOWER CASE.   SPLIT filename AT '/' INTO TABLE lt_result_tab.   IF sy-subrc EQ 0.     DESCRIBE TABLE lt_result_tab LINES ld_lines.   ENDIF.   LOOP AT lt_result_tab INTO ls_result.     IF ls_result IS NOT INITIAL.       IF sy-tabix NE ld_lines.         CONCATENATE ld_source '/' ls_result INTO ld_source.       ELSE.         MOVE ls_result TO ld_filename.       ENDIF.     ENDIF.   ENDLOOP.   CONDENSE: ld_source.   MOVE ld_source TO ld_target.   REPLACE 'your directoy' IN ld_target WITH 'arch'.   CONCATENATE ld_filename ld_source ld_target                                   INTO ld_add_prmtrs SEPARATED BY space.   CALL FUNCTION 'SXPG_COMMAND_EXECUTE'     EXPORTING       commandname                  = 'XXXXXX'       additional_parameters        = ld_add_prmtrs     IMPORTING       status                        = ld_status       exitcode                      = ld_exitcode     TABLES       exec_protocol                = lt_btcxpm     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.