OPEN DATASET...  in a Unicode system

I'm discussing with a developer @ SAP about the correct use of OPEN DATASET in a Unicode system. I'm not sure I'm correct with my opinion so maybe someone could shed a light on it.
The source of discussion is the (SAP standard) program RSQUEU01. This program is used to download data from the TemSE; in our case we use it to produce a file that is to be sent to auditors (component FI-AIS).
Our system is a little endian Unicode system (codpage 4103). If we download the created data using that program we get a dump with "CONVT_CODEPAGE" because a character could not be converted from 4103 to 1100.
The proposed correction by the developer is changing
OPEN DATASET EXP_FILENAME FOR OUTPUT IN legacy BINARY MODE.
to
OPEN DATASET exp_filename                              
FOR OUTPUT IN LEGACY BINARY MODE                     
IGNORING CONVERSION ERRORS.
I think, that correction is wrong. Since we have 12 languages in the system including some Asian the output might get corrupted.
When I asked him about that I was told use an application server with a "correct codepage" then - I'm not sure what that means since I can't connect an ASCII application server to a Unicode system.
I guess the statement should be
OPEN DATASET EXP_FILENAME FOR OUTPUT IN BINARY MODE ENCODING DEFAULT.
This makes sure that no data is cut (like doublebyte) and makes sure, the appropriate codepage (LE/BE) is used.
Are my assumptions right?
Markus
(OSS 323320/2010)

