Skip to Content
avatar image
-1
Former Member

Writing file in application server in ISO 8859-1 encoding

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Sep 19, 2017 at 11:07 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded