2006 Apr 07 1:26 PM
Hi Group,
Any body can please suggest me how to upload text file.
In my text file I am having the header text on the first row,in my case I need the data to upload excluding the Header.
2006 Apr 07 1:32 PM
hi pra,
if u use the process of lsmw to upload the data then there is once option in the step ''specify file'' in that option if u add the file then there is one option in the popup ask weather do u have filed names at the start of file then by not checking that option u can eliminate those filed name i think
and one more way u can try also try to convet that file into excel file then copy ur required records then paste thos records in new excel file and save again it as a txt file
i thinks this info is helpful for u
Thanks in advanse
naveen
2006 Apr 07 1:28 PM
From PC? If so, use function module GUI_UPLOAD. This will upload into internal table, then all you need to do is skip the first row in your loop.
report zrich_0001.
data: begin of itab occurs 0,
rec(1000) type c,
end of itab.
start-of-selection.
call function 'GUI_UPLOAD'
exporting
filename = 'C:test.txt'
tables
data_tab = itab.
loop at itab.
check sy-tabix > 1. " Skip first record
endloop.
Regards,
RIch Heilman
2006 Apr 07 1:32 PM
Yah, from PC I am uploading the tab delimeted text file.
Earlier I used the FM KCD_EXCEL_OLE_TO_INT_CONVERT ro Upload the Excel file from row 2(because first row is my header),If I use GUI_UPLOAD FM how to skip the first row,can you please suggest
2006 Apr 07 1:29 PM
Hello,
Use FM WS_upload, and file type as <b>ASC</b>
After FM,
delete itab index 1. " to delte header line.
regards,
Naimesh.
2006 Apr 07 1:30 PM
CALL FUNCTION 'WS_UPLOAD'
EXPORTING
filename = filename
filetype = 'ASC'
has_field_separator = 'X'
TABLES
data_tab = auxitab
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.
Then
DELETE auxitab index 1.
2006 Apr 07 1:32 PM
hi pra,
if u use the process of lsmw to upload the data then there is once option in the step ''specify file'' in that option if u add the file then there is one option in the popup ask weather do u have filed names at the start of file then by not checking that option u can eliminate those filed name i think
and one more way u can try also try to convet that file into excel file then copy ur required records then paste thos records in new excel file and save again it as a txt file
i thinks this info is helpful for u
Thanks in advanse
naveen
2006 Apr 07 1:50 PM
2006 Apr 08 12:30 PM
Hi Rich,
In my case I am giving the tab delimeted file (with space),when I am using GUI_UPLOAD its not reading rows
correctly can you please suggest
2006 Apr 08 7:24 PM
Hi,
Try changing the file type to DAT. Also make sure HAS_FIELD_SEPARATOR parameter is checked.
Regards,
Ravi
2006 Apr 07 2:06 PM
Hi,
Use the function module gui_upload.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
FILENAME = P_FILE
FILETYPE = 'ASC'
IMPORTING
FILELENGTH =
TABLES
DATA_TAB = RECORD
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.
After getting the uploaded text into the internal table.You can make a new internal table appending the rows of first table to second internal table excluding the first row.
Loop at RECORD.
if sy-tabix > 1.
MOve RECORD to RECORD1.
Append record1.
endif.
endloop.
Record1 will not have the data of header which you can use for further processing.
Thanks
Mayank
PS:If you find it useful.Please reward points.