‎2006 Mar 23 4:29 PM
hi folks,
I am uploading a .csv file into the internal table. The FM is working and the issue is the flat file has 33 fields of which many are blank (they have no data from the input file)and only 7 fields get populated.
Hence I have declared the internal table with those fields only.
The file format is in such a way that the there are two fields with data, then third fourth and fifth are blank again the sixth field is filled with data and the next few fields are blank.It is following that way.
obviously, the data is not sitting in the appropriate fields in the internal table.
How can I rectify that?
I am using the UPLOAD FM module. This is the code...
data: begin of rec occurs 1,
pernr(8) type c, "Employee Number
zzpaycode(4) type c, " Pay code
stdaz(5) type p decimals 2, " No of hours
bwgrl(9) type p decimals 4, " Currency
zzshift(1) type n, " zzshift
begda(8) type c, "Pay period end date
exbel(8) type c, " Dst Account
flag(1) type c,
end of rec.
call function 'UPLOAD'
exporting
filename = 'C:\Testdata\PRTRCSV53.csv'
filetype = 'ASC'
importing
cancel = answer
act_filename = filename
tables
data_tab = rec
exceptions
conversion_error = 1
invalid_table_width = 2
invalid_type = 3
no_batch = 4
unknown_error = 5
others = 6.
Thanks in advance.
Vinu
‎2006 Mar 23 4:33 PM
First, do not use obsolete function modules like UPLOAD. Use GUI_UPLOAD instead.
Next, you cannot have your internal table defined in one way and the file coming in another way(in terms of the number of columns). Your spreadsheet columns should match your internal table columns.
‎2006 Mar 23 4:33 PM
First, do not use obsolete function modules like UPLOAD. Use GUI_UPLOAD instead.
Next, you cannot have your internal table defined in one way and the file coming in another way(in terms of the number of columns). Your spreadsheet columns should match your internal table columns.
‎2006 Mar 23 4:43 PM
Why do advise him to use an obsolete FM module instead of an obsolete FM? Both FM are absolete!
‎2006 Mar 23 4:45 PM
As of which version, GUI_UPLOAD is obsolete Rainer Hubenthal?
‎2006 Mar 23 4:52 PM
I think Rainer got it mixed up with WS_UPLOAD.. I dont think GUI_UPLOAD is OBSOLETE as yet.. at least not on 47..
Vinu,
after changing the function call to GUI_UPLOAD, you should upload the file in to another itab..loop at that & transfer the relevant fields to your REC table..
Regards,
Suresh Datti
‎2006 Mar 23 4:34 PM
‎2006 Mar 23 4:49 PM
I tried this it did not work....
call function 'GUI_UPLOAD'
exporting
filename = 'C:\Testdata\PRTRCSV53.csv'
filetype = 'ASC'
importing
cancel = answer
act_filename = filename
tables
data_tab = rec
exceptions
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
others = 17 .
Thanks
Vinu
‎2006 Mar 23 4:51 PM
No Vinu, GUI_UPLOAD will not solve your problem, look at my second point of the initial response.
I suggested using GUI_UPLOAD only because the other one is obsolete.
‎2006 Mar 23 4:54 PM
The version ECC5.0 and it is an exisiting program where the FM GUI_UPLOAD part of the code was commented and the FM 'UPLOAD' was used. I reversed that and it did nto work.
Thanks
Vinu.
‎2006 Mar 23 4:54 PM
Hi Vinu,
Your internal table should have the same amount of fields as your file as Srinivas said.
‎2006 Mar 23 4:56 PM
I work on ECC5.0 too...But checking the UPLOAD FM Code...They're using WS_UPLOAD, so UPLOAD should be obsolet too...
Greetings,
Blag.
‎2006 Mar 23 5:01 PM
I think you are gettin mixed up. Forget about what all of us are saying about UPLOAD function module.
To your problem, there are very few options. One is to define your internal table to have exact number of fields as you have values(blank or otherwise) in your csv file.
Another option as Suresh mentioned, is to define an internal table with just one field of length(maximum length needed) x. Upload the file into this internal table. You will then loop at this internal table and load your other table as follows.
loop at itab.
split itab-record at ',' into final_itab-field1
some_junk_field
final_itab-field2
some_junk_field
some_junk_field
final_itab-field3.
append final_itab.
clear final_itab.
endloop.Here some_junk_field is some variable whose value you don't care about.
‎2006 Mar 23 4:57 PM
Hello
it's quite the same if you use UPLOAD or GUI_UPLOAD, the problem is that these FM's will not splitt the .csv lines into your table fields. You 'll have to do that in your program.
DATA: begin of rec occurs 1 ,
contents(100), " just long enough
end of rec,
begin of rec_a occurs 1,
.... (your fields)
end of rec_a.
Call function 'UPLOAD'
....
data_tab = rec
...
loop at rec.
clear rec_a.
splitt rec at ';' into rec_a-(your first field)
...
append rec_a.
endloop.
Regards Wolfgang
‎2006 Mar 23 5:04 PM
How about if I use 'READ DATASET... to read the .csv input file and using the 'split' command TO split the values into the appropriate fields in the internal table instead using the GUI_UPLOAD FM.
Thanks
Vinu
‎2006 Mar 23 5:05 PM
READ DATASET will work fine with your application server files, but I have never used it with desktop files.
‎2006 Mar 23 5:08 PM
‎2006 Mar 23 5:12 PM
It would make no difference, it won't splitt your input into your table fields. Use the splitt-command.