Application Development 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: 

DATA TRANSFER - How to get a SINGLE SPACE in downloaded txt file from UNIX?

Former Member
0 Kudos

Hi Experts,

Am sending data from SAP to UNIX/ Application server and text file on desk top as well.

So, I am keeping a single character just SPACE at the END of each record.

Then, When I see the downloaded text file, I found a SINGLE SPACE at the end of each record, fine.

Then, by using CG3Y t code, I downloaded the UNIX file to my desk top.

But, When I see this UNIX downloaded file from UNIX, I did NOT find any SPACE at the end of each record!!!

Am doing every thing same in both cases.

So,

1 - Why its happening in case of UNIX file?

2 - How to get a SINGLE SPACE at the END in the downloaded file from UNIX?

thanq

1 ACCEPTED SOLUTION

amit_khare
Active Contributor
0 Kudos

While doing Open Dataset if you require Blank Space at the end of each Row use WINDOWS LINE FEED option with Open Dataset.

9 REPLIES 9

amit_khare
Active Contributor
0 Kudos

While doing Open Dataset if you require Blank Space at the end of each Row use WINDOWS LINE FEED option with Open Dataset.

0 Kudos

thanq

sorry, I did NOT understood ur reply, coz,

1 - Do U mean, WINDOWS LINE FEED = " | " ?

2- I did NOT find any like this option for OPEN DATASET syntax, when I press F1 help on OPEN DATA SET, there is NO such additions like LINE FEED or " | "

So, pls. eloborate in detail

thanq

0 Kudos

Its there, I am talking abut this -

OPEN DATASET - linefeed

Syntax

... WITH { NATIVE

| SMART

| UNIX

| WINDOWS } LINEFEED ... .

Alternatives:

1. ... WITH NATIVE LINEFEED

2. ... WITH SMART LINEFEED

3. ... WITH UNIX LINEFEED

4. ... WITH WINDOWS LINEFEED

Effect

: These additions determine which line end marker is used for text files or legacy text files. If these additions are used, the profile parameter abap/NTfmode is ignored. Simultaneous specification of the values "UNIX" or "NT" in the addition TYPE is not permitted.

If these additions are not used, the line end marker is determined as follows, depending on the operating system of the current application server:

The line end marker for Unix is "LF". Under Unix, OS390 and OS400, only "LF" is used for reading and writing.

The line end marker for MS Windows is "CRLF". Under MS Windows, however, the values of the profile parameter abap/NTfmode can also be used to set whether new files are handled according to Unix conventions or Windows conventions. If the profile parameter has the value "b", the Unix line end marker "LF" is used. If the profile parameter has the value "t" or is initial, the Windows line end marker "CRLF" is used. The setting using the profile parameter can be overridden with the addition TYPE and the value "UNIX" or "NT". If an existing file is opened without the addition TYPE, this is searched for the first line end marker ("LF" or "CRLF"), and this is used for the whole file. If no line end marker is found, the profile parameter is used. This applies particularly if an existing file is completely overwritten with FOR OUTPUT.

If an addition WITH NATIVE|SMART|UNIX|WINDOWS LINEFEED is used, this setting can be changed for the open file using the statement SET DATASET. If neither of the additions is used, the line end marker also cannot be changed using SET DATASET.

Notes

: Without the use of an addition WITH LINEFEED, the line end marker is dependent on diverse implicit factors such as the operating system of the application server, a profile parameter, and line end markings that are already used. For this reason, the explicit use of WITH LINEFEED is recommended, which renders the use of the addition TYPE for setting the line end marker obsolete.

The line end marker that is currently used can be determined for every open file using GET DATASET.

Alternative 1

... WITH NATIVE LINEFEED

Effect

: This addition defines the line end marker independently of the access type according to the operating system of the application server, i.e. "LF" for Unix OS390 or OS400, and "CRLF" for MS Windows.

The line end marker is interpreted according to the current codepage. If a code page is explicitly specified using the addition CODE PAGE, the characters of the line end marker must exist be available or be written in accordance with this code page.

Note

: The addition WITH NATIVE LINEFEED is intended for editing files on an application server that can also be accessed by other means. The addition receives the appropriate line end marker without the program needing to know the operating system.

Alternative 2

... WITH SMART LINEFEED

Effect

