08-10-2011 4:09 PM
Hi ABAP Gurus,
how to get HEX 000D = 13 = <CR> out of a CHAR ?
Thank You
Martin
08-10-2011 4:32 PM
Hi Martin,
the CR character is defined by CL_ABAP_CHAR_UTILITIES=>CR_LF(1) (note that CR is the first character of the 2 of that constant)
and then you use something like FIND or SPLIT using that constant
BR
Sandra
08-11-2011 8:18 AM
Hello Sandra,
sorry, but I really do not understand this.
Best Wishes
Martin
08-11-2011 9:50 AM
Hello,
Example, that will write "D e a r M a r t i n" only because it stops at the first CR control character:
DATA l_clike TYPE c LENGTH 100.
CONCATENATE ' Dear Martin,' '...' 'Best regards,' 'Sandra'
INTO l_clike SEPARATED BY cl_abap_char_utilities=>cr_lf(1).
DO.
IF l_clike+sy-index(1) = cl_abap_char_utilities=>cr_lf(1).
EXIT.
ENDIF.
WRITE l_clike+sy-index(1).
ENDDO.
If it's not what you expect, then please provide an example too, thanks
Sandra
08-11-2011 10:33 AM
08-11-2011 10:34 AM
Hi,
if you want to replace this character, check this:
REPORT ZMYTEST .
data: mycharfield(20).
concatenate 'line1' cl_abap_char_utilities=>cr_lf(1) 'line2'
cl_abap_char_utilities=>cr_lf(1) 'line3'
into mycharfield.
write: /1 mycharfield.
replace all occurrences of cl_abap_char_utilities=>cr_lf(1)
in mycharfield with space.
write: /1 mycharfield.
Regards,
Klaus
08-16-2011 2:27 PM
Hi Sandra, Claus,
I let run Your versions against my version for 80.000 DS in SAP/BI and yours was 10 % slower ;).
Thank You
Best Wishes
Martin
Conventional SAP BI Version:
DATA l_allowed_char type rsallowedchar-allowchar.
DATA count TYPE i.
IF l_allowed_char IS INITIAL.
CALL FUNCTION 'RSKC_ALLOWED_CHAR_GET'
IMPORTING
E_ALLOWED_CHAR = l_allowed_char
* E_DEFAULT_CHAR =
* E_USERDEF_CHAR =
.
ENDIF.
RESULT = SOURCE_FIELDS-SGTXT.
CLEAR count.
WHILE count < 50.
IF NOT RESULTcount(1) CO l_allowed_char.+
CLEAR RESULTcount(1).+
ENDIF.
+count = count + 1.+
ENDWHILE.
08-16-2011 2:59 PM
Hi Martin,
Hey, we could not defend ourselves, because we had not the whole context, and I didn't even understand that you wanted a REPLACE "CR" BY "nothing" (which in fact became REPLACE "BI unauthorized chars" BY "space")!
Anyway, I don't think I can do better than your version.
Sandra
08-16-2011 3:02 PM
Hi Sandra,
sure, but in SDN a question must be placed as simpliefied and as broken down as possible.
No one is reading more than the first line of an email .....
I got to know there is a world besides ABAL 4GL
Thank You anyhow.
Martin
08-16-2011 3:41 PM
Hi guys,
I beleive Martin is looking for faster way to replace and remove CR value.
Try something like this:
FIELD-SYMBOLS:
<bytes> TYPE x.
CONSTANTS:
cr TYPE x LENGTH 2 VALUE '0D00', "Unicode CR
rc TYPE x LENGTH 2 VALUE '2000'. "Unicode RC - Replace Char in this case SPACE
DATA:
result TYPE char50.
CONCATENATE
'THIS is a Test'
cl_abap_char_utilities=>cr_lf
'for Martin'
INTO result SEPARATED BY space.
WRITE: / result.
ASSIGN result TO <bytes> CASTING TYPE x.
REPLACE ALL OCCURRENCES OF cr IN <bytes> WITH rc IN BYTE MODE.
WRITE: / result.
Regards,
Igor.
10-09-2015 1:37 PM
Hi
check in debugging
if hex value for # is 000D
then use:
REPLACE ALL OCCURANCE OF cl_abap_char_utilities=>cr_lf(1) IN string WITH space.
if hex value is 000A
then use:
REPLACE ALL OCCURANCE OF cl_abap_char_utilities=>cr_lf+1(1) IN string WITH space.
similary you can check for HORIZONTAL_TAB, VERTICAL_TAB etc.
hope this help
Regards
06-22-2021 1:33 AM