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 DOWNLOAD Problem

Former Member
0 Likes
4,818

Hi Guys,

I am facing a problem with the FM : GUI DOWNLOAD

It gives me an error: File is Not Available

Please find my code below for the same and let me know as to how do i go about it.

DATA ls_fnam TYPE string.

ls_fnam = text-016.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

filename = ls_fnam

filetype = 'ASC'

write_field_separator = 'X'

TABLES

data_tab = gt_data

fieldnames = gt_header.

Thanks and regards,

Frank

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,546

Hi,

I have assigned text-016 = C:\ABC.XLS. Now its giving me error stating that " Access to file denied".

Thanks

15 REPLIES 15
Read only

piyush_mathur
Active Participant
0 Likes
2,546

Hi Dear,

Debugg the program and chk what vale u r getting in text-016.

Regards,

Piyush

Read only

Former Member
0 Likes
2,546

hi,

make sure your file exists in presentation server..not in application server.

Read only

Former Member
0 Likes
2,546

have u mentioned a proper path for ur filename?

what is the value of text-016

Edited by: Anil Kalive on Dec 26, 2008 2:33 PM

Read only

Former Member
0 Likes
2,546

Hi,

Check whether the file name is given in ' <filename> ' . I mean single quotes ' '

Edited by: Premalatha G on Dec 26, 2008 10:07 AM

Read only

Former Member
0 Likes
2,546

ftype = 'ASC'.

CALL FUNCTION 'GUI_DOWNLOAD'

EXPORTING

FILENAME = pathname

FILETYPE = ftype

WRITE_FIELD_SEPARATOR = 'X'

TRUNC_TRAILING_BLANKS = 'X'

TABLES

DATA_TAB = disp_tab2

EXCEPTIONS

FILE_WRITE_ERROR = 1.

Read only

Former Member
0 Likes
2,546

Text-016 contains "C:\" as the file path......where i want my excel sheet to be created/downloaded.

Thanks and regards,

Frank

Read only

0 Likes
2,546

assign

text-016 = c:\ file1.

Read only

0 Likes
2,546

Dear Frank,

You have to pass the file name also with C:\.

For ex: C:\ABC.xls

Thanks

Piyush

Read only

0 Likes
2,546

Check weather u have not opened ABC.xls

also check if ur windows login id has rights to create a file on C:\ drive of system

Read only

Former Member
0 Likes
2,547

Hi,

I have assigned text-016 = C:\ABC.XLS. Now its giving me error stating that " Access to file denied".

Thanks

Read only

0 Likes
2,546

Hi Frank,

Check whether you are having access to create file in C:\ Directory. If not, then pass the other directory path, in which you have access.

Regards,

Piyush

Read only

0 Likes
2,546

Dear Frank,

I might not be having access to create file in C drive. Try with some other location like desktop or my documents. It should work. Remember to give the file extention also.

eg: D:\mydownloads\test.xls.

Most of the times u can't directly create files in drive. U can create a folder and try to download to that folder.

Thanks,

Vinod.

Read only

Former Member
0 Likes
2,546

Hi,

use this FM also, then u can select the path wherever u want.


data: text type rlgrap-filename,
        lv_text type string.

      CALL FUNCTION 'kd_get_filename_on_f4'
       EXPORTING
         program_name        = syst-repid
         dynpro_number       = syst-dynnr
*   FIELD_NAME          = ' '
*   STATIC              = ' '
         mask                = ', txt,*.txt,'
        CHANGING
          file_name           = text
        EXCEPTIONS
          mask_too_long       = 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.

      lv_text = text.

      CALL FUNCTION 'gui_download'
  EXPORTING
*   BIN_FILESIZE                    =
    filename                        = lv_text
   filetype                        = 'asc'
*   APPEND                          = ' '
*   WRITE_FIELD_SEPARATOR           = '~'
*   HEADER                          = '00'
*   TRUNC_TRAILING_BLANKS           = ' '
*   WRITE_LF                        = 'X'
*   COL_SELECT                      = ' '
*   COL_SELECT_MASK                 = ' '
*   DAT_MODE                        = ' '
*   CONFIRM_OVERWRITE               = ' '
*   NO_AUTH_CHECK                   = ' '
*   CODEPAGE                        = ' '
*   IGNORE_CERR                     = ABAP_TRUE
*   REPLACEMENT                     = '#'
*   WRITE_BOM                       = ' '
*   TRUNC_TRAILING_BLANKS_EOL       = 'X'
*   WK1_N_FORMAT                    = ' '
*   WK1_N_SIZE                      = ' '
*   WK1_T_FORMAT                    = ' '
*   WK1_T_SIZE                      = ' '
* IMPORTING
*   FILELENGTH                      =
  TABLES
    data_tab                        = it_copy
*   FIELDNAMES                      =
 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.

Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 10:56 AM

Read only

Former Member
0 Likes
2,546

HI..

Use following code to find the file from presentation server.avoid to hard code of file path.


**File Name
data: flname type string.
at selection-screen on value-request for filename.
  call function 'F4_FILENAME'
    importing
      file_name = filename.

start-of-selection.
  flname = filename.

**Upload Input file from presentation server to SAP
    call function 'GUI_UPLOAD'
    exporting
      filename                      = flname
      filetype                      = 'ASC'
   has_field_separator            = 'X'
*   HEADER_LENGTH                 = 0
*   READ_BY_LINE                  = 'X'
*   DAT_MODE                      = ' '
*   CODEPAGE                      = ' '
*   IGNORE_CERR                   = ABAP_TRUE
*   REPLACEMENT                   = '#'
*   CHECK_BOM                     = ' '
*   VIRUS_SCAN_PROFILE            =
*   NO_AUTH_CHECK                 = ' '
* IMPORTING
*   FILELENGTH                    =
*   HEADER                        =
    tables
      data_tab                      = it_record

   exceptions
     file_open_error               = 1
     file_read_error               = 2
     no_batch                      = 3
     gui_refuse_filetransfer       = 4
     invalid_type                  = 5
     no_authority                  = 6
     unknown_error                 = 7
     bad_data_format               = 8
     header_not_allowed            = 9
     separator_not_allowed         = 10
     header_too_long               = 11
     unknown_dp_error              = 12
     access_denied                 = 13
     dp_out_of_memory              = 14
     disk_full                     = 15
     dp_timeout                    = 16
     others                        = 17
            .
  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.

jay

Code Formatted by: Alvaro Tejada Galindo on Dec 26, 2008 10:56 AM

Read only

Former Member
0 Likes
2,546

Thanks guys,

The problem was solved.