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: 

Getting # appended into the last column after reading the file in a string variable

ojasve
Explorer
0 Kudos
704

I am getting # appended into the last column after reading the file in a string variable and also after I spilt the same string variable into a field of work area type char04 I am not getting the last character...for ex I am getting TAB instead of TABL .

OPEN DATASET p_fname FOR INPUT IN TEXT MODE ENCODING DEFAULT MESSAGE mess.
* OPEN DATASET p_fname FOR INPUT IN BINARY MODE MESSAGE mess.
IF sy-subrc = 0.
DO.
READ DATASET p_fname INTO lv_string.
IF sy-subrc <> 0.
EXIT.
ENDIF.
CONDENSE lv_string.
SPLIT lv_string AT ','
INTO ls_itab-typ
ls_itab-prog.
APPEND ls_itab TO lt_itab.
CLEAR ls_itab.
ENDDO.

CLOSE DATASET p_fname.

Here ls_itab-typ is of type char04- and is of type SY-Repid.

Here when we split the string variable lv_string containing value TABL,ZCUSTOMTABLE1.

But the value in the fields are coming as ls_itab-typ = 'TAB'

ls_itab-prog = 'ZCUSTOMTABLE1#'.

I hope i am able to explain the question

Any solution will be appreciated.Thanks.

8 REPLIES 8

matt
Active Contributor
570

Look at the value debug and see what hex value is behind it.

Sandra_Rossi
Active Contributor
570

No code, no answer...

raymond_giuseppi
Active Contributor
0 Kudos
570

How did you <placeholder>

matt
Active Contributor
570

Look at the value ls_itab-prog in debug and see what hex value is behind the # character.

ojasve
Explorer
0 Kudos
570

ls_itab-prog is solved as I have done string manipulation to remove # from this,hex value is attached also ....but for ls_itab-typ the value should come as TABLE instead it is coming as TAB but when the input is changed to PROG it is coming as PROG only any idea on this.

Sandra_Rossi
Active Contributor
570

As you can see, it's the first character FFFE (invisible) = well-known UTF-16 Little Endian Byte-Order Mark (see wikipedia).

This character should be removed, but you must also change your logic to decode UTF-16.

Open the file in binary mode.

Convert the text from UTF-16LE codepage (SAP 4103) - The class to use depends on your ABAP version.

ojasve
Explorer
0 Kudos
570

Thank you Sandra for the explaination.But I am not able to figure out the code.

Can you provide the code Please!

Thank you!

Sandra_Rossi
Active Contributor
0 Kudos
570

Which part of the code are you interested in? What did you try? What issue do you have?

There are many questions and answers in the forum for every part of the code .