ABAP Uoload or Download file from local files

  File

OverView

GUI_UPLOAD and GUI_DOWNLOAD function modules are used when uploading files locally and downloading files locally.
Here, the basic usage of these function modules is described.

Sample Code:GUI_UPLOAD

TYPES: BEGIN OF T_FILE,
         VAL1(10) TYPE C,
         VAL2(10) TYPE C,
         VAL3(10) TYPE C,
       END OF T_FILE.
DATA: IT_FILE TYPE TABLE OF T_FILE. 
DATA: W_FILE TYPE STRING.

W_FILE = 'C:tempupload.txt'.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    FILENAME                = W_FILE     
    FILETYPE                = 'ASC'      
    HAS_FIELD_SEPARATOR     = 'X'        
  TABLES
    DATA_TAB                = IT_FILE.

Sample Code:GUI_DOWNLOAD

TYPES: BEGIN OF T_FILE,
         VAL1(10) TYPE C,
         VAL2(10) TYPE C,
         VAL3(10) TYPE C,
       END OF T_FILE.
       
DATA: IT_FILE TYPE TABLE OF T_FILE, 
      WA_FILE TYPE T_FILE.
DATA: W_FILE TYPE STRING.

WA_FILE-VAL1 = '1'.
WA_FILE-VAL2 = '2'.
WA_FILE-VAL3 = '3'.
APPEND WA_FILE TO IT_FILE.

W_FILE = 'C:tempdownload.txt'.

CALL FUNCTION 'GUI_DOWNLOAD'
  EXPORTING
    FILENAME              = W_FILE  
    FILETYPE              = 'ASC'   
    WRITE_FIELD_SEPARATOR = 'X'     
  TABLES
    DATA_TAB              = IT_FILE.

Explanation

In both cases, you can easily read and write the file by passing the input and output file name and some parameters.
This sample is tab delimited, but if you want to delimit with commas, create an internal table that has only long character string columns (for example, 1000 digits).
You can use this general-purpose module in the same way by combining the characters you want to output by separating them with commas.