cancel
Showing results for 
Search instead for 
Did you mean: 

Table line data from flat file

Former Member
0 Kudos

hi folks,

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.

EXIT.

ENDIF.

split tb_line at ',' into REC-businessunit

REC-tablename REC-oldlegcode REC-description

REC-newlawsoncode.

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?

Thanks

Vinu.

Accepted Solutions (1)

Accepted Solutions (1)

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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.

Regards,

Rich Heilman

Former Member
0 Kudos

I don't think you can do anything without coding if the file has this extra special character. Try using REPLACE CL_ABAP_CHAR_UTILITIES=>NEWLINE WITH '' INTO myvariable. or CL_ABAP_CHAR_UTILITIES=>CR_LF.

Former Member
0 Kudos

Are you opening the dataset IN TEXT MODE?

Former Member
0 Kudos

Thanks for your response.

Vinu.

Former Member
0 Kudos

I am extremely sorry!!!! I pressed the wrong button and points went to Srinivas.

Srinivas, is there a way that you can transfer those points to Rich?

Sorry for the confusion.

Vinu

Former Member
0 Kudos

Yes I am opening in the Text Mode.

Vinu

Former Member
0 Kudos

Yes, simply select some other button against my post and select 'Problem Solved' against Rich's.

Former Member
0 Kudos

I meant selecting some other button against the post where you clicked 'Problem Solved'. I cannot do that. You have to do that. This is what you need to do. I think you will see a button that says 'The problem is not solved yet' or something like that. By doing that it will open the post again. You can then assign the 'Problem Solved' to Rich. You can simply remove all the points assigned to me that were not meant to be.

Former Member
0 Kudos

Thanks Srinivas for letting me know that.

Vinu

Answers (0)