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: 

How to read a comma separated text file frm presentation server????

Former Member
0 Kudos

Hi all ,

How to read a comma separated text file frm presentation server????

i know we can use GUI_UPLOAD but it does not get the comma separated file into an structured internal table

Please let me know???

Thanks ,

Rajitha.Selvaraj

1 ACCEPTED SOLUTION

Former Member
0 Kudos

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_file

filetype = gc_filetype

TABLES

data_tab = gt_text_file

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

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*If the Presentation Server is selected on the selection screen

IF p_local EQ gc_x.

LOOP AT gt_text_file INTO wa_text_file.

CLEAR wa_text_table.

SPLIT wa_text_file-line AT gc_comma INTO wa_text_table-objectid

wa_text_table-lifnr

wa_text_table-matnr

wa_text_table-ebelp

wa_text_table-tdname

wa_text_table-spras

wa_text_table-textid

wa_text_table-object

wa_text_table-line. -


> this is the your internal table strcture...

APPEND wa_text_table TO gt_text_table.

6 REPLIES 6

Former Member
0 Kudos

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = gv_file

filetype = gc_filetype

TABLES

data_tab = gt_text_file

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

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

*If the Presentation Server is selected on the selection screen

IF p_local EQ gc_x.

LOOP AT gt_text_file INTO wa_text_file.

CLEAR wa_text_table.

SPLIT wa_text_file-line AT gc_comma INTO wa_text_table-objectid

wa_text_table-lifnr

wa_text_table-matnr

wa_text_table-ebelp

wa_text_table-tdname

wa_text_table-spras

wa_text_table-textid

wa_text_table-object

wa_text_table-line. -


> this is the your internal table strcture...

APPEND wa_text_table TO gt_text_table.

0 Kudos

Hi Kesav thx for the answer

how actually to get the content of the file directly into the structured internal table with out the split directly from the Function module by using the parameter has_field_separator = ' '

in the function module

0 Kudos

Hello Rajitha,

If you read the SAP documentation for HAS_FIELD_SEPARATOR parameter of GUI_UPLOAD.

Specifies whether the fields in the file are separated by a TAB.

It does not recognize "comma" as field separator, only TABS are recognised. I think this answers ur query.

BR,

Suhas

Edited by: Suhas Saha on Dec 15, 2008 11:01 AM

0 Kudos

Thanks suhas

Former Member
0 Kudos

There are lots of threads discussing this issue.

Search the forum with GUI_UPLOAD and you will get hundreds of sample code.

Have a habit of searching the forum before posting a question.

Read the [Rule of Engagement|https://wiki.sdn.sap.com/wiki/display/HOME/RulesofEngagement] before posting more.

Regards

Karthik D

Former Member
0 Kudos

This message was moderated.