Application Development 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: 

Delete dataset does not work after upgrade in Ecc 7.01

former_member196098
Participant
0 Kudos

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

1 ACCEPTED SOLUTION

former_member196098
Participant
0 Kudos

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

16 REPLIES 16

former_member196098
Participant
0 Kudos

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!!

0 Kudos

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-subrcMeaning
0File deleted.
4File could not be deleted.

Exceptions

Catchable Exceptions

CX_SY_FILE_AUTHORITY

  • Cause: No authorization for
    accessing a file
    Runtime Error:
    OPEN_DATASET_NO_AUTHORITY (can be
    handled) 

CX_SY_FILE_OPEN

  • Cause: File cannot be opened
    Runtime Error:DATASET_CANT_OPEN (can be handled)



0 Kudos

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?

0 Kudos

I can read the filke by read dataset no issues

open dataset is fine too

but delete dataset has issue

0 Kudos

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.

Former Member
0 Kudos

I tried looking for Notes, but OSS is sick today.  Have you looked for notes yet?

Neal

0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

I think it may be time to log a product error message with OSS!

mayur_priyan
Active Participant
0 Kudos

Hi,

My guess is it might be an Authorization issue.

Check the following link for the same.

https://scn.sap.com/thread/3392452

0 Kudos

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

former_member196098
Participant
0 Kudos

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

0 Kudos

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

0 Kudos

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

0 Kudos

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