09-19-2008 1:04 PM
Hi, Im using open dataset, transfer, close dataset to write data on unix server. Problem is, that all files i write by this ABAP command, have permission 660. I want to set it to 644. Is it possible, if I am not allowed to use unix commands in ABAP?
THX
09-19-2008 1:12 PM
Hi,
Create one external unix command in SM69.
In that transaction, input "chmod" in the "Operation system command" field.
in the "Parameters for operating system command" input "644 &"
Lets say the external command you created is "'ZFMM_CHMOD1'".
Now we need to call this in ABAP.
data: w_output TYPE SXPGCOLIST-PARAMETERS VALUE '/tmp/swa.txt' ,
w_command TYPE SXPGCOLIST-name VALUE 'ZFMM_CHMOD1'.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = w_command
ADDITIONAL_PARAMETERS = w_output
IMPORTING
STATUS = w_status
TABLES
EXEC_PROTOCOL = LOG
Edited by: Swastik Bharati on Sep 19, 2008 2:13 PM
09-19-2008 1:12 PM
Hi,
Create one external unix command in SM69.
In that transaction, input "chmod" in the "Operation system command" field.
in the "Parameters for operating system command" input "644 &"
Lets say the external command you created is "'ZFMM_CHMOD1'".
Now we need to call this in ABAP.
data: w_output TYPE SXPGCOLIST-PARAMETERS VALUE '/tmp/swa.txt' ,
w_command TYPE SXPGCOLIST-name VALUE 'ZFMM_CHMOD1'.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = w_command
ADDITIONAL_PARAMETERS = w_output
IMPORTING
STATUS = w_status
TABLES
EXEC_PROTOCOL = LOG
Edited by: Swastik Bharati on Sep 19, 2008 2:13 PM
09-19-2008 1:39 PM
it looks good. I wrote this code but still there is some bug, because it returns me exception COMMAND_NOT_FOUND. But i created it in SM69. Mayby problem is, that i didn't create transport for that command... or mayby something with authorization on unix?
REPORT ytest.
DATA: w_output TYPE sxpgcolist-parameters VALUE
'/usr/sap/trans/IS/files/out/spotreby_jmp.tab',
w_command TYPE sxpgcolist-name VALUE 'ZMDM_CHMOD',
w_status TYPE extcmdexex-status,
log TYPE STANDARD TABLE OF btcxpm.
CALL FUNCTION 'SXPG_COMMAND_EXECUTE'
EXPORTING
commandname = w_command
additional_parameters = w_output
IMPORTING
status = w_status
TABLES
exec_protocol = log
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.
Edited by: Filip Kouba on Sep 19, 2008 2:40 PM
09-19-2008 1:51 PM
you can even use this..
REPORT ZUNIX line-size 400
no standard page heading.
data : unixcom like rlgrap-filename.
data: begin of tabl occurs 500,
line(400),
end of tabl.
data: lines type i.
*----------------------------------------------------------------------
start-of-selection.
refresh tabl.
unixcom = 'CHMOD 644 filefullpath'.
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
"if there is any error then you can get the error details in tbal
"Loop the tabl and write the results.
09-19-2008 2:07 PM
2Vijay: it returns sy-subrc = -1. What it means, when sy-subrc is with minus?