‎2006 Mar 09 10:13 AM
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 !!
‎2006 Mar 09 10:17 AM
Hi,
loop at it.
SPLIT it AT '#' INTO itab-id itab-name.
append itab.
endloop.
Hope this helps.
Roland
‎2006 Mar 09 10:15 AM
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.
‎2006 Mar 09 10:19 AM
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.
‎2006 Mar 09 10:21 AM
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
.
‎2006 Mar 09 10:22 AM
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.
‎2006 Mar 09 10:37 AM
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.
‎2006 Mar 09 10:16 AM
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
.
‎2006 Mar 09 10:16 AM
Hi,
If you use the parameter HAS_FIELD_SEPARATOR = 'X' in the function module, your itab should be fine.
Regards,
Suresh Datti
‎2006 Mar 09 10:17 AM
Hi,
loop at it.
SPLIT it AT '#' INTO itab-id itab-name.
append itab.
endloop.
Hope this helps.
Roland
‎2006 Mar 09 10:23 AM
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.
‎2006 Mar 09 10:26 AM
Hi Eswar,
Try this..
loop at it.
SPLIT it AT CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB INTO itab-id itab-name.
append itab.
endloop.
‎2006 Mar 09 10:26 AM
‎2006 Mar 09 10:29 AM
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.
‎2006 Mar 09 10:37 AM
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
‎2006 Mar 09 10:17 AM
Hi Eswar,
HAS_FIELD_SEPERATOR = 'X'.or use...
REPLACE ALL OCCURRENCES OF '#' IN char with space.
regards
satesh
‎2006 Mar 09 10:59 AM
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