Google Search - Blog...........

ABAP - Uploading Data To The FTP Server Using FM GUI_UPLOAD And FILE_GET_NAME.

REPORT z_logical1.

DATA: BEGIN OF itab OCCURS 0,
text(25) TYPE c,
END OF itab.

PARAMETER: fname TYPE rlgrap-filename,
p_lpath TYPE filename-fileintern,
name(30).

CONSTANTS: co_var(9) VALUE 'FNAME',
co_ftype(10) VALUE 'ASC',
co_fsep VALUE 'X'.

DATA : fname1 TYPE string,
file TYPE rlgrap-filename,
wg_file TYPE filename-fileextern.

AT SELECTION-SCREEN ON VALUE-REQUEST FOR fname.

*function call to get f4 search for files

CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
EXPORTING
program_name = syst-repid
dynpro_number = syst-dynnr
field_name = co_var
CHANGING
file_name = fname
EXCEPTIONS
mask_too_long = 1
OTHERS = 2.

fname1 = fname.


*TO MIGRATE THE FILE FROM PRES. SERV. TO INTERNAL TABLE

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = fname1
filetype = 'ASC'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4.

START-OF-SELECTION.

*TO GET THE PHYSICAL PATH BY GIVING THE LOGICAL PATH

CALL FUNCTION 'FILE_GET_NAME'
EXPORTING
logical_filename = p_lpath
IMPORTING
file_name = file
EXCEPTIONS
file_not_found = 1
OTHERS = 2.
CONCATENATE file name INTO wg_file.
OPEN DATASET wg_file
FOR OUTPUT IN TEXT MODE
ENCODING DEFAULT.

LOOP AT itab.
TRANSFER itab TO wg_file. "DATASET.
ENDLOOP.
CLOSE DATASET wg_file.


ALSO READ:

- Download A File With The Specified Delimit Character Dynamically.

- Download ABAP Source Code & TEXTPOOL To The Desktop.

- Downloading Programs Into A Folder In Presentation Server.

- Download SAP Data In XML Format.

- Download SAPScript Output To PDF File.



RETURN TO MAIN INDEX:

- Sample Programs On Uploading & Downloading Files.

- Sample Programs On HR ABAP.

- Sample Report Programs On ALV List/ Grid Display.

- Sample Programs On Selection Screen.

- Sample Programs On BDC.

.....Back To MAIN INDEX.



No comments:

Post a Comment