08-22-2013 11:37 AM
Hello everyone,
We had a Test system that just been upgraded and there was programs that read file and delete from server.
İts standard SAP code!!
İ simplified it and foun found out that
delete dataset <fıle_name> doesnt work!!!
it works in all systems except this upgraded one, other systems havent been upgraded!!
Code is like this:
I looked at snotes: 18273
The auth object i check works fine but delete dataset returns subrc 4 and fails to delete!!
*&---------------------------------------------------------------------*
*& Report ZZZ_MC_ALV1
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
"\\172.20.7.93\entegrasyon$
REPORT ZZZ_SOLEN_ALV1.
TYPE-POOLS SABC.
data: gv_line type string.
data: full_name type string.
data: lv_message(100).
DATA myref TYPE REF TO CX_SY_FILE_AUTHORITY .
DATA err_text TYPE string.
"E:\USR\SAP\ENTEGRASYON\ISLENMEMIS\XX.TXT
FULL_NAME = 'e:\usr\sap\entegrasyon\islenmemis\xx.txt'.
write:sy-subrc.
break sdogan.
DATA: lv_file_name type AUTHB-FILENAME.
lv_file_name = full_name.
**Check the auth object
CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
EXPORTING PROGRAM = SY-REPID
ACTIVITY = sabc_act_delete
FILENAME = lv_file_name
EXCEPTIONS NO_AUTHORITY = 1
ACTIVITY_UNKNOWN = 2.
write:sy-subrc.
open dataset full_name for input message lv_message
in text mode encoding non-unicode.
write:/ 'Open dataset:' , sy-subrc.
do.
read dataset full_name into gv_line.
if sy-subrc eq 0.
write:/ gv_line.
else.
exit.
endif.
enddo.
close dataset full_name.
write:/ 'Close dataset:' , sy-subrc.
delete dataset full_name.
write:/ 'Delete dataset:' , sy-subrc.
*form backup_file using pv_in_dir
* pv_in_backup_dir type salfile-longname
* pv_fname like gt_infiles-name.
* data str type string.
* data cmd(256) type c.
* data: lt_list(250) occurs 50 with header line.
*
* clear: lt_list, lt_list[].
* concatenate 'CACLS' ',' c_in_dir pv_fname ',/E,/P,EVERYONE:F'
* into str.
* translate str using ', '.
* cmd = str.
* call 'SYSTEM' id 'COMMAND' field cmd
* id 'TAB' field lt_list-*sys*.
*
* clear: lt_list, lt_list[],cmd,str.
* concatenate 'copy' ',' pv_in_dir pv_fname ','
* pv_in_backup_dir pv_fname into str.
*
* translate str using ', '.
* cmd = str.
* call 'SYSTEM' id 'COMMAND' field cmd
* id 'TAB' field lt_list-*sys*.
*
* check sy-subrc eq 0.
*
* " yedeği alınmış dosya silinir
* delete dataset full_name.
* if sy-subrc is initial.
* endif.
*
*endform. " backup_file
08-22-2013 3:26 PM
Guys i have tested smth and found the reason for it...
Test: I have uploaded a file using cg3z call it test.txt to the same folder where
delete dataset didnt work
And then try the delete dataset test.txt and it worked!!!
Then checked the owner of the file: its called Sapservice etc..
Some idea came to my mind:
so talk to the Basis guys to give this user full access to this directory
And now all works fine!!
it was the SAP user that was lacking the full control
but why there was no error on the auth object on delete!!
So issue is solved guys thanks to you all
08-22-2013 12:14 PM
I also had a look at the link
http://help.sap.com/saphelp_nw04/helpdata/en/fc/eb3d5c358411d1829f0000e829fbfe/content.htm
But still no help as the auth object is fine!!
08-22-2013 12:30 PM
maybe you should add some exception handling to your code and query for the error.
I guess you are checking sy-subrc ?
Add also a try catch block to catch the error. It will give you just that little more info about what is happening and why.
Return Value
sy-subrc | Meaning |
0 | File deleted. |
4 | File could not be deleted. |
Catchable Exceptions
08-22-2013 12:41 PM
Hello Peter
Yes ye sı thought the same
I have added try catch
but nothing more then return code 4
seem like security but other systems same server works how?
08-22-2013 12:42 PM
I can read the filke by read dataset no issues
open dataset is fine too
but delete dataset has issue
08-22-2013 12:57 PM
Ok, maybe try a wait statement after the close dataset (lock on dataset not lifted immediately? or dataset not closed yet by filesystem ?). I am guessing now, no way I want to make it look that this is the solution.
It is strange. I guess you did check that the filename is correct at the time of this statement in debugging mode ?
Sorry I am out of options. The delete dataset statement has always worked for me.
08-22-2013 12:57 PM
I tried looking for Notes, but OSS is sick today. Have you looked for notes yet?
Neal
08-22-2013 1:00 PM
Hello Neal my friend:
Thanks, I looked for Notes..
there was few notes on delete dataset
İ have gone thru most of them
with no success
just i thought its the auth object
but auth object returns Ok no authorization issues at all
08-22-2013 1:13 PM
Hi Solen,
Is there any chance that it's server level authorizations and not SAP authorizations. I know that on our system, we have to get server level authorizations before SAP can reach into a new directory. Also, on the server level, many systems have distinct authorizations for read, write, delete and something else that I'm not sure I know enough about to comment on...
Neal
08-22-2013 2:46 PM
I have been talking to the Basis people and they told me the directory has full control and in other places there is no issue
There is a program where you can execute the OS level commands
its called
RSBDCOS0
ı have tried on that and logs to sm21
08-22-2013 3:20 PM
08-22-2013 1:36 PM
Hi,
My guess is it might be an Authorization issue.
Check the following link for the same.
08-22-2013 2:46 PM
Mayur
ı suspect too but open dataset works well
and ı can read no ıssues
and the same auth object is assigned to the user and returm code fine
08-22-2013 3:26 PM
Guys i have tested smth and found the reason for it...
Test: I have uploaded a file using cg3z call it test.txt to the same folder where
delete dataset didnt work
And then try the delete dataset test.txt and it worked!!!
Then checked the owner of the file: its called Sapservice etc..
Some idea came to my mind:
so talk to the Basis guys to give this user full access to this directory
And now all works fine!!
it was the SAP user that was lacking the full control
but why there was no error on the auth object on delete!!
So issue is solved guys thanks to you all
08-22-2013 3:35 PM
I would still claim that it is a fault in SAP's code. Though you don't care anymore, it could still be useful to create an OSS Message. But I leave that up to your "druthers"!
Neal
08-23-2013 7:10 AM
Yes Neal
You are right i should raise it as an issue
As the auth object fails to get the right permisson.
it says you have permission but you dont have one
Thanks mate
03-05-2015 5:48 PM
Hi All,
If you are using unix server you can delete folder from application server.
Using the unix command MKDIR and RMDIR we can create a directory / delete a directory respectively.
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 = 'mkdir dirname'. "To create a Directory.
unixcom = 'rmdir dirname'. " To remove the Directory
call 'SYSTEM' id 'COMMAND' field unixcom
id 'TAB' field tabl[].
"in the tabl you can see if there are any results.
"Loop the tabl and write the results.
Regards,
Deepanshu Malhotra