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: 

Issue with reading the first line of CSV file

0 Kudos
646

Hello Experts,

CSV file from AL11 folder is opened and read using the below commands

OPEN DATASET filename FOR INPUT IN TEXT MODE ENCODING DEFAULT WITH SMART LINEFEED

Reading dataset is as below:

READ DATASET  filename INTO wa_tab_dataset.

While checking the first 3 characters of WA_TAB_DATASET it is ignoring the third character as shown below.

This happens only for the first line of the file. In the file we could not see any spaces as well.

Any inputs regarding this will be helpful.

Thanks and Regards,

Sanjay.

4 REPLIES 4

matt
Active Contributor
443

What does the hexadecimal field show for these two scenarios?

Sandra_Rossi
Active Contributor
443

Look at the "hexadecimal" part:

FF...

It's probably FFFE...

FFFE is the Byte-Order-Mark character for UTF-16 Little Endian (it could be also UTF-32LE but it's very rare).

Make sure with the architects that this format is as expected. It should also be documented in the requirement.

If it's confirmed, then you need to:

  • open the dataset IN BINARY MODE
  • read it into XSTRING variable (no loop needed, the whole file will be read at once)
  • Convert XSTRING into STRING using a code page conversion class with code page '4103' or 'utf-16le' (depends on your ABAP version).

former_member808116
Participant
0 Kudos
443

You try: Wa_tab_dataset+0(3).

0 Kudos
443

Hello Sandra,

As you said Hexadecimal part is FFFE for the first row and it is different for all the other rows.

I will check with the Architects. Thanks for your help.

Regards,

Sanjay.