Skip to Content
-1

Writing file in application server in ISO 8859-1 encoding

Sep 18, 2017 at 08:20 PM

109

avatar image
Former Member

Hi All,

I want to write a file in application server in ISO 8859-1 encoding. In order to do this i have coded like below but the issue is when we download and open the file in notepad++ which is in application server it is showing as UTF-8. Can any one help on this

data:   lv_encoding   TYPE abap_encod.
        lv_encoding = /tdag/cpcl_c_gen=>code_page_latin1.

LOOP AT lt_tab INTO ls_tab.
      CONCATENATE lv_char ls_tab lv_char INTO lv_string1.
      CONCATENATE lv_string1 cl_abap_char_utilities=>cr_lf INTO lv_string1.
      CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
        EXPORTING
          text     = lv_string1
*         MIMETYPE = ' '
          encoding = lv_encoding
        IMPORTING
          buffer   = lv_xstring
        EXCEPTIONS
          failed   = 1
          OTHERS   = 2.
      IF sy-subrc <> 0.
* Implement suitable error handling here
      ENDIF.

      ASSIGN lv_xstring TO <lf_any>.
      TRANSFER <lf_any> TO lv_file.
*      TRANSFER lv_string TO lv_file.
      CLEAR: ls_tab, lv_string, lv_xstring.

    ENDLOOP.

10 |10000 characters needed characters left characters exceeded

What is your OPEN DATASET statement?

2
Former Member

Sorry my mistake to Sandra & Mathew

  OPEN DATASET lv_file FOR OUTPUT IN LEGACY BINARY MODE CODE PAGE lv_encoding.
0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Sandra Rossi Sep 19, 2017 at 11:07 AM
1

OPEN DATASET :

OPEN DATASET lv_file 
FOR OUTPUT
IN LEGACY TEXT MODE CODE PAGE '1100' " ISO-8859-1
REPLACEMENT CHARACTER '#'.

No need of doing the code page conversion yourself, it's implicitly done.

Show 2 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Hi Sandra,

I am aware of this that we don't need to do the conversion again but unfortunately when open the file notepad ++ to see the encoding it is still showing as UTF8 so that is why i tried one more time to do the conversion.

Did you tried by opening your file notepad++ whether the encoding shows as ISO-8859-1 or not? I also passed the same code page 1100.

lv_encoding = /tdag/cpcl_c_gen=>code_page_latin1.

Regards,

Gupta

0

UTF-8 is very close to ISO-8859-1 for the lowest code points (at least the 128 first code points). How are you sure that it's UTF-8?

0