Application Development and Automation 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: 
Read only

GUI_DELETE_FILE

former_member182371
Active Contributor
0 Likes
1,288

Hi,

after procesing a file i want to delete it.

i use the following code:

call function 'GUI_DELETE_FILE'

exporting

file_name = d_file

EXCEPTIONS

FAILED = 1

OTHERS = 2.

*if sy-subrc <> 0.

    • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

    • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

*endif.

although the file is correctly deleted i always get sy-subrc = 1. Why is this happening?
(i´ve commented if sy-subrc <> 0 because i got this message: MESSAGE_TYPE_UNKNOWN).

Best regards.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
962

Not sure why you are getting that, but maybe try the following code instead.



call method cl_gui_frontend_services=>file_delete
  exporting
    filename           = filepatch
  changing
    rc                 = sysubrc
*  EXCEPTIONS
*    FILE_DELETE_FAILED = 1
*    CNTL_ERROR         = 2
*    ERROR_NO_GUI       = 3
*    FILE_NOT_FOUND     = 4
*    ACCESS_DENIED      = 5
*    UNKNOWN_ERROR      = 6
*    others             = 7
        .
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,

Rich Heilman

4 REPLIES 4
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
963

Not sure why you are getting that, but maybe try the following code instead.



call method cl_gui_frontend_services=>file_delete
  exporting
    filename           = filepatch
  changing
    rc                 = sysubrc
*  EXCEPTIONS
*    FILE_DELETE_FAILED = 1
*    CNTL_ERROR         = 2
*    ERROR_NO_GUI       = 3
*    FILE_NOT_FOUND     = 4
*    ACCESS_DENIED      = 5
*    UNKNOWN_ERROR      = 6
*    others             = 7
        .
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,

Rich Heilman

Read only

Former Member
0 Likes
962

Hello,

wouldn't trust in that function.

German documentation says:

OBSOLET: bitte Klasse CL_GUI_FRONTEND_SERVICES verwenden

means : not anymore supported, use Class .

The reason could be:

CASE ORBTYP.

WHEN ORB_COM_DEF.

CALL METHOD OF H_COM1 'DeleteFile' = RET

EXPORTING #1 = FILE_NAME.

IF ( RET = 0 ) .

RAISE FAILED.

ENDIF.

IF SY-SUBRC NE 0.

RAISE FAILED.

ENDIF.

ENDCASE.

Best regards

Read only

former_member182371
Active Contributor
0 Likes
962

Hi,

are GUI_DOWNLOAD and GUI_UPLOAD obsolte as well?

Best regards.

Read only

Former Member
0 Likes
962

Instead of using this stupid FM (I saw that it doesn't care and gives no indication even if you send an empty FILE_NAME to it...) use the function "WS_FILE_DELETE".

Also watch this topic on more stuff regading:

"Obsolete Functions in SAP 4.7"

Link:

enjoy

ayal.