Problem writing file ANSI to UTF-8. OPEN DATASET FOR OUTPUT IN TEXT MODE

Hello everybody,
My report needs  to create a file in ANSI so I am using this sentence: * "OPEN DATASET p_dir_a FOR OUTPUT IN TEXT MODE ENCODING DEFAULT."*  almost all charters in the file are well generating excepting for this two: ( Á ) & ( Í ) because SAP assigns the same code to both characters ( Ã? ) = 'xC3'  which is not correct, the right code should be ( Á ) = 'xC1'  ( Í ) = 'xCD' respectively
from this string = ( ÁÉÍÓÚáéíóúàèìòùÀÈÌÒÙ ) only those two characters are wrong converted.
Also I tray to catch a conversion error with this sentence:
          TRY.
            TRANSFER <field> TO p_dir_a NO END OF LINE.
          CATCH cx_sy_conversion_codepage.
            MESSAGE 'error' type 'I'.
        ENDTRY.
but never enters in it.
Does anyone know where I can configure SAP to SET this value correctly?
Thanks for your help.

was a server problem, not SAP

Similar Messages

  • Bad data added in Open Dataset for output in Binary mode

    Hello,
    I am getting random bad data being added to the end of the file that is created on the file server when I run the Open Dataset for output in Binary mode.  This data sometimes looks like information about the Unix file server.  If I do the Open Dataset in Text mode, it does not add the extra bad data.
    ** transfer file to Unix File server
           DATA: LIN TYPE P.
                                                                                    OPEN DATASET P_APPFIL FOR OUTPUT IN BINARY MODE.
                                                                                    DESCRIBE TABLE XML_TAB LINES LIN.
                                                                                    IF LIN EQ 0.
             EXIT.
           ELSE.
             LOOP AT XML_TAB.
               TRANSFER XML_TAB TO P_APPFIL.
             ENDLOOP.
           ENDIF.
                                                                                    CLOSE DATASET P_APPFIL.
    Running the program 2 times with the same variant will give different results.
    For example, the data in file should end with </cPedigreeXML> but it added data as shown below:
    </cPedigreeXML>8        ˜        I   X-UNKNOWN                                                 9            œ        I   X-UNKNOWN                                                10   
                C   X-UNKNOWN   
    Then, when the program was run again with the same selections, it did not add the erroneous data at the end.
    This is a real problem because the bad data that gets added causes the file to error in the application.  Any help would be greatly appreciated.
    Thanks,
    Bob

    Hi Bob,
          Use CLEAR statement after TRANSFER statement and check once.
         IF LIN EQ 0.
             EXIT.
           ELSE.
             LOOP AT XML_TAB.
               TRANSFER XML_TAB TO P_APPFIL.
               <b>CLEAR XML_TAB.</b>
             ENDLOOP.
           ENDIF.
    Thanks,
    Vinay

  • OPEN DATASET FOR INPUT IN TEXT MODE - linesize issue

    Hi,
    I faced a problem when opened ANSI file with CYRILLIC in ECC 6.0 Unicode system - the system cuts the line to 250 characters. Below is snip of code:
    REPORT  Z_TEST_01 LINE-SIZE 1023.
    DATA:
      file TYPE char40 VALUE 'ansi_file.txt',
      line TYPE char1024, len TYPE i.
    OPEN DATASET file FOR INPUT IN TEXT MODE ENCODING DEFAULT.
    WHILE sy-subrc = 0.
          READ DATASET file INTO line ACTUAL LENGTH len.
            WRITE: / len, line.
    ENDWHILE.
    CLOSE DATASET file.
    In this case, variable LEN always get value 250. File-content is correctly converted from ANSI and all CYRILLIC is displayed to the screen. I changed type for LINE - initialy the type was STRING, actially.
    Further, tried to open it in BINARY - like this:
    DATA:
      file TYPE char40 VALUE 'ansi_file.txt',
      line TYPE char1024, len TYPE i.
    FIELD-SYMBOLS <hex_container> TYPE x.
    OPEN DATASET file FOR INPUT IN BINARY MODE.
    ASSIGN line TO <hex_container> CASTING.
    DO.
      READ DATASET file INTO <hex_container>.
      IF sy-subrc = 0.
        WRITE: / line.
      ELSE.
        EXIT.
      ENDIF.
    ENDDO.
    CLOSE DATASET file.
    WRITE: / line.
    In this case I got bigger linesize (obviously 1024), but faced conversion issues - the file contains some CYRILLIC and it is messed. Played for few hours with conversions - using additions: IN LEGACY BINARY MODE... BIG/LITTLE ENDIAN, CODE PAGE... without success. So decided to ask...
    Well, I searched SDN for a similar issue, but didn't found, except this one:
    Re: OPEN DATASET STRING Problem
    Could someone points me what am I doing wrong? How can I read my ANSI file with line-size more than 250 chars? Actually, in my case line size may vary up to 1800 chars. Further, afrer conversion and some validation, I should save it back to the AS.
    Many thans in advance.
    Regards,
    Ivaylo Mutafchiev

    Sorry for the noise - it is not an issue anymore.

  • OPEN DATASET file FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE

    Hi There,
    I also have the similar issue. I am able to write the data into appliaction server in Chinese Characters using :OPEN DATASET datei FOR OUTPUT IN TEXT MODE ENCODING DEFAULT or OPEN DATASET datei FOR OUTPUT IN TEXT MODE ENCODING UTF-8. But when i save that file into my presentation server manually, all the chinese characters are showing as Junk.
    When i use OPEN DATASET datei FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE, giving runtime error and when i use OPEN DATASET datei FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE IGNORING CONVERSION ERRORS, No error but application server output itself showing as Junk characters.
    Could you please suggest me what you have done?
    Regards,
    Chaitanya A

    Hi,
       Use this
      OPEN DATASET File_path  FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE
      WITH SMART LINEFEED
    it will definitely work.
    Regards,
    Manesh. R

  • Open dataset for output

    Hi,
      When I create a file from R3 using open dataset for output, the file is created at the OS Level with rights coming from R3. Is there a way to control the properties of those rights.
    Regards,

    Hi,
    you can use authorization object S_DATASET & S_PATH to control user & program access to the file system . Then in your program use FM AUTHORITY_CHECK_DATASET to check the authority before opening to avoid a dump.
    Cheers
    Allan

  • CG3Z working not open dataset for output

    Hi,
    I am trying to upload data into the application server for which m using the OPEN DATASET statement. My file name is as follows in lowercase.
    p_file = '/usr/upi/out/test_20100220.dat'. TYPE c.
    While trying to execute this i am getting a short dump 'DATASET_NOT OPEN'.
    I tried to upload a file through tcode CG3Z with the same file path and its working fine whereas through the below code its not working at all.
    open DATASET w_filename_unix for INPUT in TEXT MODE ENCODING DEFAULT.
        LOOP AT i_fieldnames INTO wa_fieldnames.
          TRANSFER wa_fieldnames TO w_filename_unix.
        ENDLOOP.
        LOOP AT i_output INTO wa_output.
          TRANSFER wa_output TO w_filename_unix.
        ENDLOOP.
      if sy-subrc NE 0.
        WRITE: 'Error'.
      ENDIF.
      CLOSE DATASET w_filename_unix.
    Please help.
    Regards herwin..

    hii,
    Why is it W_filename...??? it should be p_file ...... after opendataset...

  • OPEN DATASET FOR OUTPUT IN LEGACY TEXT MODE not working!

    Hi All,
    I need your expertise to help me with my problem.
    The program passed through the code OPEN DATASET ... FOR OUTPUT IN LEGACY TEXT MODE. Then it gave an error message "Error Accessing File /home/sap/sample.txt".
    I would like to know what are the causes of this error. Please explain to me further why the program gives an error message specified above because I'm not familiar in OPEN DATASET.
    Please reply asap since the issue need to be resolved immediately.
    Thanks in advance,
    Carina

    Hi Carmey,
    The Problem will u need toi get Open Dataset Authorisation from ur Basis Team from the Specified Path.
    Regards,
    Morris Bond.
    Reward Points if Helpful.

  • Open Dataset for input in BINARY MODE not working after ECC 6.0 upgrade

    Hi All,
    Our requirement is to download an XML file from the application server and there is a customized program to download these files.
    This program uses the statement,  Open dataset ...for input in BINARY MODE
    and it works perfect for 4.7. There were no issues. But, after the upgrade to ECC 6.0 this does not work.
    When the data is read in ECC 6.0 , it is shown in some special characters and it could not be opened with XML editor and the file is not completely downloaded. I read through the forum and tried the following statement as well,
    Open dataset....for input in LEGACY BINARY MODE.
    After this statement, there were no special characters, but there is a blank space introduced before every character.
    Example : TEST(actual)
                      T E S T (After the legacy binary mode)
    Could you please let me know if there is any solution to rectify this problem. Appreciate your help.
    Thanks a million.
    Edited by: Manikd on May 12, 2011 3:52 PM

    But this program was already using BINARY MODE and after upgrade this is not working. I know, it may work in TEXT MODE. However, I cannot change the whole program to TEXT mode now.

  • Open dataset filename for output in text mode encoding default

    Hi,
    When I excute this command I get a sy-subrc = 0, but no file is created. This happens in an ECC 6.0 system. In 4.6C works ok.
    filename has the following structure '
    server\directory\filename'
    What am I doing wrong??
    Thank you very much for your your help.
    Regards.

    Hi,
    Can u tell what syntax u have written for open statement.
    In programs with active Unicode check, you must specify the access type (such as ... FOR INPUT, ... FOR OUTPUT, and so on) and the mode (such as ... IN TEXT MODE, ... IN BINARY MODE, and so on). If the file is opened using ... IN TEXT MODE, you must still use the addition ... ENCODING. If the Unicode check is enabled, it is possible to use file names containing blanks.
    Regards,
    Sruthi

  • Open dataset for file output does not work

    I have the following code
    OPEN DATASET MY_FILE FOR OUTPUT IN TEXT MODE ENCODING NON-UNICODE.
    MY_FILE is a selection parameter for the filename but when I put any file name, say C:\tmp\test.txt, the code does not create the file for writing. If I create the file manually from windows so that I am sure it exists (Right click-> New -> Text File -> test.txt), SAP still does not open the file for writing.
    Am I doing something wrong?
    I have searched the net and the forums but I can't seem to get a useful answer...
    Thanks in advance!
    Kyle

    Hey Prabhu,
    Thanks. I kinda missed this from the documentation:
    The file must be accessible from the application server. You cannot use OPEN DATASET to process files on the current presentation server (whether PC or workstation). The function modules WS_DOWNLOAD and WS_UPLOAD exist for this purpose.
    [http://help.sap.com/saphelp_40b/helpdata/en/34/55cad198482bc0e10000009b38f91f/content.htm]
    Points have been awarded. Thank you.
    Kyle

  • Unable to create a file in Application Server using OPEN DATASET stattement.

    I am unable to create a file in Application Server using the following statement.
    OPEN DATASET filename FOR OUTPUT
    IN TEXT MODE ENCODING DEFAULT
    MESSAGE msg.
    The message I'm getting is "Permission Denied". I have checked authorisation using SU53 which says "The last authorization check was successful". Please help.

    You can use following code to capture the error.
    TRY.
          OPEN DATASET filename FOR OUTPUT IN BINARY MODE MESSAGE V_MSG.
          CATCH CX_ROOT
          INTO EXCEPTION.
          CALL METHOD O_EXCEPTION ->IF_MESSAGE~GET_TEXT
            RECEIVING
            RESULT = V_MSG.
          MESSAGE v_msg
          TYPE 'E'.
    ENDTRY.
    You can capture error in v_msg.
    Following are the exceptions for the same:
    Exceptions
    Catchable Exceptions
    CX_SY_FILE_OPEN
    Cause: The file is already open.
    Runtime Error: DATASET_REOPEN
      CX_SY_CODEPAGE_CONVERTER_INIT   
    Cause: The desired conversion is not supported. (Due to specification of invalid code page or of language not supported in the conversion, with SET LOCALE LANGUAGE.)
    Runtime Error: CONVT_CODEPAGE_INIT
    CX_SY_CONVERSION_CODEPAGE
    Cause: Internal error in the conversion.
    Runtime Error: CONVT_CODEPAGE
    CX_SY_FILE_AUTHORITY
    Cause: No authorization for access to file
    Runtime Error: OPEN_DATASET_NO_AUTHORITY
    Cause: Authorization for access to this file is missing in OPEN DATASET with addition FILTER.
    Runtime Error: OPEN_PIPE_NO_AUTHORITY
      CX_SY_PIPES_NOT_SUPPORTED   
    Cause: The operating system does not support pipes.
    Runtime Error: DATASET_NO_PIPE
    CX_SY_TOO_MANY_FILES
    Cause: Maximum number of open files exceeded.
    Runtime Error: DATASET_TOO_MANY_FILES   Non-Catchable Exceptions   
    Cause: An attempt was made to open a pipe that is already open.
    Runtime Error: DATASET_PIPE_POSITION
    Hope that will help you.
    Please reward if useful.

  • Physical file location in SAP when OPEN DATASET command is used

    Hi,
    I have used below sample code from SAP help in my program. If you notice, I have not specified the file path however I am able to open and read this file whenever I want. Could anybody let me know where exactly is this file physically located. I have tried SP11( Temse objects) but no use.
    DATA: file   TYPE string VALUE `test.dat`,
          result TYPE string.
    OPEN DATASET file FOR OUTPUT IN TEXT MODE
                                 ENCODING DEFAULT.
    TRANSFER `1234567890` TO file.
    CLOSE DATASET file.
    OPEN DATASET file FOR UPDATE IN TEXT MODE
                                 ENCODING DEFAULT .
    TRANSFER `ABCD` TO file.
    CLOSE DATASET file.
    OPEN DATASET file FOR INPUT IN TEXT MODE
                                ENCODING DEFAULT .
    WHILE sy-subrc = 0.
      READ DATASET file INTO result.
      WRITE / result.
    ENDWHILE.
    CLOSE DATASET file.
    Regards
    Kasi

    Hi,,
    In the transaction AL11 go to the directory  DIR_TEMP... you can find your file there
    Regards,
    Siddarth

  • Write internal table to a file on application server using OPEN DATASET

    I have logical file path and XLS file name. I want to write internal table to a XLS or CSV file on application sever. Please give example.

    Hi
    see this program
    EXCEL SHET to INTERNAL table and then to APPLICATION server
    *& Report  ZSD_EXCEL_INT_APP
    REPORT  ZSD_EXCEL_INT_APP.
    parameter: file_nm type localfile.
    types : begin of it_tab1,
            f1(20),
            f2(40),
            f3(20),
           end of it_tab1.
    data : it_tab type table of ALSMEX_TABLINE with header line,
           file type rlgrap-filename.
    data : it_tab2 type it_tab1 occurs 1,
           wa_tab2 type it_tab1,
           w_message(100)  TYPE c.
    at selection-screen on value-request for file_nm.
    CALL FUNCTION 'KD_GET_FILENAME_ON_F4'
    EXPORTING
      PROGRAM_NAME        = SYST-REPID
      DYNPRO_NUMBER       = SYST-DYNNR
      FIELD_NAME          = ' '
       STATIC              = 'X'
      MASK                = ' '
      CHANGING
       file_name           = file_nm
    EXCEPTIONS
       MASK_TOO_LONG       = 1
       OTHERS              = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    start-of-selection.
    refresh it_tab2[].clear wa_tab2.
    file = file_nm.
    CALL FUNCTION 'ALSM_EXCEL_TO_INTERNAL_TABLE'
      EXPORTING
        filename                      = file
        i_begin_col                   = '1'
        i_begin_row                   =  '1'
        i_end_col                     = '10'
        i_end_row                     = '35'
      tables
        intern                        = it_tab
    EXCEPTIONS
       INCONSISTENT_PARAMETERS       = 1
       UPLOAD_OLE                    = 2
       OTHERS                        = 3
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    loop at it_tab.
      case it_tab-col.
       when '002'.
        wa_tab2-f1 = it_tab-value.
       when '004'.
        wa_tab2-f2 = it_tab-value.
      when '008'.
        wa_tab2-f3 = it_tab-value.
    endcase.
    at end of row.
      append wa_tab2 to it_tab2.
    clear wa_tab2.
      endat.
    endloop.
    data : p_file TYPE  rlgrap-filename value 'TEST3.txt'.
    OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING DEFAULT.
    *--- Display error messages if any.
      IF sy-subrc NE 0.
        MESSAGE e001(zsd_mes).
        EXIT.
      ELSE.
    *---Data is downloaded to the application server file path
        LOOP AT it_tab2 INTO wa_tab2.
          TRANSFER wa_tab2 TO p_file.
        ENDLOOP.
      ENDIF.
    *--Close the Application server file (Mandatory).
      CLOSE DATASET p_file.
    loop at it_tab2 into wa_tab2.
      write : / wa_tab2-f1,wa_tab2-f2,wa_tab2-f3.
    endloop.

  • Open dataset for input don't work after upgrade from 46C to 47

    We did an upgrade from 46C to 47, after that all the Z programs that have the sentence "open dataset for input" alwas send a sy-subrc = 8, the curios things is that the sentece "open dataset for output" works ok.
    Please I need help to solve this?
    En example of code.
    PARAMETERS: P_ARCHF(60) OBLIGATORY DEFAULT
                'C:\20050900.txt' LOWER CASE.
    OPEN DATASET P_ARCHF FOR INPUT IN TEXT MODE.
    IF SY-SUBRC <> 0. MESSAGE i001 WITH ARCHIVO. stop. endif.

    Well, it's telling you that the datset doesn't exist. From the help in 4.7:
    OPEN DATASET
    Addition 1a
    ... FOR INPUT
    Effect
    OPEN ... FOR INPUT opens the file in read mode.
    If the file does not exist, OPEN ... FOR INPUT fails with Return Code SY-SUBRC = 8.
    Note
    If OPEN DATASET is not executed in a Unicode program and if the user has write authorization for the file, the file is opened in read and write mode. Otherwise, it is only opened in read mode.
    Rob

  • Director 12- can't create a windows projector - problem writing file error

    I am trying to create a windows projector of a project. when I get the following error - problem writing file - file name- Can't compress file that has been modified and not saved. The file has not been modified and has been saved. Any help would be great.

    Hi.
    You say you have tried publishing to a new empty folder.  From the video I can see that the folder has table1.app in there (25 secs in) which is a Mac projector that has been published.
    Yet you have Windows Projector checkbox ticked at the start of the video.
    I publish Mac and Windows projectors to entirely seperate folders as a matter of practice.
    I call the folders "Published" and "PublishedMac" and that is where the respective projectors for each piece of software lives.
    Perhaps there is some mix up between Mac and Windows publishing that is going on because
    you are publishing both to the same folder?
    Hope this helps.
    Richie

Maybe you are looking for