# GUI_DOWNLOAD — Download Internal Table to PC

> Writes the content of an internal table to the user's PC as a text or binary file through SAP GUI. Programs that export report results as tab-delimited or CSV files use it. Use the FIELDNAMES table for column headings and pass WRITE_FIELD_SEPARATOR = 'X' with a suitable CODEPAGE so the file opens correctly in Excel; it does not run in the background.

- Modules: BASIS
- Type: Function module
- Function group: SFES
- Remote-enabled (RFC): No
- S/4HANA status: Used the same way in S/4HANA
- URL: https://nekuhub.com/en/functions/gui-download/

## Importing parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| FILENAME | STRING | File name (full path) | Yes |
| FILETYPE | CHAR10 | File type (ASC, BIN, DAT) | - |
| WRITE_FIELD_SEPARATOR | CHAR01 | Separate fields with tab | - |
| CODEPAGE | ABAP_ENCODING | Code page | - |
| APPEND | CHAR01 | Append to existing file | - |

## Exporting parameters

| Parameter | Type | Description |
|---|---|---|
| FILELENGTH | I | Written file length |

## Tables parameters

| Parameter | Type | Description | Required |
|---|---|---|---|
| DATA_TAB | - | Data table | Yes |
| FIELDNAMES | - | Column headings | - |

## Exceptions

- ACCESS_DENIED: Access denied
- CONTROL_FLUSH_ERROR: Control flush error
- DATAPROVIDER_EXCEPTION: Data provider exception
- DISK_FULL: Disk full
- DP_ERROR_CREATE: Data provider create error
- DP_ERROR_SEND: Data provider send error
- DP_ERROR_WRITE: Data provider write error
- DP_OUT_OF_MEMORY: Data provider out of memory
- DP_TIMEOUT: Data provider timeout
- FILESIZE_NOT_ALLOWED: File size not allowed
- FILE_NOT_FOUND: File not found
- FILE_WRITE_ERROR: File write error
- GUI_REFUSE_FILETRANSFER: SAP GUI refused file transfer
- HEADER_NOT_ALLOWED: Header not allowed
- HEADER_TOO_LONG: Header too long
- INVALID_TYPE: Invalid file type
- NO_AUTHORITY: No authorization
- NO_BATCH: Cannot run in background
- SEPARATOR_NOT_ALLOWED: Separator not allowed
- UNKNOWN_DP_ERROR: Unknown data provider error
- UNKNOWN_ERROR: Unknown error

## Call template (ABAP)

```abap
CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    filename = lv_filename
  IMPORTING
    filelength = lv_filelength
  TABLES
    data_tab = lt_data_tab
    fieldnames = lt_fieldnames
  EXCEPTIONS
    access_denied = 1
    control_flush_error = 2
    dataprovider_exception = 3
    disk_full = 4
    dp_error_create = 5
    dp_error_send = 6
    dp_error_write = 7
    dp_out_of_memory = 8
    OTHERS = 9.
```