: This addition depends on the access type:

In files that are opened for reading using FOR INPUT, both "LF" and "CRLF are interpreted as a line end marker. When opening an EBCDIC file with the addition CODEPAGE, in addition to "LF", "CRLF", and the EBCDIC character strings, the corresponding ASCII character strings are also recognized. In addition, the EBCDIC character "NL" (line separator) is also interpreted as a line end marker.

In files opened for appending or changing with FOR APPENDING or FOR UPDATE, the program searches for a line end marker that is already used in the file. In this process, first the end of the file is identified. If no line end marker is found there, a certain number of characters at the beginning is analyzed. If a line end marker is found, this is used when writing to the file. This is also affected by the addition CODE PAGE. For example, ASCII line end markers are recognized and used in a file opened with EBCDIC, but not the other way round. If no line end marker is found or no search is possible (for example, if the file is opened with the addition FILTER), the line end marker is determined according to the operating system of the application server, as with the addition WITH NATIVE LINEFEED.

In files opened for writing using FOR OUTPUT, the line end marker is determined according the operating system of the application server, as with the addition WITH NATIVE LINEFEED.

Note

: The addition WITH SMART LINEFEED is intended for the generic editing of files in heterogeneous environments. The line end marker is recognized and set for different formats. The use of this addition is the best solution for most application cases.

Alternative 3

... WITH UNIX LINEFEED

Effect

: The line end marker is set to "LF" regardless of the access type and operating system of the application server.

The line end marker is interpreted according to the current code page. If a code page is specified explicitly using the addition CODE PAGE, the characters of the line end marker must be available or be written according to this code page.

Note

: The addition WITH UNIX LINEFEED is intended for editing Unix files in which the specific line end markers are to be retained, even if the operating system of the current application server is MS Windows.

Alternative 4

... WITH WINDOWS LINEFEED

Effect

: The line end marker is set to "CRLF" regardless of the access type and operating system of the application server.

The line end marker is interpreted according to the current code page. If a code page is specified explicitly using the addition CODE PAGE, the characters of the line end marker must be available and be written according to this code page.

Note

: The addition WITH WINDOWS LINEFEED is intended for use with MS Windows files in which the specific line end marker is to be retained, even if the operating system of the current application server is Unix, OS390 or OS400.

0 Kudos

thanq

sorry as I need to fix this issue very urgently, pls. let me know the syntax, my prog. details r,

I used syntax OPEN DATASET my_dsn FOR OUTPUT IN TEXT MODE ENCODING DEFAULT

Ours is UNIX, 4.6C SAP

so, pls. let me the FULL syntax with CORRECT addition for my requirement,

actually, i tried like OPEN DATASET with unix linefeed, but getting SYNTAX error and I culd not able to find F1 help on this!!

thanq

Edited by: Srinivas on May 20, 2008 7:23 AM

0 Kudos

Then directly use this code to append with each line of record -

DATA: LF TYPE X VALUE '0A'.

CONCATENATE WA_LINES LF INTO WA_LINES.

0 Kudos

thanq

I tried with suggestion of another expert in another thread, but, am getting syntax errorr saying that,

IF I USE CONCATENATE, the LF SHULD BE A CHARACTER TYPE, not " X " type

so, pls. let me know alterative, it bcom urgent for me

thanq

0 Kudos

check this class -CL_ABAP_CHAR_UTILITIES=>CR_LF

0 Kudos

thanq

some way, its working, some way NOT, coz, am getting one TOTAL BLANK LINE alternatively, like, my text pad is,

KNEE RT-MODULAR 5610930081L RT Modular Fem/Block/Schaft L 5610930069L TC Plus rechts (Tray 1) 999.000

KNEE RT-MODULAR 5610930081L RT Modular Fem/Block/Schaft L 72200902 8.5X90MM CLEARTRAC CANNULA, TH888.000

KNEE RT-MODULAR 5610930081L RT Modular Fem/Block/Schaft L 75000296 PLUSTC Fixed Tibl INSRT VKS CR777.000

So, Is it possible, TO REMOVE the occuring BLANK line in btwn 2 filled lines?

thanq

0 Kudos

thanq worked out.

I used SHIFT LEFT BY z PLACE instaed of SHIFT LEFT DELETING LEADFING SPACE for QUANTITY field

than