9 Replies Latest reply: Mar 11, 2008 2:19 AM by S S RSS

Difference between IN LEGACY TEXT MODE & TEXT MODE ENCODING NON-UNICODE

H. M.
Currently Being Moderated

Hi,

 

We're upgrading to ECC5 and the 'open dataset' command needs amending if the program is flagged for Unicode (which usually occurrs in user/fm exits). Therefore is ECC5 this command is no longer valid:

"open dataset DSN in text mode"

 

We currently interface with systems that may not have unicode enabled. Yet we have not enabled unicode in our own system just yet.

So we think these two commands are the most approriate for replacing the 'old' open dataset command:

"open dataset DSN for input in TEXT MODE encoding NON-UNICODE"

"open dataset DSN in LEGACY TEXT MODE for input"

 

However we're not really sure what the difference between these two commands is?

Has anyone worked with these commands?

Could you offer some help as to their differences and when each should be used?

 

Many thanks!

  • Re: Difference between IN LEGACY TEXT MODE & TEXT MODE ENCODING NON-UNICODE
    Harikishore Sreenivasuau
    Currently Being Moderated

    The LEGACY MODE allows you to read files that were written before Release 6.10.

  • Re: Difference between IN LEGACY TEXT MODE & TEXT MODE ENCODING NON-UNICODE
    Ravi Kanth Talagana
    Currently Being Moderated

    Hi Robert,

       Here is an excerpt from sap documentation.

     

    ... TEXT MODE ENCODING {DEFAULT|UTF-8|NON-UNICODE}

     

     

     

     

    Effect:

    The addition IN TEXT MODE opens the file as a text file. The addition ENCODING defines how the characters are represented in the text file. When writing in a text file, the content of a data object is converted to the representation entered after ENCODING, and transferred to the file. If the data type is character-type and flat, trailing blanks are cut off. In the data type string, trailing blanks are not cut off. The end-of-line marking of the relevant platform is applied to the transferred data by default. When reading from a text file, the content of the file is read until the next end-of-line marking, converted from the format specified after ENCODING into the current character format, and transferred to a data object.

     

    The end-of-line marking depends on the operating system of the application server. In the MS Windows operating systems, the markings "CRLF" and " LF" are possible, while under Unix, only "LF" is used. If, when using Windows, an existing file is opened without the TYPE addition (see os_addition), the first end-of-line marking is found and used for the whole file. If a new file is created without the TYPE addition, the content of the profile parameter abap/NTfmode is used. If the profile parameter is not set, "CRLF" is used. If a file with the TYPE addition is opened and a valid value is contained in attr, this value is used.

     

    In Unicode programs, only the content of character-type data objects can be transferred to text files and read from text files. The addition ENCODING must be specified in Unicode programs, and can only be omitted in non-Unicode programs.

     

    The additions after ENCODING determine in which character representation the content of the file is handled.

     

    DEFAULT

    In a Unicode system, the designation DEFAULT corresponds to the designation UTF-8, and the designation NON-UNICODE in a non-Unicode system.

     

     

    UTF-8

    The characters in the file are handled according to the Unicode character representation UTF-8.

     

     

    NON-UNICODE

    In a non-Unicode system, the data is read or written without being converted. In a Unicode system,the characters in the file are handled according to the non-Unicode-codepage that would be assigned to the current text environment according to the database table TCP0C, at the time of reading or writing in a non-Unicode system.

     

    If the addition ENCODING is not specified in non-Unicode programs, the addition NON-UNICODE is used implicitly.

     

     

    ... LEGACY TEXT MODE [{BIG|LITTLE} ENDIAN] [CODE PAGE cp]

     

     

     

     

    Effect:

    Opening a Legacyfile. The addition IN LEGACY TEXT MODE opens the file as a legacy text file. As with legacy binary files, the byte order and the codepage with which the content of the file should be handled can also be specified. The syntax and meaning of {BIG|LITTLE} ENDIAN and CODE PAGE cp are the same as for legacy binary files.

     

    In contrast to legacy binary files, the trailing blanks in a legacy file are cut off when writing character-type flat data objects in a legacy text file. As for a text file, an end-of-line marking is also applied to the transferred data. In contrast to text files opened with the addition INTEXT MODE, Unicode programs do not check whether the data objects used for reading or writing are character-type. Furthermore, the LENGTH additions of the statements READ DATASET and TRANSFER are used for counting in bytes in legacy text files and in the units of a character represented in the memory for text files.

     

     

     

    Note:

    As with legacy binary files, text files that have been written in a non-Unicode system can be accessed in Unicode systems as legacy text files, and the content is converted accordingly.

     

     

     

    Example

    A file test.dat is created as a text file, filled with data, changed, and exported. As every TRANSFER statement applies end-of-line marking to written content, after the change, the content of the file has two lines. The first line contains "12ABCD". The second line contains "890". The character "7" has been overwritten by the end-of-line marking of the first line.

     

    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

                                 AT POSITION 2.

    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,

    Ravi

Actions