Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

FACING PROBLEM IN macro

Former Member
0 Likes
536

Hi Experts,

i am facing a problem while upgrading a 4.6c to ecc 6.1program. its a macro program. after checking unicode a error is coming like.IN TEXT MODE THE ENCODING ADDITION MUST BE SPECIFIED.

DEFINE m_open.

----


  • FORM F_DSOPEN_&1_&2 *

----


  • This is a macro to dynamically open unix files *

----


  • --> dsn *

  • --> type *

  • --> c *

----


form f_dsopen_&1_&2 using

p_xpath.

data msg(80).

open dataset p_xpath for &1 in &2 mode message msg.

if sy-subrc <> 0.

message e135(fr) with p_xpath msg.

endif.

endform.

END-OF-DEFINITION.

*----


m_open input text.----


ERROR.

m_open input binary.

m_open output text.

m_open output binary.

.

PLEASE TELL ME HOW CAN I RESOLVE IT.

Thanks & Regards

Pankaj Acharya

3 REPLIES 3
Read only

Former Member
0 Likes
492

the syntax for open dataset is wrong.u must include the encoding addition in the syntax.

regards,

pavan,

Read only

0 Likes
492

Hi,

The syntax is correct its a macro programming. through define and enddefine we r doing all the things.

Read only

Former Member
0 Likes
492

Hi,

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,

Omkar.