Skip to Content
0
Aug 30, 2007 at 11:57 AM

Urgent(reading a file)

17 Views

Hi

i need to read a comma separated text file.

i am using

cl_gui_frontend_services=>gui_upload

but i am not able to get what table type i should use in the importing parameter.i am getting an error. itab is not type compatible with importing parameter.

right now i am using the following code.

&----


*& Report ZFULLSTOPREAD

*&

&----


*&

*&

&----


REPORT ZFULLSTOPREAD.

types: begin of ita,

rec(1000) type c,

end of ita.

data: itab type standard table of ita with header line.

types: begin of itab22,

name(5) TYPE C,

AGE(2) type c,

quant(1) type c,

end of itab22.

data: file type string.

data: itab2 type standard table of itab22 with header line.

file = 'C:\test.txt'.

call method cl_gui_frontend_services=>gui_upload

exporting

filename = file

filetype = 'ASC'

has_field_separator = 'X'

changing

data_tab = itab

exceptions

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 itab.

clear itab22

split itab-rec at ',' into itab22-matnr.

itab22-werks.

itab22-quant.

append itab22.

endloop.

please reply..