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: 
SAP Community Downtime Scheduled for This Weekend

GUI_UPLOAD

Former Member
0 Kudos
195

Hi all,

I am trying to upload data from flat file to internal table using GUI_UPLOAD. The data in the file is tab delimited. what should I specify in the <b>HAS_FIELD_SEPARATOR</b>. I am forwarding my code too.

REPORT Z_FILE_READ.

data : begin of itab occurs 0,

carrid like sflight-carrid,

connid like sflight-connid,

end of itab.

data f_name type string value

'C:\Documents and Settings\Guest\Desktop\Book1'.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\BW\Book1.txt'

FILETYPE = 'ASC'

HAS_FIELD_SEPARATOR = ' '

READ_BY_LINE = 'X'

tables

data_tab = itab.

write 'vijay'.

Regards,

Varun.

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
147

The value for that parameter is either space or "X". The system will handle the rest. Not sure if it will work on tab delimited or not.

Regards,

Rich Heilman

9 REPLIES 9

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
148

The value for that parameter is either space or "X". The system will handle the rest. Not sure if it will work on tab delimited or not.

Regards,

Rich Heilman

0 Kudos
147

Hi Rich,

Now I changed the value to X and in the input file I gave the seperator as ,(comma). But it still doesn't work properly.If not this FM what is the best way to upload data from file to internal table ?

Regards,

Varun.

Message was edited by: varun sonu

0 Kudos
147

Try this code -

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gd_file

has_field_separator = 'X' "file is TAB delimited

TABLES

data_tab = it_record

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.

IF sy-subrc NE 0.

write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.

skip.

endif.

0 Kudos
147

Hi Varun,

You can use FM WS_UPLOAD or UPLOAD.Though it says obselate,you can still use them.

0 Kudos
147

Hi, I have created an tab delimited file and a test program. I have set the parameter to "X". It is working good for me. Create a tab delimited text file in notepad and save as .txt file. It should work.

report  zrich_0001.

data: begin of itab occurs 0,
      fl1(10) type c,
      fl2(10) type c,
      fl3(10)  type c,
      end of itab.

call function 'GUI_UPLOAD'
  exporting
    filename            = 'C:test.txt'
    filetype            = 'ASC'
    has_field_separator = 'X'
  tables
    data_tab            = itab.

loop at itab.

  write:/ itab-fl1, itab-fl2, itab-fl3.
endloop.

Regards,

Rich Heilman

0 Kudos
147

Hi all,

The previous two did not work out for me. when I use ws_upload the result is same. But when Iused If sy-subrc is 0.Guys you might have worked in real time. When you do call transaction or session ow do you upload data from flat file to internal table ? My purpose is also same.

Regards,

Varun.

0 Kudos
147

Hi Rich,

Thank you Its working.

Regards,

Varun.

0 Kudos
147

Good, I'm glad that it worked out.

REgards,

Rich Heilman

Former Member
0 Kudos
147

i test the program,but it can not upload files include chinese chararcter.how can i upload chinese characters?