09-08-2010 3:10 PM
Hi all.
i used the FM SXPG_CALL_SYSTEM as below
w_ext_cmd = 'ZREMSH'.
w_params = 'HARP -L BATCHMGR LS -L ~ORDER_BOOKING/PMAIL/DV4/*.TXT'.
CALL FUNCTION 'SXPG_CALL_SYSTEM'
EXPORTING
commandname = w_ext_cmd
additional_parameters = w_params
.....
.......
ZHREMSH was already added by BASIS.
the output was ERROR:
18 permission denied.
44 External program terminated with exit code 1
i loggen in into my user Account.
can u please provide me the process how i can execute it successfully. If possible with a sample program.
thanks,
Ajay
09-08-2010 3:20 PM
Try this kind of report
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = lv_command
additional_parameters = lv_parameters
IMPORTING
exitcode = exitcode
TABLES
exec_protocol = lt_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.
CALL FUNCTION 'DB6_SHOW_SXPG_ERROR'
EXPORTING
commandname = lv_command
additional_parameters = lv_parameters
server = sy-host
return_code = sy-subrc
exitcode = exitcode
TABLES
exec_protocol = lt_protocol
EXCEPTIONS
OTHERS = 0.
You may then analyze the errors, which are not always related to the Abap code.
Regards,
Raymond
09-08-2010 3:15 PM
Hi Ajay,
Refer below code snippet :
DATA: DIR_PREFIX(40) TYPE C VALUE '/usr/sap/trans/SID/BACCHUS',
FROM_FILE(125) TYPE C,
TO_FILE(125) TYPE C,
W_MESS_AREA LIKE TSL1D-AREA VALUE 'LC',
W_MESS_AREA_SUB LIKE TSL1D-SUBID VALUE '0',
W_CMD LIKE SXPGCOLIST-NAME, "cmd name
W_STATUS LIKE BTCXP3-EXITSTAT, "cmd exit status
W_PARM LIKE SXPGCOLIST-PARAMETERS. "cmd parameters
DATA: RTAB LIKE BTCXPM OCCURS 20 WITH HEADER LINE.
* Logical command name
MOVE: COMMAND TO W_CMD,
IN_FILE TO FROM_FILE,
OUT_FILE TO TO_FILE.
* Check directory prefix
REPLACE 'SID' WITH SY-SYSID INTO DIR_PREFIX.
CONDENSE DIR_PREFIX NO-GAPS.
IF FROM_FILE(24) NE DIR_PREFIX(24) OR
TO_FILE(24) NE DIR_PREFIX(24).
MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 107 WITH FROM_FILE(24).
ENDIF.
CONCATENATE FROM_FILE
TO_FILE
INTO
W_PARM
SEPARATED BY SPACE.
CALL FUNCTION 'SXPG_CALL_SYSTEM'
EXPORTING
COMMANDNAME = W_CMD
ADDITIONAL_PARAMETERS = W_PARM
IMPORTING
STATUS = W_STATUS
* EXITCODE =
TABLES
EXEC_PROTOCOL = RTAB
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
OTHERS = 12.
IF SY-SUBRC NE 0.
IF SY-SUBRC EQ 4.
MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 105 WITH SY-SUBRC
FROM_FILE.
ELSE.
MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 106 WITH SY-SUBRC
TO_FILE.
ENDIF.
ELSE.
IF W_STATUS EQ 'O'.
* Command executed
READ TABLE RTAB INDEX 1.
IF RTAB-MESSAGE CO '1234567890 '.
ELSE.
* Executed command came back with an error
MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 108 WITH RTAB-MESSAGE.
ENDIF.
ELSE.
* Command not executed
* MESSAGE ID 'ZBCSTANDARD' TYPE 'E' NUMBER 109 WITH w_status
* to_file.
ENDIF.
ENDIF.
ENDFORM. " MOVE_FILE
Regards
Abhii
09-08-2010 3:20 PM
Try this kind of report
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = lv_command
additional_parameters = lv_parameters
IMPORTING
exitcode = exitcode
TABLES
exec_protocol = lt_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.
CALL FUNCTION 'DB6_SHOW_SXPG_ERROR'
EXPORTING
commandname = lv_command
additional_parameters = lv_parameters
server = sy-host
return_code = sy-subrc
exitcode = exitcode
TABLES
exec_protocol = lt_protocol
EXCEPTIONS
OTHERS = 0.
You may then analyze the errors, which are not always related to the Abap code.
Regards,
Raymond