2006 Jun 20 2:52 PM
Hi,
How do we read a CSV file using OOPS concept? And at the same time how can we upload it is there any special functions to do that?please reply, urgent.
Thanks,
Sindhu.
2006 Jun 20 3:00 PM
hi,
use class CL_GUI_FRONTEND_SERVICES
methods: GUI_DOWNLOAD and GUI_UPLOAD
A.
2006 Jun 20 3:04 PM
Call the method
CL_GUI_FRONTEND_SERVICES->GUI_UPLOAD
This will upload the file into an internal table
You would then need to split at comma to get it into your required internal table format.
2006 Jun 20 3:06 PM
Short sample here.
report zrich_0001.
types: begin of ttab,
fld1(20) type c,
fld2(20) type c,
fld3(20) type c,
end of ttab.
data: itab type table of ttab.
data: wa type ttab.
data: iup type table of string.
data: xup type string.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = 'C:test.csv'
changing
data_tab = iup.
loop at iup into xup.
split xup at ',' into wa-fld1
wa-fld2
wa-fld3.
append wa to itab.
endloop.
loop at itab into wa.
write:/ wa-fld1, wa-fld2, wa-fld3.
endloop.
Regards,
Rich Heilman
2006 Jun 20 3:07 PM
Hi Sindhu,
GUI_DOWNLOAD and GUI_UPLOAD are most easy ones to use.........
2006 Jun 20 3:55 PM
Here is a slightly more dynamic approach.
report zrich_0001.
types: begin of ttab,
fld1(20) type c,
fld2(20) type c,
fld3(20) type c,
end of ttab.
data: itab type table of ttab.
data: wa type ttab.
data: iup type table of string.
data: xup type string.
data: isplit type table of string with header line.
field-symbols: <fs>.
call method cl_gui_frontend_services=>gui_upload
exporting
filename = 'C:test.csv'
changing
data_tab = iup.
<b>loop at iup into xup.
clear wa.
clear isplit. refresh isplit.
split xup at ',' into table isplit.
loop at isplit.
assign component sy-tabix of structure wa to <fs>.
if sy-subrc <> 0.
exit.
endif.
<fs> = isplit.
endloop.
append wa to itab.
endloop.</b>
loop at itab into wa.
write:/ wa-fld1, wa-fld2, wa-fld3.
endloop.
Regards,
Rich Heilman