‎2013 Sep 25 4:15 PM
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
‎2013 Sep 25 4:27 PM
Can you go onto the server and execute your command? If not then there is no way that SAP can.
Neal
‎2013 Sep 26 7:44 AM
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
‎2013 Sep 26 8:46 AM
Can you please share with us how you have defined the external OS command?
BR,
Suhas
‎2013 Sep 26 9:29 AM
Hello Suhas,
hier is the screenshot about the external command:
‎2013 Sep 26 9:34 AM
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
‎2013 Sep 26 9:40 AM
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
‎2013 Sep 26 10:34 AM
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
‎2013 Sep 26 10:51 AM
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.