Skip to Content
author's profile photo Former Member
Former Member

Deleting Application Server XML file

Hi,

I have been trying to delete an application server XML file using the DELETE DATASET statement in my program.

The sy-subrc is set to 4 after the statement and the file is not deleted.

-> Does the delete statement not work if I dont have sufficient authorization?

( I tried uploading a file to the particular folder in the application server, and it showed up a messgae 'Permission Denied' So I guess I dont have write access to that folder )

-> Or, should XML files in specific be deleted differently?

Any insights on why this is happening and how to correct it?

Thanks in advance,

Nisha

Edited by: Nisha Hariharan on Dec 8, 2011 9:35 AM

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Dec 08, 2011 at 08:39 AM

    Welcome to SCN,

    Your question itself has the solution.

    call function as below before your delete

    CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
         EXPORTING  PROGRAM          = SY-REPID
                    ACTIVITY         = 'DELETE' "Delete file auth object
                    FILENAME         = pfile
         EXCEPTIONS NO_AUTHORITY     = 1
                    ACTIVITY_UNKNOWN = 2.
    if sy-subrc ne 0.
    write 'No authorization to delete'.
    else.
    delete dataset pfile.
    endif.
    

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2011 at 09:08 AM

    Thanks a lot.

    Am I right in understanding that this checks if I have delete access to the particular file?

    I am facing a new issue here that the entire file name with path is more than 60 characters which is the size of the paramter to be passed here into the FM.

    So I used this statement in my program where lv_infile is more than 60 chars.

    AUTHORITY-CHECK OBJECT 'S_DATASET'

    ID 'PROGRAM' FIELD sy-repid

    ID 'ACTVT' FIELD '06'

    ID 'FILENAME' FIELD lv_infile.

    And this returns SY-SUBRC EQ 0.

    So it means I have authorization to delete it. Right?

    Then, why doesnt it get deleted?

    Any ideas?

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2011 at 09:16 AM

    Yes, I was just about to post a reply. I added that too. That also returns sy-subrc 0.

    But immediately after that the delete statement still returns sy-subrc 4.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2011 at 09:24 AM

    Yes, I checked them all.

    Thanks for your help Keshav.

    Nisha

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Dec 08, 2011 at 09:38 AM

    Tried.

    It doesnt even enter the CATCH block.

    Thanks anyway.

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.