Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Upload CSV file from PC to Application server

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

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

Manohar2u
Active Contributor
0 Kudos

You can try the tcode CG3Z to upload your file into application server from your PC

Regards,

Manohar

Former Member
0 Kudos

<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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

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..

andreas_mann3
Active Contributor
0 Kudos

Hi Vikrant,

have a look here:

Andreas