Hi Markus,
Let's first clarify the difference ways for writing files:
<ul style="list-style:circle!important;">
<li>BINARY MODE: Means that we essentially dump a sequence of bytes, which isn't necessarily related to any code page (and characters). I.e. if I'd want to save for example an executable program, the individual bytes have no meaning when interpreted as characters (unless we look at strings stored in the program). Note that legacy binary mode actually allows you to specify a code page though, but in general the recommendation is not to use the legacy option.</li>
<li>TEXT MODE: Here we have text information that has to be interpreted using a specific code page; thus usually the additional parameter ENCODING should be given, which specifies which code page is used.</li>
</ul>
Now, let's clear up a small typo in Ajay's response:
Yes you are right if you want to have all double byte characters too then you need to use ENCODING DEFAULT which would use 4103 in Unicode system.
That is incorrect. In a Unicode system [encoding default|http://help.sap.com/abapdocu_70/en/ABAPOPEN_DATASET_ENCODING.htm] corresponds to UTF-8, not UTF-16.
Back to your problem. Your suggestion doesn't work, because you cannot specify encoding default for a binary output (the legacy binary mode allows you to specify a code page, but that's misleading and I wouldn't use any legacy mode). So when you try to use the syntax you proposed, you'd get a syntax error.
Generally the recommendation is for Unicode enabled applications to use UTF-8 files with byte order mark, i.e. something like
open dataset EXP_FILE in text mode encoding utf-8 with byte-order mark.
However, the real question is what your external audit application expects and it sounds as if it's not Unicode enabled...
Enough blabber, here's what I'd do: Since you're having issues with a audit-related standard SAP program I'd post the question in forum - other people must have run into that problem. Also, I checked OSS, but couldn't make much sense out of the few notes I've found (and nothing seemed relevant). Check what the expected input format is in the external audit system; possibly post a message to OSS.
Cheers, harald

Similar Messages

  • Unable to Open unix file in UNICODE system which created NON-UNICODE system

    Unable to Open unix file in UNICODE system which created in NON-UNICODE system
    We have two SAP systems both are ECC6.0 but System 1 is NON-Unicode and System2 is Unicode system.
    There is a common unix directory/folder for both system.
    Our requirement is to create one file on unix common folder and write the data to file from system1 .
    In system2 open the same file for appending mode to write the data .
    The file in system 1 created with below sentence.
    OPEN DATASET g_unix_file FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
    Now I have to append the data from system 2 to same file.
    I have tried to used below statement in system 2 to open the file but sy-subrc value comes as '8'.
    1> OPEN DATASET g_unix_file FOR APPENDING IN TEXT MODE ENCODING UTF-8.
    2>OPEN DATASET g_unix_file FOR APPENDING IN legacy TEXT MODE CODE PAGE
    cdp IGNORING CONVERSION ERRORS  .
    3>OPEN DATASET g_unix_file FOR APPENDING IN TEXT MODE ENCODING Default.
    4>OPEN DATASET g_unix_file FOR APPENDING IN TEXT MODE ENCODING NON-UNICODE.
    Tried out all the possibilities as per F1 help given for open dataset , but still there is problem with opn file in appending as well output mode.However the file successfully open in Input mode(Read).
    Please advice suggestion to resolve this issue.
    Thanks.

    Messgae captured as 'Permission Denied". The program gets triggered with system user Id PPID.
    How to check the security access of the User ID.

  • Truncated record in OPEN DATASET ENCODING NON-UNICODE

    Hi,
    I have to read a Unicode created file into a non-unicode SAP System, version 4.7.
    When I make the OPEN DATASET using ENCODING UTF-8 y get a CONVT_CODEPAGE dump. That´s odd cause my system is non-unicode. I don´t wanna use IGNORING CONVERSION ERRORS attribute, the output will be corrupt.
    But when I use ENCODING NON-UNICODE or ENCODING DEFAULT the READ DATASET mysteriously truncate the record which try to read from real 401 characters to 361 characters. Variable is string.
    I can see full records through AL11.
    Any ideas?
    Thanks,
    Pablo.

    Hi,
    Try using:
      open dataset filename in text mode encoding default for input
                                  ignoring conversion errors.
    As said in AL11 its coming so the above code is used for that.
    Hope this will surely help you !!!
    Regards,
    Punit

  • Open Dataset non-unicode & default

    Currently im using the open dataset with default then it hit a codepage error. I found out that the file contained characters that is not UTF-8 so when i changed the open dataset to non-unicode the codepage error goes away. Im wondering if there is any effect of changing from default to non-unicode.

    OPEN DATASET P_AFILE FOR INPUT IN TEXT MODE ENCODING DEFAULT ignoring conversion errors.
    ADD ignoring conversion errors to ur prg
    and should be unicode.
    hope it will help you.
    Regards,
    sinagam.
    Edited by: Venkata Pavan Sinagam on Sep 23, 2011 5:50 PM

  • Open dataset twice once for input and once for output in unicode system

    Hi All,
    In a program
    I used a open dataset to read the data from the file.
    OPEN DATASET cmp_file FOR INPUT IN TEXT MODE
          ENCODING NON-UNICODE.
    Then i closed the file.
    Again later in the program,
    I used a open dataset to transfer the data.
    OPEN DATASET cmp_file FOR OUTPUT IN TEXT MODE
          ENCODING NON-UNICODE.
    But this time I get sy-subrc = 8.
    Unable to open the file and subsequent TRANSFER is leading to the runtime error.
    Note : I am using a unicode system
    I could run the same program well in non-unicode system..
    ->
    Is it that if a file contains data already
    1.I need to delete the data and open it
    or
    2.I need to open in APPENDING mode manadatorily...
    in case of UNICODE system..
    Kindly suggest..

    Hi,
    IF you have write permission al S.O. Level you need to check your DATASET rigths using AUTHORITY_CHECK_DATASET, this validate your rigths with S_DATASET object.
    Example
    TYPE-POOLS SABC.
    CALL FUNCTION 'AUTHORITY_CHECK_DATASET'
    EXPORTING PROGRAM = 'ZDATASET'
    ACTIVITY = SABC_ACT_READ
    FILENAME = '/tmp/sapv01'
    EXCEPTIONS NO_AUTHORITY = 1
    ACTIVITY_UNKNOWN = 2.
    See SABC type pool to know wich activities are aviable.
    Hope this help.
    Regards

  • Open Dataset - unicode system ECC 6.0,special characters

    Hi,
    we have upgraded our system from 46b to ecc 6.0 unicode. We face following problem in file download to application server(solaris) using open dataset.
    in output file hyphen(-) character is by special character â.
    eg. if data in table is  'BANGALORE - 560038' is displayed as 'Bangalore â 560034' in application server file. if we download the same file to windows it shows proper data.
    only when we open file in vi editor on application server , system shows this special character.
    Kindly help.
    Regards,
    Sidhesh S

    OPEN DATASET G_APFILE FOR INPUT IN TEXT MODE.in 4.6                                                                                                    
        OPEN DATASET G_APFILE IN LEGACY TEXT MODE FOR INPUT in ECC6.0
    regards
    Giridhar

  • 'Open Dataset' command - add ASCII code in a unicode system

    Hi,
    I use following comand in order to save a file on an application server. 
    open dataset <path> for output in text mode encoding default.
    Is it possible to convert file to ASCII code instead of the system setting unicode and to ignore conversion errors? If yes, please tell me how.
    Thanks!

    problem exporting text in hebrew
    Similar kind of problem has been solved here.. check that link first
    Use the class CL_ABAP_CONV_OUT_CE and use it to convert file from unicode to ascii.

  • Open dataset in UTF8. Problems between Unicode and non Unicode

    Hello,
    I am currently testing the file transfer between unicode an non unicode systems.
    I transfered some japanese KNA1 data from non unicode system (Mandt,Name1, Name2,City) to a file with this option:
    set local language pi_langu.
      open dataset pe_file in text mode encoding utf-8 for output with byte-order mark.
    Now I want to read the file from a unicode system. The code looks like this:
    open dataset file in text mode encoding utf-8 for input skipping byte-order mark.
    The characters look fine but they are shifted. name1 is correct but now parts of the city characters are in name2....
    If I open the file in a non unicode system with the same coding the data is ok again!
    Is there a problem with spaces between unicode an non-unicode?!

    Hello again,
    after implementing and testing this method, we saw that the conversion is always taken place in the unicode system.
    For examble: we have a char(35) field in mdmp with several japanese signs..as soon as we transfer the data into the file and have a look at it the binary data the field is only 28 chars long. several spaces are missing...now if we open the file in our unicode system using the mentioned class the size is gaining to 35 characters
    on the other hand if we export data from unicode system using this method the size is shrinking from 35 chars to 28 so the mdmp system can interprete the data.
    as soon as all systems are on unicode this method is obselete/wrong because we don't want to cut off/add the spaces..it's not needed anymore..
    the better way would be to create a "real" UTF-8 file in our MDMP system. The question is, is there a method to add somehow the missing spaces in the mdmp system?
    so it works something like thtat:
          OPEN DATASET p_file FOR OUTPUT IN TEXT MODE ENCODING UTF-8 WITH BYTE-ORDER MARK.
    "MDMP (with ECC 6.0 by the way)
    if charsize = 1.
    *add missing spaces to the structure
    *transfer strucutre to file
    *UNICODE
    else.
    *just transfer struc to file -> no conversion needed anymore
    endif.
    I thought mybe somehow this could work with the class CL_ABAP_CONV_OUT_CE. But until now I had no luck...
    Normally I would think that if I'am creating a UTF-8 file this work is done automatically on the transfer command

  • Unicode Open Dataset Question

    We are beginning to prepare for the Unicode enabling of our custom ABAP programs and I have a question about the new OPEN DATASET statement.  We have programs that write sequential files for use by the following:
    1) ABAP programs that execute on our own SAP system
    2) Non-SAP programs that execute in our data center
    3) Programs (which may or may not be SAP) that execute in the data centers of other completely independent companies.
    Conversely, we have programs that read files supplied by those systems. 
    After reading through a lot of information, I am reaching the conclusion that for our files that contain only character data, it would be safe for us to modify our OPEN DATASET statements simply to use u201COPEN DATASET IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORSu201D without attempting to be more explicit with some of the other options that are available. 
    Can any of you confirm that this is (or is not) a valid assumption?

    yes you can go ahead with that..for the text files and chardata files
    OPEN DATASET IN TEXT MODE ENCODING DEFAULT IGNORING CONVERSION ERRORSu201D

  • Unicode file formats ( open dataset)

    Hi,
    We are sending Unicode file with encoding as UTF-8( open dataset) containing Greek character to Legacy system. Legacy system( Sql server) is not able to understand this file format. As a workaround legacy side team coverts the file to Unicode UCS-2 using notepad ( by selecting encoding option as Unicode) and then uploading it to SQL server..
    Is there anyway to convert the UTF-8 file to other Unicode file format ( say UCS-2 )within SAP or generate the desired file format.

    Hi Martin,
    Thanks for the help!!!
    I tried  to convert the file format from UTF-8 to UCS-2  using the methods of the class mentioned but it didn't fulfill my requirement.  I have Greek character in UTF-8 format and when I convert it to any other other format then Greek character are displayed as #.
    Problem is legacy SQL server don't support UTF-8 format.  I tried open data set with binary mode & also legacy text mode with all available code pages but result were not fruitful.
    ( Program RSCP_CONVERT_FILE to convert code page - I used target code page as all possible UTF* , UCD* & Greek code page but no luck ).
    I am just wondering whether SAP can convert UTF-8 to UCS-2 or not. Other option I am thinking is to have the file converted by Unix script  that is application server external command which can be executed via FTP.

  • 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 (UNICODE) for english en polish characters

    Hi,
    I have a problem on my multi language project on where I need to manage English language and polish language.
    I have a table (that we can call TABLE) I manage the translation on it. When I am connected in English I can see some squares instead some polishes characters. When I am connected in polish, I have the right characters. Any way I don&#8217;t think it&#8217;s a problem, cause if I copy/paste the square on Word, I find back the corrects characters.
    My problem is after.
    I have a structure with the collon name and an internal table with data.
    I use the module function DDIF_TABL_GET on my table TABLE to have the collon name corresponding to the language wanted.
    I am building a string with that and some carry return.
    (Here in English I have again some square, but always the good character if I paste it on Words.)
    Now I would like to put this string in a file using the good encoding.
    I have tried lot of &#8216;opening dataset&#8217; and lot of &#8216;encoding&#8217;.
    I have a file on SAP (transaction FILE)
    (Here in English I have again some square, but always the good character if I paste it on Words.)
    If I download this file on my computer, I have wrong characters.
    Could I have help?
    My wrong code:
      OPEN DATASET lv_filename FOR OUTPUT IN TEXT MODE ENCODING UTF-8.
      TRANSFER u_contenu TO lv_filename.
      CLOSE DATASET lv_filename.

    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 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.

  • Runtime Error in OPEN DATASET

    Dear All,
    I am trying to upload a text file in application server. But I am getting the run time error which says-
    " For the statement
        "TRANSFER f TO ..."
    only character-type data objects are supported at the argument position
    "f".
    In this case. the operand "f" has the non-character-type "u". The
    current program is a Unicode program. In the Unicode context, the type
    'X' or structures containing not only character-type components are
    regarded as non-character-type."
    If I remove the quantity fields then the error does not happen. But I have to take quantity fields also. Plz tell me what to do. My code is,
    DATA FILENAME like rlgrap-filename VALUE 'MIGO_VALUE.txt'.
    TABLES VBAK.
    DATA D_MSG_TEXT(50).
    DATA : BEGIN OF it_mseg OCCURS 0,
           mblnr TYPE mseg-mblnr,
           mjahr TYPE mseg-mjahr,
           matnr TYPE mseg-matnr,
    *       erfmg TYPE mseg-erfmg,
           werks TYPE mseg-werks,
           lgort TYPE mseg-lgort,
           END OF it_mseg.
    DATA wa LIKE it_mseg.
    SELECT mblnr mjahr matnr werks lgort FROM mseg INTO CORRESPONDING FIELDS OF TABLE it_mseg WHERE bwart = '101'.
    SORT it_mseg BY mblnr.
    OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
                          MESSAGE D_MSG_TEXT.
    if sy-subrc eq 0.
    message 'File created succesfully in SAP System'(002) type 'S'.
    endif.
    IF SY-SUBRC NE 0.
      WRITE: 'File cannot be opened. Reason:', D_MSG_TEXT.
      EXIT.
    ENDIF.
    * Transferring Data
    LOOP AT it_mseg INTO wa.
    TRANSFER wa to filename.
    ENDLOOP.
    * Closing the File
    CLOSE DATASET FILENAME.
    Thanks,
    Tripod.

    Thanks Sri for your help. I tried to apply the logic, but the  error i am getting here is -
    "IT_MSEG-ERFMG" must be a character-like data object (data type C, N,D, T, or STRING) STRING).
    Same case here, if I remove ERFMG field, i do not get such error.
    data ld_string type string.
    LOOP AT it_mseg INTO wa.
      CONCATENATE it_mseg-mblnr it_mseg-mjahr it_mseg-matnr it_mseg-erfmg it_mseg-werks it_mseg-lgort INTO ld_string.
         endloop.
    With regards,
    Tripod.

  • Err with scheduling an abap program using open dataset

    issue: have an abap program which uses "open dataset ... for input ..." to read the file. 
    - with manual ly running it, receive the following message "dataset_not_open".  
    - with scheduling it, receive same message
    attempting to run an abap program as part of a process chain (ie scheduling a background job) in BI.
    the abap performs the following fxns:
    1) read a file on the server
    2) removes delimiter, renames it
    3) rewrites the file onto the server
    initially used ws_upload for reading and ws_download for writing the file. 
    - both fxns worked fine if it is run manually --> but failed as a  background (part of process chain)
    - note 7925 states can't use ws_upload, download for background jobs
    -so switched to "open dataset"
    Any suggestions as to why the "open dataset" does not work is greatly appreciated it.
    B.A.

    Thank you for all responses. here is more info about the err message:
    sy-subrc = 8
    'invalid argument'
    I looked up the invalid argument in note 99155 --> due to "The destination file is no longer available during repeated file access. "   So, the following steps were taken:
    - file was regenerated and
    - file was placed on the server to be read
    have the following code:
    OPEN DATASET FILENAME FOR OUTPUT IN TEXT MODE encoding default
                          MESSAGE D_MSG_TEXT.
    also have tried the following:
       OPEN DATASET d1 for input in text mode encoding default.
       open dataset d1 for output in text mode encoding NON-UNICODE..
       open dataset d1 for output in text mode  encoding utf-8.
    none had worked.  system --> status shows no unicode.
    THanks again for any suggestions.

