‎2008 Jul 29 3:24 PM
Hello,
In one scenario i ve to upload a text file into the Application Server.
I know to upload the file through tcode CG3Z, but i have to upload the file through the code.
How to do that?
Please reply.
Regards,
Rahul
‎2008 Jul 29 3:26 PM
‎2008 Jul 29 3:27 PM
Firs Load the FIle to Intenal table using the Function GUI_UPLOAD.
Second :
Using
open the app file for writing using
OPEN DATASET
Now Loop the internal table
and transfer each record
Now close the File using the Close dataset.
‎2008 Jul 29 3:28 PM
Hi,
Open dataset, transfer file to dataset and close dataset statements will solve your purpose.
Raghav
‎2008 Jul 29 3:28 PM
if you have the data in an internal table itab, do as follows
open dataset <filename> for output in text mode.
if sy-subrc = 0.
loop at itab.
concatenate itab-field1 itab-field2 itab-field3...into v_text.
tranfer v_text to <filename>.
endloop.
close dataset <filename>.
endif.
‎2008 Jul 29 3:29 PM
Hi Rahul,
Save the excel file as Tab delimited, and use the FM: GUI_UPLOAD.
DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
DATA: begin of it_datatab occurs 0,
row(500) type c,
end of it_datatab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = i_file
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = it_datatab "ITBL_IN_RECORD[]
EXCEPTIONS
file_open_error = 1
OTHERS = 2.
Hope this helps you.
Regards,
Chandra Sekhar
‎2008 Jul 29 3:35 PM
hi check this..
DATA: e_file like rlgrap-filename value '/usr/sap/tmp/file.txt'.
open dataset e_file for output in text mode.
lOOP AT it_datatab......
transfer it_datatab to e_file.
ENDLOOP.
close dataset e_file.
‎2008 Jul 29 3:39 PM
Hi Rahul.
I would like to suggest a few,
UPLOAD_FILES.
This function module is usefull for both Application server as well as Presentation server.
Hope that's usefull.
Good Luck & Regards.
Harsh Dave
‎2008 Jul 29 3:50 PM