Copyright 2024 - BV TallVision IT

Unix and Windows/Dos are not aligned where text files are concerned - Unix systems have a single character end-of-line and Windows works with a 2-character end-of-line / carriage-return combination. Like the type-writer in the 40's. When your Unix file is to be processed in Windows or vice-versa, here's what you can do..

Unix or Unix-like systems  uses LF (Line feed, '\n', 0x0A, 10 in decimal) 
Windows/Dos system uses CR followed by LF (CR+LF or CRLF, '\r\n', 0x0D0A). The CR (Carriage return, '\r', 0x0D, 13 in decimal, displayed as "^M" in some editors)

 

The effect of processing Unix files under Windows is the concatenation of all textlines into a single line. The other way around - when a Windows file is opened in a Unix environment, the lines will still be in tact, but an additional character on each line may appear.

Create a Windows file from a Unix platform

You are creating a file for some outbound interface which is composed as a text file with text lines. The system SAP is running on is a Unix system so OPEN DATASET in text mode would create a file with LF characters to delimit a text line. Use the following OPEN DATASET option to create a file that can be moved to a Windows environment without conversion.

  OPEN DATASET '/usr/sap/DEV/SYS/work/myWindowsText.txt' 
    FOR OUTPUT IN TEXT MODE ENCODING DEFAULT
    WITH WINDOWS LINEFEED.

The content of the file can be read line-by-line, even though the actual file does not have the regular Unix text file style. 

Less likely but not impossible: you are operating SAP from a Windows platform and you want your file to be processed in Unix - the option would become WITH UNIX LINEFEED.

Windows file is used as input for Unix SAP platform

The same option can also be used to read files:

 OPEN DATASET '/usr/sap/DEV/SYS/work/myUnixText.text' 
    FOR INPUT IN TEXT MODE ENCODING DEFAULT
    WITH WINDOWS LINEFEED.

But wait, if it's reading a file, you can also specify WITH SMART LINEFEED, which will detect the EOL type that was used making your report support both types of text file.