‎2007 Apr 05 2:13 PM
Hi all,
i want to delete a directory (a folder ) in a drive..i have written code but seems not working..
DATA : V_VALUE1 TYPE STRING.
DATA : V_RETURN_CODE1 TYPE I.
CONCATENATE 'C:\PO PDFs\' P_OBJ_ID '.pdf' INTO V_VALUE1.
CLEAR : P_OBJ_ID.
...................DELETE THE DIRECTORY PO PDFs......................
CREATE OBJECT V_GUIOBJ.
CALL METHOD V_GUIOBJ->directory_delete
EXPORTING
directory = V_VALUE1
changing
rc = V_RETURN_CODE1
EXCEPTIONS
DIRECTORY_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
PATH_NOT_FOUND = 4
DIRECTORY_ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
others = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Please hlp
‎2007 Apr 05 2:17 PM
Hi
Where have you defined the object V_GUIOBJ?
The path is 'C:\PO PDFs\' P_OBJ_ID '.pdf' so it seems you're deleting a PDF file not a path.
Do you want to delete a file or a directory?
For the file you can use the method FILE_DELETE.
Max
‎2007 Apr 05 2:17 PM
Hi
Where have you defined the object V_GUIOBJ?
The path is 'C:\PO PDFs\' P_OBJ_ID '.pdf' so it seems you're deleting a PDF file not a path.
Do you want to delete a file or a directory?
For the file you can use the method FILE_DELETE.
Max
‎2007 Apr 05 2:18 PM
Hi Srikanth,
There seems to be one more Single quote in filename , remove that and checkout if it works
change this
CONCATENATE 'C:\PO PDFs\' P_OBJ_ID <b>'.</b>pdf' INTO V_VALUE1.
to
CONCATENATE 'C:PO PDFsP_OBJ_ID.pdf' INTO V_VALUE1.Message was edited by:
Chandrasekhar Jagarlamudi
‎2007 Apr 05 2:19 PM
Hi,
Instead of this, you try following method, give appropirate parameter and it will do.
CALL METHOD cl_gui_frontend_services=>directory_delete
EXPORTING
directory =
changing
rc =
*EXCEPTIONS
*DIRECTORY_DELETE_FAILED = 1
*CNTL_ERROR = 2
*ERROR_NO_GUI = 3
*PATH_NOT_FOUND = 4
*DIRECTORY_ACCESS_DENIED = 5
*UNKNOWN_ERROR = 6
*NOT_SUPPORTED_BY_GUI = 7
*WRONG_PARAMETER = 8
*others = 9
.
IF sy-subrc <> 0.
*MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
*WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Hope it will help you.
‎2007 Apr 05 2:37 PM
The proble is that you are trying to create an object wthout declaring a referance to the class:
You can directly call the class method like this:
CALL METHOD cl_gui_frontend_services=>directory_delete
EXPORTING
directory = 'C:/PO PDFs'
changing
rc = v_subrc
EXCEPTIONS
DIRECTORY_DELETE_FAILED = 1
CNTL_ERROR = 2
ERROR_NO_GUI = 3
PATH_NOT_FOUND = 4
DIRECTORY_ACCESS_DENIED = 5
UNKNOWN_ERROR = 6
NOT_SUPPORTED_BY_GUI = 7
WRONG_PARAMETER = 8
others = 9
.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Ravi
‎2007 Apr 05 4:06 PM
when i use this FM..i went in debug mode ...it is giving as <b>access_denied</b> exception...
From SAP i can't access to local PC?
Do SAP provides a default folder that i can save a file and delete that file ??
Pls Help