Application Development and Automation 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: 
Read only

Upload , dilimited file

Former Member
0 Likes
677

Hi,

I am tring to upload , dilimited file into internal table using GUIUPLOAD function module. its not reading only first field only. Please help me out.

Thanks.

file has

name,value

GUI Function

call function 'GUI_UPLOAD'

exporting

filename = l_name

has_field_separator = ','

tables

data_tab = it_itab

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.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
637

Hi

HAS_FIELD_SEPE... is meant to indicate if there is a seperator or not, and should not pass the seperator itself. If you are uploading a .CSV file...then use FM ALSMEXCELTOINTERNALTABLE

You will get the data into an ITAB in the form of Row, Column & Value. Just right around a logic to convert it into your required format.

Thanks

Sharath.

Hi,

I am tring to upload , dilimited file into internal table using GUIUPLOAD function module. its not reading only first field only. Please help me out.

Thanks.

file has

name,value

GUI Function

call function 'GUI_UPLOAD'

exporting

filename = l_name

has_field_separator = ','

tables

data_tab = it_itab

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.

4 REPLIES 4
Read only

Former Member
0 Likes
637

Hi,

In your file are you seperating the fields by ','.

If yes, then therez nothing wrong in your code.

if, fields are seperated by TAB..then give field seperator as 'X'.

Regards

Sandeep REddy.

Read only

Former Member
0 Likes
637

Check this FM documentation:

FU GUI_UPLOAD HAS_FIELD_SEPARATOR

____________________________________________________

Short Text

Columns Separated by Tabs in Case of ASCII Upload

Description

Specifies if the fields in the file are separated by a tab. This is necessary if the structure passed contains several components. CR/LF occurs instead of a tab after the last field of a row.

Value range

'X': Fields are separated by tabs.

SPACE: Fields are not separated by tabs. In this case, the table must

contain either only one single column or all columns must be contained

in the file in their full length.

Default

SPACE

Function Module

GUI_UPLOAD

This is the rich's reply in one of the posts:

Here is an example program.

code

report zrich_0001.

types: begin of ttab,

rec(1000) type c,

end of ttab.

types: begin of tdat,

fld1(10) type c,

fld2(10) type c,

fld3(10) type c,

end of tdat.

data: itab type table of ttab with header line.

data: idat type table of tdat with header line.

data: file_str type string.

parameters: p_file type localfile.

at selection-screen on value-request for p_file.

call function 'KD_GET_FILENAME_ON_F4'

exporting

static = 'X'

changing

file_name = p_file.

start-of-selection.

file_str = p_file.

call function 'GUI_UPLOAD'

exporting

filename = file_str

tables

data_tab = itab

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.

loop at itab.

clear idat.

split itab-rec at ',' into idat-fld1

idat-fld2

idat-fld3.

append idat.

endloop.

loop at idat.

write:/ idat-fld1, idat-fld2, idat-fld3.

endloop.

[/code]

Regards,

Rich Heilman

Edited by: Aparna Shekhar on Jun 2, 2008 2:33 PM

Read only

Former Member
0 Likes
637

the parameter "has_field_separator" isn't what you think it is... look at the documentation for that function module:'


Description

    Specifies if the fields in the file are separated by a tab . This is
    necessary if the structure passed contains several components. CR/LF
    occurs instead of a tab after the last field of a row.

I would just upload the data into an itab that has only 1 field in it (char 255 or whatever)

then, loop through, separate at the commas into a 2nd itab.

regards,

robert.

Read only

Former Member
0 Likes
638

Hi

HAS_FIELD_SEPE... is meant to indicate if there is a seperator or not, and should not pass the seperator itself. If you are uploading a .CSV file...then use FM ALSMEXCELTOINTERNALTABLE

You will get the data into an ITAB in the form of Row, Column & Value. Just right around a logic to convert it into your required format.

Thanks

Sharath.