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: 

Sequential ASCII file with carriage return line feed at end of each record

madhu_reddy22
Participant
0 Kudos
589

Hi,

I have a requirement to create an outbound interface with 'Sequential ASCII file with carriage return line feed at end of each record'. I have created the interface with OPEN DATASET, TRANSER and CLOSE DATASET. What does carriage return line feed mean? How are we supposed to include the carriage return line feed at the end of each record.

I am looping at the internal table to transfer all the records to the file on the app server.

loop at i_file into wa_file.

transfer wa_file.

endloop.

Thanks in advance.

Madhu

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos
136

Hello,

You have to use the constant CL_ABAP_CHAR_UTILITIES=>CR_LF for this purpose.

Try like this:

DATA : 
L_V_FILE TYPE  STRING,
l_v_crlf TYPE char2.

l_v_crlf = CL_ABAP_CHAR_UTILITIES=>CR_LF.

loop at i_file into wa_file.

MOVE wa_file TO l_v_file_data.

CONCATENATE l_v_file_data l_v_crlf INTO l_v_file_data.

TRANSFER l_v_file_data.
" transfer wa_file.

CLEAR l_v_file_data.
endloop.

BR,

Suhas

7 REPLIES 7

former_member435013
Active Participant
0 Kudos
136

Hi,

it is general knowledge for IT-professionals.

Line ending in text files under Windows - former DOS - is encoded with carriage return + line feed.

Line ending in text files under Unix and related OS is encoded with only line feed.

SAP running with an operating system below behaves anologously.

You should simply check out your resulting file with an appropiate hex editor.

Carriage return (CR) is 13 decimal coded respective 0D hex coded

Line feed (LF) is 10 decimal coded respective 0A hey coded

Pay attention, when transfer files from one compurter to another for instance by FTP.

You may choose ascii or binary mode. Binary mode does not change line end coding but ascii mode does.

Hope this helps!

Regards

Walter Habich

SuhaSaha
Advisor
Advisor
0 Kudos
137

Hello,

You have to use the constant CL_ABAP_CHAR_UTILITIES=>CR_LF for this purpose.

Try like this:

DATA : 
L_V_FILE TYPE  STRING,
l_v_crlf TYPE char2.

l_v_crlf = CL_ABAP_CHAR_UTILITIES=>CR_LF.

loop at i_file into wa_file.

MOVE wa_file TO l_v_file_data.

CONCATENATE l_v_file_data l_v_crlf INTO l_v_file_data.

TRANSFER l_v_file_data.
" transfer wa_file.

CLEAR l_v_file_data.
endloop.

BR,

Suhas

0 Kudos
136

Hi,

I have included the code . When I check the file in the app server I find a # at the end of each record.

Does it imply that I have a carriage return line feed at the end of each record?

Can we upload # as a character at the end of each record and say that it is a carriage return line feed?

I am not able to understand it practically.

Thanks in advance,

Madhu

Former Member
0 Kudos
136

>

> I have included the code .

What does it look like if you don't include the code?

Rob

0 Kudos
136

If I do not use the code for the carriage return line feed I do not get a # at the end of each record.

If the code is included I get a hash, but if the last few characters in the record are empty then the # does not come after the spaces. Instead it appears at the end of the last non-empty character. I want to have it at the end of the spaces.

Thank you,

Madhu

0 Kudos
136

Hi, have the code with carriage return and dont go with the view in AL11 it compresses files and shows a display, keep the code for carriage return and download the file using Tr. CG3Y or CG3Z.

0 Kudos
136

This is a helpful answer. I had same issue as my FTP server's OS change to New Unix. I had same issue. I read this post and get solution.

Thank you.

Nayan Lad