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

down laod file problem

Former Member
0 Likes
626

Hi Friends,

I am using the below code downloading file

but I am getting the short dump like 'Acess denied'.

TYPES: BEGIN OF xml_line_dl,

data(10000) TYPE c,

END OF xml_line_dl.

data: gv_filename_dld TYPE string value 'c:\abc.xml '.

data: xml_table_dld TYPE TABLE OF xml_line_dl.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = gv_filename_dld

filetype = 'ASC'

TABLES

data_tab = xml_table_dld.

Please suggest me I need to avoid the short dump If I dont have the acess to 'C:\' drive

Insted of short dump I need to populate the error message If I dont have the acess to C derive

ThanX

Sam

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
600

Try handling the exceptions.

MOVE p_file TO xfile.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = xfile

filetype = 'ASC'

IMPORTING

filelength = bytes_written

TABLES

data_tab = t_out

fieldnames = t_output

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

5 REPLIES 5
Read only

Former Member
0 Likes
600

Hi,

You can use the Exception's of the Function module for this..

Read only

Former Member
0 Likes
601

Try handling the exceptions.

MOVE p_file TO xfile.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = xfile

filetype = 'ASC'

IMPORTING

filelength = bytes_written

TABLES

data_tab = t_out

fieldnames = t_output

EXCEPTIONS

file_write_error = 1

no_batch = 2

gui_refuse_filetransfer = 3

invalid_type = 4

no_authority = 5

unknown_error = 6

header_not_allowed = 7

separator_not_allowed = 8

filesize_not_allowed = 9

header_too_long = 10

dp_error_create = 11

dp_error_send = 12

dp_error_write = 13

unknown_dp_error = 14

access_denied = 15

dp_out_of_memory = 16

disk_full = 17

dp_timeout = 18

file_not_found = 19

dataprovider_exception = 20

control_flush_error = 21

OTHERS = 22.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Read only

Former Member
0 Likes
600

After the function call check SY-SUBRC

if SY-SUBRC = 15.

<custom messgae>

endif.

Read only

Former Member
0 Likes
600

Hi,

Do like this...

Call function GUI_DOWNLOAD using pattern button and uncomment the Exceptions parameters.

Then use the Exception ACCESS_DENIED, you will get sy-subrc = 15, and you can populate your error/information message here only.

For eg:

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

  • BIN_FILESIZE =

filename = filename

  • FILETYPE = 'ASC'

  • APPEND = ' '

WRITE_FIELD_SEPARATOR = 'X'

  • HEADER = '00'

TRUNC_TRAILING_BLANKS = 'X '

  • WRITE_LF = 'X'

  • COL_SELECT = ' '

  • COL_SELECT_MASK = ' '

  • IMPORTING

  • FILELENGTH =

tables

data_tab = ITAB

EXCEPTIONS

FILE_WRITE_ERROR = 1

NO_BATCH = 2

GUI_REFUSE_FILETRANSFER = 3

INVALID_TYPE = 4

NO_AUTHORITY = 5

UNKNOWN_ERROR = 6

HEADER_NOT_ALLOWED = 7

SEPARATOR_NOT_ALLOWED = 8

FILESIZE_NOT_ALLOWED = 9

HEADER_TOO_LONG = 10

DP_ERROR_CREATE = 11

DP_ERROR_SEND = 12

DP_ERROR_WRITE = 13

UNKNOWN_DP_ERROR = 14

ACCESS_DENIED = 15

DP_OUT_OF_MEMORY = 16

DISK_FULL = 17

DP_TIMEOUT = 18

FILE_NOT_FOUND = 19

DATAPROVIDER_EXCEPTION = 20

CONTROL_FLUSH_ERROR = 21

OTHERS = 22

Case sy-subrc.

When 15.

*Write your message here.

endcase.

Read only

former_member156446
Active Contributor
0 Likes
600

using exceptions is the best practice.