cancel
Showing results for 
Search instead for 
Did you mean: 

Junk value is coming when uploading text file to AL11 via open data set

kunal_chandra
Explorer
0 Kudos
195

I am using OPEN DATASET lv_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT . to transfer file to AL11 path but when reading the file I am getting junk value ï»¿ is beginning it self as show in attachment . I tried  ENCODING  NON-UNICODE and UTF-8 also to place the file but no luck. Basically it getting uploaded with UTF-8 with BOM, but in order to resolve this I need it in UTF-8 format. Any suggestion will be helpful.

 

ABAP Development 

kunal_chandra_0-1739300121832.png

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor
0 Kudos

I guess it's the Byte Order Mark representing UTF-8 = bytes 'EFBBBF' (see Wikipedia). You may use

OPEN DATASET ... FOR INPUT ENCODING UTF-8 SKIPPING BYTE-ORDER MARK

See OPEN DATASET, encoding (ABAP Keyword Documentation).

 

kunal_chandra
Explorer
0 Kudos
Thanks, I tried above syntaxes bit still getting  in the file and the file format showing as UTF8 with BOM when downloading
Sandra_Rossi
Active Contributor
0 Kudos
Then, probably the file you are trying to read is incorrect, it really contains 3 characters  which should not be there, probably there was a mistake when generating the file (OPEN DATASET ... FOR OUTPUT).
kunal_chandra
Explorer
0 Kudos
the code is below:
kunal_chandra
Explorer
0 Kudos
the code is: TRY. CALL METHOD cl_abap_file_utilities=>create_utf8_file_with_bom EXPORTING file_name = lv_file. CATCH cx_sy_file_open INTO DATA(lx_open). CATCH cx_sy_file_authority INTO DATA(lx_auth). CATCH cx_sy_file_io INTO DATA(lx_io). CATCH cx_sy_file_close INTO DATA(lx_close) . ENDTRY. IF lv_file IS NOT INITIAL. OPEN DATASET lv_file FOR APPENDING IN TEXT MODE ENCODING DEFAULT . IF sy-subrc = 0 and lv_hdr IS NOT INITIAL. TRANSFER lv_hdr TO lv_file. ENDIF. endif
Sandra_Rossi
Active Contributor
0 Kudos
The file generation seems OK, it's UTF-8 with BOM. How are you reading/getting the file? NB: my first answer was about the reading of the file (FOR INPUT ENCODING UTF-8 SKIPPING BYTE-ORDER MARK).