2007 Jul 25 9:52 AM
Hi all,
I have a text file which contains records in a continuous format. One row in the text file extents upto 1099 charactors. i have about 100 rows in the text file without tab delimited. how can i upload this file to a internal table.
Please send your suggestions,
Raj.
Hi all,
I have a text file which contains records in a continuous format. One row in the text file extents upto 1099 charactors. i have about 100 rows in the text file without tab delimited. how can i upload this file to a internal table.
Please send your suggestions,
Raj.
2007 Jul 25 9:54 AM
HI rajesh,
1. we can use GUI_UPLOAD fm for this.
regards,
amit m.
2007 Jul 25 9:58 AM
Hi amit,
we can use GUI_UPLOAD. but what is the structure of the internal table.
At present iam using the below structure, but it uploads only the first row of the text file.
DATA : BEGIN OF ifile OCCURS 0,
text(1200) TYPE c,
END OF ifile.
Thanks,
Raj.
2007 Jul 25 10:02 AM
Hi again,
1. i assume that different rows are on different line.
(if it is not so, then let me know)
2. declare the internal table,
in EXACTLY the same way
as the FIELD SEQUENCE inside the file,
with EXACT LENGTH of each field.
regards,
amit m.
2007 Jul 25 10:03 AM
Hi Rajesh,
can you post your code,
try giving the whole body of internal table while passing to GUI_UPLOAD
<b>IFILE[].</b>
2007 Jul 25 10:04 AM
CALL FUNCTION 'GUI_UPLOAD'
see that the structure of the file and the internal table do match
if you are using a txt file do specify the delimiter correctly and also do press enter after the end of each row.
regards,
srinivas
<b>*reward for useful answers*</b>
2007 Jul 25 9:55 AM
Hi Rajesh
give file type as 'ASC' when uploading beacuse it is continuous format.
regards
sandhya
2007 Jul 25 9:57 AM
Hi
You can declare a internal table like
data: begin of itab occurs 0,
string(1200),
end of itab.
Use GUI_UPLOAD and move the text file into internal table.
Unless if there is no delimiter(some sort of separator symbol like space or comma between fields of the text file , then it is difficult to separate them into fields)
Other wise you have to loop the ITAb
and by using the offset of fields move the fields into another internal table and append that int table and use
<b>Reward points for useful Answers</b>
Regards
Anji
2007 Jul 25 10:01 AM
Hi,
try this:
cange as you need
DATA: DATEI_PC TYPE STRING VALUE 'C:\MATNR.TXT'.
*
DATA: BEGIN OF ITAB occurs 0,
TXT(1024),
END OF ITAB.
*
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = DATEI_PC
FILETYPE = 'ASC'
CHANGING
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
NOT_SUPPORTED_BY_GUI = 17
ERROR_NO_GUI = 18
OTHERS = 19.
*
IF SY-SUBRC NE 0. WRITE: / 'Error in Uploading'. STOP. ENDIF.
*
WRITE: / 'UPLOAD:'.
LOOP AT ITAB. WRITE: / ITAB-TXT. ENDLOOP.
Regards, Dieter
2007 Jul 25 10:13 AM
Hi,
Thanks for all your replies,
Below is my code;
Internal table structure:
DATA : BEGIN OF ifile OCCURS 0,
text(1200) TYPE c,
END OF ifile.
Upload FM:
CALL METHOD CL_GUI_FRONTEND_SERVICES=>GUI_UPLOAD
EXPORTING
FILENAME = file1
FILETYPE = 'ASC'
CHANGING
DATA_TAB = ifile[]
EXCEPTIONS
FILE_OPEN_ERROR = 1.
The records are in a continuous format such that the text file has rows with 1099 characters without tab delimited. I declared the row size as 1200 characters in the internal table. The result is in a way that, 1099 characters in the first row are uploaded along with 101 characters in the second row of the text file. At the end i have a single row with 1200 characters in my internal table.
Pls send your suggestions to upload the whole file,,,
Raj...
2007 Jul 25 10:24 AM
Hi again,
1. 1099 characters in the first row are uploaded along with 101 characters in the second row of the text file.
This is happening bcos
there should be ENTER after every record.
(and not TAB)
2. The text file should be like this.
RECORD1
RECORD2
RECORD3
and not like this
RECORD1 RECORD2 RECORD3
regards,
amit m.
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |