07-03-2006 7:37 AM
Hi,
I'm not a abaper so need help from ABAP gurus.
We have a simple requirement, and need two abap programs for these requirements:
1. First program should upload a .CSV file from PC to Application server. No data transformation/modification is required. The .CSV file should be uploaded as it is. Also Users should be able to provide PC and Application server path at run time.
2. Once file has been uploaded, we want it to be renamed by appending current date.
Any idea, how can I achieve it. I know there exist GUI_UPLOAD function module but not sure how to use it.
Regards,
Vikrant.
07-03-2006 7:42 AM
Vikrant,
If its a one time activity you can use the transactions CG3Y and CG3Z transactions.
If NOT, then you will have to do this.
1. Call the method GUI_UPLOAD METHOD of the class, CL_GUI_FRONTEND_SERVICES. This will prompt the user to enter the file path and name.
2. Once the data is uploaded to a internal table, use the OPEN DATASET, TRANSFER, CLOSE DATASET commands to save the data to a file on the app server.
Regards,
Ravi
Note :Please mark the helpful answers
07-03-2006 7:42 AM
You can try the tcode CG3Z to upload your file into application server from your PC
Regards,
Manohar
07-03-2006 7:44 AM
<b>CG3Z</b> to upload your file into application server from your PC
or appliction to pc.
report zkish_0001
no standard page heading.
parameters: d1 type localfile default '/usr/sap/TST/SYS/Data1.csv'.
data: begin of itab occurs 0,
fld1(20) type c,
fld2(20) type c,
fld3(20) type c,
end of itab.
data: wa(2000) type c.
start-of-selection.
open dataset d1 for input in text mode.
if sy-subrc = 0.
do.
read dataset d1 into wa.
if sy-subrc <> 0.
exit.
endif.
split wa at ',' into itab-fld1 itab-fld2 itab-fld3.
append itab.
enddo.
endif.
close dataset d1.
03-08-2013 11:40 AM
Hello kishan,
You forgot to include the encoding addition in the OPEN DATASET command.
Setting encoding to DEFAULT or UTF-8 works fine.
Anyways, niche way to read .csv files from the presentation server.
07-03-2006 7:53 AM
Hi USE FM GUI_DOWNLOAD to transfer your .CSV file to an internal table itab.
after that use the code to create a file on the application server and transfer the internal table data to the application server file.
OPEN DATASET p_ofile_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
OPEN DATASET p_ofile_file1 FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
IF sy-subrc = 0.
CLEAR: wa_local.
LOOP AT p_local_table INTO wa_local.
TRANSFER wa_local TO p_ofile_file.
CLEAR: wa_local.
ENDLOOP.
append p_ofile_file sy-datum to p_ofile_file1
CLOSE DATASET p_ofile_file.
CLOSE DATASET p_ofile_file1..
07-03-2006 8:03 AM