Maybe you are looking for

  • Clusterware

    hi how to install oracle 10g release 2 clusterware on two nodes windows 2002 (32-bit) service pack2 and how can I configue it in order to do the failover, could any one help me please and provide me with all* steps clearly bye

  • N8 hang / boot failure / hard reset / missing stan...

    Recap: Phone hanged (won't boot) and I had to do a hard reset (volume down, camera, menu, power). After that some standard apps (Nokia Store, Social and QuickOffice wouldn't install). - Solution: Just reinstall Belle from Nokia Suite, then the standa

  • Apex_Item References don not work in operative application

    Good evening fellow Apex-Developers! I just started to import pages from a developer version into the operative version of an application. Everything seems to work except of the pages that contain reports with apex_item references in the queries. The

  • Inspection type problem

    Hi Sap Gurus, I copied 01 inspection type to Z013 inspection type and followed the following procedure. But while posting MIGO inspection lot is not getting created and stock is updating in unresticted use stock. But same material with 01 inspection

  • How can I turn off the new "tabs on top" layout of the new Firefox?

    Dear Mozilla, Te be honest I was very comfortable with the old Firefox layout and really don't like the new 'Tabs on Top' layout. It's one of the main reasons I hate Chrome. Is there any way I can turn it off? I haven't been able to find it. If not,