Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to convert .txt (from applicaiton server) to internal table

former_member842213
Participant
0 Kudos
61

hi all

i want to convert .txt (from applicaiton server) to internal table , im getting the contents in the itab, but im not able to remove '#',

can anybaody help me?

Thanks.

2 REPLIES 2

Former Member
0 Kudos
43

HI,

data : begin of itab occurs 0,

line(1000),

end of itab.

data : begin of jtab occurs 0,

field1,

fiedl2,

..

end of jtab.

after you read data from applicaton server into itab.

then do this.

loop at itab.

split itab-line at cl_abap_char_utilities=>cr_lf into jtab-field1 jtab-field2.

append jtab.

endloop.l

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
43

The # is a representation of the tab, so you need to do something like this.



report zrich_0001.

data: str type string.

data: begin of itab occurs 0,
      fld1(10) type c,
      fld2(10) type c,
      fld3(10) type c,
      end   of itab.

data:
      dsn(100) value '/usr/sap/TST/sys/test.txt'.

constants:
    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.

clear itab.  refresh itab.

* Read the data.
open dataset dsn for input in binary mode.
do.
  read dataset dsn into str.
  if sy-subrc = 0.
   split str at con_Tab into itab-fld1 itab-fld2 itab-fld3.
    append itab.
  else.
    exit.
  endif.
enddo.
close dataset dsn.


Loop at itab.
  write:/ itab-fld1, itab-fld2, itab-fld3.
endloop.

Regards,

RIch Heilman