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

Former Member
0 Likes
1,419

data: begin of it occurs 0,

char(100),

end of it.

data: begin of itab occurs 0,

id(4),

name(10),

end of itab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\emp.txt'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it

  • 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

.

my input is :

01 XY (tab in between)

02 AB

ouput in <b>it</b> is

01#XY

02#AB

I want to trnsfer data to ITAB by separating #

Need help !!

1 ACCEPTED SOLUTION
Read only

roland_spindler
Participant
0 Likes
1,400

Hi,


loop at it.
  SPLIT it AT '#' INTO itab-id itab-name.
  append itab.
endloop.

Hope this helps.

Roland

15 REPLIES 15
Read only

Former Member
0 Likes
1,400

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'C:\emp.txt'

FILETYPE = 'ASC'

<b>HAS_FIELD_SEPARATOR = 'X'</b>

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

.

.

.

.make the highlighted change.

Read only

0 Likes
1,400

Hi,

I tried the same.

HAS_FIELD_SEPARATOR = 'X'

but the data in my <b>it</b> internal table is

<b>01</b>. it should come 01 XY.

My it internal table having the field 100 char. but still i am not getting entire row.

Read only

0 Likes
1,400

Hi Eswar,

You can directly upload to ITAB.

I tried > it works...

data: begin of it occurs 0,
char(100),
end of it.

data: begin of itab occurs 0,
id(4),
name(10),
end of itab.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:dataemp.txt'
FILETYPE = 'ASC'
 HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
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
.

Read only

0 Likes
1,400

Hi eswar,

1. data_tab = it

use

<b>data_tab = itab</b>

2. U have used in FM

the internal table IT,

instead use ITAB (which has 2 fields)

3. Moreover your text file

records should be separted by ENTER .

4. Open that file in notepad and check

the format.

5. Very minor mistake, other wise everything about

your code is fine .

regards,

amit m.

Read only

0 Likes
1,400

data: begin of it occurs 0,

char(100),

end of it.

data: begin of itab occurs 0,

id(4),

name(10),

end of itab.

CALL FUNCTION 'GUI_UPLOAD'

EXPORTING

filename = 'D:\data\emp.txt'

FILETYPE = 'ASC'

  • HAS_FIELD_SEPARATOR = 'X'

  • HEADER_LENGTH = 0

  • READ_BY_LINE = 'X'

  • DAT_MODE = ' '

  • CODEPAGE = ' '

  • IGNORE_CERR = ABAP_TRUE

  • REPLACEMENT = '#'

  • CHECK_BOM = ' '

  • IMPORTING

  • FILELENGTH =

  • HEADER =

tables

data_tab = it

  • 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 it.

<b> SPLIT it-char AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO itab-id

itab-name.</b>

APPEND itab.

ENDLOOP.

Read only

Former Member
0 Likes
1,400

Set HAS_FIELD_SEPARATOR = 'X' in the call to GUI_UPLOAD.

You can directly upload to itab...

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'D:dataemp.txt'
FILETYPE = 'ASC'
 HAS_FIELD_SEPARATOR = 'X'
* HEADER_LENGTH = 0
* READ_BY_LINE = 'X'
* DAT_MODE = ' '
* CODEPAGE = ' '
* IGNORE_CERR = ABAP_TRUE
* REPLACEMENT = '#'
* CHECK_BOM = ' '
* IMPORTING
* FILELENGTH =
* HEADER =
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
.

Read only

suresh_datti
Active Contributor
0 Likes
1,400

Hi,

If you use the parameter HAS_FIELD_SEPARATOR = 'X' in the function module, your itab should be fine.

Regards,

Suresh Datti

Read only

roland_spindler
Participant
0 Likes
1,401

Hi,


loop at it.
  SPLIT it AT '#' INTO itab-id itab-name.
  append itab.
endloop.

Hope this helps.

Roland

Read only

0 Likes
1,400

First i want to get it into <b>it</b> then move into itab-id and itab-name.

so here i am passing <b>it</b> to data_tab.

Read only

0 Likes
1,400

Hi Eswar,

Try this..

loop at it.

SPLIT it AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO itab-id itab-name.

append itab.

endloop.

Read only

0 Likes
1,400

Hi,

Did you try mine...

It have even tried it...

Read only

0 Likes
1,400

Hi again,

1. First i want to get it into it then move into itab-id and itab-name.

If so,

then use gui_upload 2 times. Simple.

regards,

amit m.

Read only

0 Likes
1,400

hi ,

if thats the case..

from it-char

sorry at '#' dint work..

 loop at it.
  split it-char at L_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB into str1 str2.
  itab-id = str1.
  itab-name = str2.
  append itab.
 endloop.

regards

satesh

Message was edited by: Satesh R

Read only

Former Member
0 Likes
1,400

Hi Eswar,

HAS_FIELD_SEPERATOR = 'X'.

or use...

REPLACE ALL OCCURRENCES OF '#' IN char with space.

regards

satesh

Read only

Former Member
0 Likes
1,400

Hi,

If you dont want to use has_field_separator and If you can keep the input width constand you can use this code.

REPORT ZAUSTIN.

data: begin of it occurs 0,
char(100),
end of it.

data: begin of itab occurs 0,
id(4),
name(10),
end of itab.

CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = 'c:emp.txt'
FILETYPE = 'ASC'

tables
data_tab = it.

WRITE IT.

LOOP AT IT.
ITAB = IT.
APPEND ITAB.
ENDLOOP.

note that input lenth should be constant and no separting charector. i.e. my input was

' 01test1'

' 02test2' <- without the single quote

regards

austin