‎2007 Apr 04 8:52 AM
hi gurus
i have to upload this the below file into an internal table but the data in the flat file is different data types.
310 320 330 340 350 360 370 380 390 400 410 420 430 440 450
70000000510 Vinay 31.03.2007 76 11.24 11.25 11.26 11.27 11.28 11.29 Guest Room meter recording abnormally high due to internal component failure. 89 VINAY1 120 CTS 400 KTS 200 PTS 300
plz suggest how to upload into internal table.
Thanks and Regards,
alson
‎2007 Apr 04 9:01 AM
Hi....
Take an internal table of type string...
Try the following code......
DATA: BEGIN OF TEST OCCURS 0,
CARRID TYPE STRING,
END OF TEST.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE NAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = TEST
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.
LOOP AT TEST.
WRITE TEST-CARRID.
ENDLOOP.
Reward points if useful.......
Suresh..........
‎2007 Apr 04 8:55 AM
Hi Alson,
Let it be. Have all the fields as character types (of sufficient lenghts), then you can move them to another winternal table with columns of appropriate data types.
regards,
ravi
‎2007 Apr 04 8:56 AM
Hi..
data:
begin of itab,
f1 type string,
end of itab.
now upload file using 'GUI_UPLOAD' into itab.
‎2007 Apr 04 9:01 AM
Hi....
Take an internal table of type string...
Try the following code......
DATA: BEGIN OF TEST OCCURS 0,
CARRID TYPE STRING,
END OF TEST.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = FILE NAME
FILETYPE = 'ASC'
HAS_FIELD_SEPARATOR = ' '
HEADER_LENGTH = 0
READ_BY_LINE = 'X'
DAT_MODE = ' '
CODEPAGE = ' '
IGNORE_CERR = ABAP_TRUE
REPLACEMENT = '#'
CHECK_BOM = ' '
VIRUS_SCAN_PROFILE =
IMPORTING
FILELENGTH =
HEADER =
TABLES
DATA_TAB = TEST
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.
LOOP AT TEST.
WRITE TEST-CARRID.
ENDLOOP.
Reward points if useful.......
Suresh..........
‎2007 Apr 04 9:30 AM
You can have intenal table of type string in which you can upload data of various data types.
for ex.
Types:
BEGIN OF t_file,
content TYPE string,
END OF t_file.
and then,
Data: i_file type standard table of t_file.
then upload the data in internal table i_file
‎2007 Apr 04 12:28 PM
hi guys,
i have done the chnages wht u suggested but still its not working. our client is using 4.6B version. Can u suggest something else.
Thanks and regards,
alson.
‎2007 Apr 05 6:13 AM
Hi guys,
I did the same as u mentioned but still i am unable to uplaod the data.My clint is still using 4.6B version. Is this version problem? guys plz help me to solve this problem bcz its urgent.
Thanks and regards,
alson.
‎2007 Apr 05 6:18 AM
Can u post ur code??
Just declare all the fields inm ur internal tables of type char, and then use GUI_UPLOAD
‎2007 Apr 05 6:25 AM
Hi shekar,
Thanks for the reply. The thing is i have to upload a file which is this type--
310 320 330 340 350 360 370 380 390 400 410 420 430 440 450
70000000510 Vinay 31.03.2007 76 11.24 11.25 11.26 11.27 11.28 11.29 Guest Room meter recording abnormally high due to internal component failure. 89 VINAY1 120 CTS 400 KTS 200 PTS 300
then i have to move to anothe internal table. the above filelds are of diferent data types. wht iam trying to do is upload all the data into an internal table with single field and then move to another internal table by splitting. The end user has the file of this type. plz suggest a good solution.
thanks and regards,
vinay
‎2007 Apr 05 6:31 AM
We need to re-view your code to see what is actually wrong. All the people posted in this thread is the correct way to do an upload, without your code, we cannot determine what is actually wrong.
The best is that you could open your raw file in an excel, and save as tab delimited text file. Declare your internal table in such a way that all fields should only accept character values.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = l_file_path
HAS_FIELD_SEPARATOR = 'X'
tables
data_tab = li_my_internal_table
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
.
‎2007 Apr 05 6:32 AM
data : begin of itab occurs 0,
field(1000),
end of itab.
data : begin of it_final occurs 0,
field1(10),
field2(15),
......
end of it_final.
* use gui_upload and populate the data in itab
then
loop at itab.
it_final-field1 = itab-field+0(10).
it_final-field2 = itab-field+10(15).
.............
......
append it_final.
clear it_final.
endloop
‎2007 Apr 05 6:55 AM
hi shekar,
I did the same . i am pasting copy of my code.
DATA: BEGIN OF itab OCCURS 0,
v_str TYPE xstring,
END OF itab.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = p_fname
filetype = 'DAT'
has_field_separator = 'X'
IMPORTING
filelength = v_length
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
OTHERS = 6.
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*
I am unable to upload the file the format is in earlier message. once this is done i will be able to move data to another internal table in which all the fields will be of character type
Thanks and regards
alson
‎2007 Apr 05 6:58 AM
1. Whats the name of ur file ??
2. change ur itab declaration to this and try
DATA: BEGIN OF itab OCCURS 0,
v_str(1000),
END OF itab.
‎2007 Apr 05 7:03 AM
Hi shekar ,
its a text file. i have even tried this earlier. but of no use anyhow i will try once again. plz send any code if u have of similar type.
Regards,
alson
‎2007 Apr 05 7:05 AM
1. Check the S-SUBRC value
2. pls post the full path of ur filename
‎2007 Apr 05 7:15 AM
hi shekar,
the file path is
C:\Documents and Settings\agtech-swagatika\Desktop\bdc.txt
sy-subrc is 0 only. Its taking blank values.
Please suggest me a solution
Regards
alson
‎2007 Apr 05 10:15 AM
hi shekar,
now my upload problem is solved. I chaged the file type from DAT to BIN/ASC. The present data in my inernal table is like this..
310#320#330#340#350#360#370#380#390#400#410#420#430#440#450##70000000510#Vinay#31.03.2007#76#11.24#11.25#11.26#11.27#1
Plz tell me how to move this data to another internal table.
Thanks and regards
alson.