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

uploading file

syed_ibrahim5
Active Participant
0 Likes
569

hi,

i have to upload data through bdc... i am doing it using gui_upload...... the file is a text file....

the fields are seperated by comma......... so it is not uploading to the internal table......but when it is given with tabs it is getting uploaded......i have tried using field seperator parameter as ',' .... but it is still not working....pls help me out..

thanks in advance,

syed

1 ACCEPTED SOLUTION
Read only

kesavadas_thekkillath
Active Contributor
0 Likes
485

types:begin of ty_line,

line type char255, ( give the size as required)

end of ty_line.

data:i_line type table of ty_line.

data:wa_line type ty_line.

Using GUI_UPLOAD upload the file to internal table i_line.

next

loop at i_line into wa_line.

split wa_line at ',' into wa_itab-field1 wa_itab-field2 wa_itab-field3.

append wa_itab to i_tab.

endloop.

Now i_tab will hold the data.

3 REPLIES 3
Read only

Former Member
0 Likes
485

Hi SYED_ibbu ,

dont use field seperator parameter- try command split

split each line of the file into a string table.

uploaded line:

1,2,3

string table:

1

2

3

then loop at the string table and assign each line to a work area

which is of the same line type like the records in your upload file.

Regards

REA

Edited by: Ramy EL-ARNAOUTY on May 6, 2010 5:10 PM

Read only

kesavadas_thekkillath
Active Contributor
0 Likes
486

types:begin of ty_line,

line type char255, ( give the size as required)

end of ty_line.

data:i_line type table of ty_line.

data:wa_line type ty_line.

Using GUI_UPLOAD upload the file to internal table i_line.

next

loop at i_line into wa_line.

split wa_line at ',' into wa_itab-field1 wa_itab-field2 wa_itab-field3.

append wa_itab to i_tab.

endloop.

Now i_tab will hold the data.

Read only

0 Likes
485

hi keshav,

your solution becoms unclear, if you habe a lot more than 3 columns.

try this

TYPES: BEGIN OF ty_tab,
        col1 TYPE string,
        col2 TYPE string,
        col3 TYPE string,
       END OF ty_tab.

DATA data_tab TYPE TABLE OF string.
DATA itab     TYPE TABLE OF string.

DATA lt_import TYPE TABLE OF ty_tab.
DATA ls_import TYPE ty_tab.

FIELD-SYMBOLS <data> TYPE string.
FIELD-SYMBOLS <wa>   TYPE string.
FIELD-SYMBOLS <comp> TYPE ANY.

CALL FUNCTION 'GUI_UPLOAD'
  EXPORTING
    filename = 'C:\Temp\upl.txt'
    filetype = 'ASC'
  TABLES
    data_tab = data_tab.

LOOP AT data_tab
  ASSIGNING <data>.

  SPLIT <data> AT ',' INTO TABLE itab.

  LOOP AT itab
     ASSIGNING <wa>.

    ASSIGN COMPONENT sy-tabix OF STRUCTURE ls_import
      TO <comp>.

    <comp> = <wa>.

  ENDLOOP.

  APPEND ls_import TO lt_import.

ENDLOOP.

lt_import stores the uploaded records.

Regards

REA

Edited by: Ramy EL-ARNAOUTY on May 7, 2010 10:19 AM