Carriage Return and Line Feed in ABAP
Carriage return and line feed combination separates lines in the ABAP text editor control and some other custom controls. In some other programming language like Java, these special characters are represented by escape characters.
Escape characters are part of the syntax for many programming languages, data formats and communication protocols. For a given alphabet an escape character’s purpose is to start character sequences (so named escape sequences) which have to be interpreted differently from the same characters occurring alone. An escape character may not have its own meaning, so all escape sequences are of 2 or more characters.
In ABAP language, these is no escape character syntax. If we debug the input string of text editor, the carriage return and line feed character is displayed as ‘##’. But if use below statement to separate the string, it will not work. Because ABAP uses character ‘#’ to represent invisible character.
REPLACE '##' with ' ' INTO LS_STRING.
SAP provides class CL_ABAP_CHAR_UTILITIES which is the standard utility class for processing characters. This is a constant in this class named CR_LF which represents carriage return and line feed. Below code snippet can be used to add carriage return and line feed into strings.
DATA: crlf(2) TYPE c. DATA: l_html(4096) TYPE C. crlf = cl_abap_char_utilities=>;cr_lf. CONCATENATE l_html crlf '_FUNCTION' '30' 'WWW_GET_REPORT' INTO l_html.
Thanks so much. I’ve been looking for this for days.
Mike
Hi! nice bit of code, however i am trying to use this in Split by, but very unsuccessful!!
this does not work for me…
SPLIT file_upload_itm-ltxa1 at cl_abap_char_utilities=>cr_lf into: str1 str2.
any pointers on splitting a string by CR_LF??
Works like a charm! thanks!
@Asim
Thanks~
thanx a lot, it works perfect…!!!
Hi Andy,
Thanks a lot for this information. I was stuck on this for many days due to dmee file generation with CR_LF.
Kind Regards,
Pritish