03-01-2013 3:26 PM
I have a Program that downloads a file using TRANSFER statement. When I use the method,
CL_ABAP_CHAR_UTILITIES=>cr_lf, it writes "CR LF" at the end of the file when viewed in notepad. Is there a way or any field in the method that I can use for having just "CR" at the end of each line of the file?
Here is part of the code...
DATA: BEGIN OF TREC,
STRING(299),
CARRIAGE_RETURN(1) TYPE c,
END OF TREC.
LOOP AT TEMPTEST INTO TEMPTEST.
MOVE TEMPTEST-FLD001 TO TREC-STRING+0(1).
MOVE TEMPTEST-FLD002 TO TREC-STRING+1(3).
MOVE TEMPTEST-FLD003 TO TREC-STRING+4(2).
MOVE TEMPTEST-FLD004 TO TREC-STRING+6(10).
MOVE TEMPTEST-FLD005 TO TREC-STRING+16(1).
MOVE TEMPTEST-FLD006 TO TREC-STRING+17(1).
MOVE TEMPTEST-FLD007 TO TREC-STRING+18(1).
MOVE TEMPTEST-FLD008 TO TREC-STRING+19(1).
MOVE TEMPTEST-FLD009 TO TREC-STRING+20(10).
MOVE TEMPTEST-FLD010 TO TREC-STRING+30(10).
MOVE TEMPTEST-FLD011 TO TREC-STRING+40(6).
MOVE TEMPTEST-FLD012 TO TREC-STRING+46(35).
MOVE TEMPTEST-FLD013 TO TREC-STRING+81(21).
MOVE TEMPTEST-FLD014 TO TREC-STRING+100(198).
MOVE CL_ABAP_CHAR_UTILITIES=>cr_lf TO TREC-CARRIAGE_RETURN.
TRANSFER TREC TO PI_A_FILENAME LENGTH 300 NO END OF LINE.
ENDLOOP.
Thanks!
03-01-2013 3:43 PM
03-01-2013 3:53 PM
03-01-2013 4:31 PM
Dear Anjana,
Above code Transfers the data to application server right?
On application server what do you server?
Thanks & Regards,
Vignesh Yeram
03-01-2013 4:41 PM
Dear Anjana,
Above code Transfers the data to application server right?
On application server how the character is shown?
because i checked the class
constants cr_lf type abap_cr_lf value %_cr_lf.
abap_cr_lf(2) type c,
So its a two character.
Please try downloading the file in Notepad ++
Kindly let me know your feedback.
Thanks & Regards,
Vignesh Yeram
03-01-2013 4:51 PM
Hi Vignesh,
Yes, the TRANSFER statement is downloading the file to a server which is AS/400. There it does not show any characters. I then download the file to Notepad++ using a software that we have and that is where I see the CR LF.
Making it two character did not work either.
I only made it one character hoping that it would eliminate the LF. Making it two character did not work either.
I also tried using,
CALL FUNCTION 'FI_DME_CHARACTERS'
IMPORTING
e_cr = hlp_cr.
MOVE HLP_CR TO TREC-CARRIAGE_RETURN.
That did not work either. It still shows up as, CR LF.
Thanks!
03-01-2013 5:07 PM
Dear Anjana,
Please try to remove the field carraige_return.
then try with below options:-
1) MOVE CL_ABAP_CHAR_UTILITIES=>cr_lf TO TREC-STRING+298(2).
2) MOVE 'CR' to TREC-STRING+298(2).
Kindly let me know your feedback.
Thanks & Regards,
Vignesh Yeram
03-01-2013 5:25 PM
Hi Vignesh,
They did not work....
The solution,
1) MOVE CL_ABAP_CHAR_UTILITIES=>cr_lf TO TREC-STRING+298(2).
gave the same result with CRLF in the file.
Solution,
2) MOVE 'CR' to TREC-STRING+298(2).
physically put the character 'CR' in the file with no carriage return which is not the intended result.
Thanks!
03-01-2013 4:46 PM
Hi,
DATA: BEGIN OF TREC,
STRING(299),
CARRIAGE_RETURN(1) TYPE c, --->instead of this try this
crlf(1) type c value cl_abap_char_utilities=>CR_LF,
END OF TREC.
and no need to do
MOVE CL_ABAP_CHAR_UTILITIES=>cr_lf TO TREC-CARRIAGE_RETURN. in the loop.
try and let me know
Thanks
03-01-2013 4:55 PM
Hi Sukumar,
That solution does the same and puts the CRLF in the file.
Thanks!
03-01-2013 7:17 PM
Hi Anjana,
Maybe you could try a bit of work around
CONSTANTS: CR TYPE CHAR1 VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF. "CR
or
DATA CR TYPE CHAR1.
CR = CL_ABAP_CHAR_UTILITIES=>CR_LF.
MOVE CR TO TREC-CARRIAGE_RETURN.
03-01-2013 7:54 PM
03-01-2013 7:34 PM
What if you replace CL_ABAP_CHAR_UTILITIES=>CR_LF by CL_ABAP_CHAR_UTILITIES=>NEWLINE ?
Regards,
Raymond
03-01-2013 7:56 PM
03-02-2013 10:21 AM
03-04-2013 7:13 PM
Raymond,
Here is the OPEN DATASET code in the Program.
OPEN DATASET PI_A_FILENAME
FOR OUTPUT
IN TEXT MODE
MESSAGE S_L-MSG ENCODING
DEFAULT.
I have tried using LEGACY TEXT MODE and that did not work either.
03-01-2013 8:52 PM
Try '\r' at the end of the line
MOVE '\r' TO TREC-CARRIAGE_RETURN.
03-04-2013 8:48 PM
Hello Anjana,
with reference to the online documentation I would not expect an easy possiblity to achieve CR in combination with TRANSFER.
I assume opening the data set in BINARY MODE and doing all the conversions (incl. control chars) own your own shall do.
Regards
Klaus
06-13-2019 8:46 PM
for CR
cl_abap_char_utilities=>NEWLINE
for LF
cl_abap_char_utilities=>FORM_FEED
06-14-2019 9:28 AM
Wrong.
Unicode characters are:
CARRIAGE RETURN/CR = U+000D
NEWLINE/LINEFEED/LF = U+000A
FORMFEED/FF = U+000C
Pawan Kesari gave the right answer, but was rejected by the OP because the problem is mixed with TRANSFER (write to file) and potential human error for checking the file contents.