Table line data from flat file
I am reading the data from the flat file(.CSV) into a single line and then splitting the data at the ',' and reading them into the fields of internal table like:
DATA: tb_line(125) type c.
data: begin of rec occurs 1,
businessunit(3) type c,
tablename(30) type c,
oldlegcode(30) type c,
description(30) type c,
newlawsoncode(30) type c,
records(8) type c,
message(50) type c,
end of rec.
READ DATASET filein INTO tb_line.
IF SY-SUBRC NE 0.
split tb_line at ',' into REC-businessunit
REC-tablename REC-oldlegcode REC-description
the data read into the tb_line is
tb_line = BPF,PAYCODES,OVERTIME,Overtime,OTP#
and therefore the final field takes the value 'OTP#'
To get rid of this '#' I have read the final field value into a variable and then remove the ''#" using shift.
<b>My question is can we avoid the appearence of '#' while reading the data into the tb_line.</b>
Because on three separate occasions I have encountered this scenario and everytime I will have to declare the varuable for the last field and remove the '#" sign with some additional code.
Is there a better way to solve this?
Rich Heilman replied
If you are shifting it one place to the right and then back to remove it, I believe that this is the best way to handle it. This is the line return in the file. You don't really have any control of the file so this is the best way, to handle yourself.