Specifying Text Mode
To process a file in text mode, use the IN TEXT MODE option of the OPEN DATASET statement as follows:
Syntax
OPEN DATASET <dsn> FOR.... IN TEXT MODE.
If you read data from a file or write data to a file that is opened in text mode, the data is transmitted line by line. The system assumes that the file has a line structure.
You should use the text mode if you want to write character strings to files or if you know that an existing file is formatted on a line basis. With text mode, you can read, for example, files that were created with an arbitrary text editor on your application server.

The following demonstration program is written for SAP Systems running on UNIX systems that use an ASCII representation.
DATA FNAME(60) VALUE 'myfile'.
DATA: TEXT(4),
HEX TYPE X.
OPEN DATASET FNAME FOR OUTPUT IN TEXT MODE.
TRANSFER '12 ' TO FNAME.
TRANSFER '123456 9 ' TO FNAME.
TRANSFER '1234 ' TO FNAME.
OPEN DATASET FNAME FOR INPUT IN TEXT MODE.
READ DATASET FNAME INTO TEXT.
WRITE / TEXT.
READ DATASET FNAME INTO TEXT.
WRITE TEXT.
READ DATASET FNAME INTO TEXT.
WRITE TEXT.
OPEN DATASET FNAME FOR INPUT IN BINARY MODE.
SKIP.
DO.
READ DATASET FNAME INTO HEX.
If SY-SUBRC <> 0.
EXIT.
ENDIF.
WRITE HEX.
ENDDO.
The output of this program appears as follows:
12 1234 1234
31 32 0A 31 32 33 34 35 36 20 20 39 0A 31 32 33 34 0A
In this example, a file "myfile" is opened for writing in text mode. Three string literals, each of length 10, are transferred to the file. After opening the file for reading in text mode, the stored lines are read into field TEXT of length 4. The first line is filled with two blanks from the right. The last five positions of the second line are truncated. Opening the file in binary mode and reading it into the hexadecimal field HEX shows its actual structure: The numbers between 31 and 36 are the ASCII representations of the numeric characters 1 to 6, while 20 represents the space character. The end of each line is marked by 0A. Note that the trailing spaces of the string literals are not written to the file.