12-13-2011 1:05 PM
When I store a certain text in variable p_texto -> FIND FIRST OCURRENCE is ok; sy-subrc = 0.
When Instead of assigning a text I read a long text from an excel into p_texto variable ->
FIND FIRST OCURRENCE is not working; sy-subrc = 4.
DATA: p_texto(5000).
DATA: posicion TYPE match_result.
p_texto = 'HI THIS IS THE FIRST LINE#AND THIS ONE THE SECOND LINE'.
FIND FIRST OCCURRENCE OF '#' IN p_texto RESULTS posicion.
How could I manage this problem?
Thank you very much in advance.
12-13-2011 1:12 PM
Hi Jarizkuren ,
in your text, string "#" is the rapresentation of characters that cannot be displayed in sap.
Probably you should search for
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
CL_ABAP_CHAR_UTILITIES=>NEWLINE
CL_ABAP_CHAR_UTILITIES=>CR_LF
regards
Andrea
12-13-2011 1:12 PM
Hi Jarizkuren ,
in your text, string "#" is the rapresentation of characters that cannot be displayed in sap.
Probably you should search for
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB
CL_ABAP_CHAR_UTILITIES=>NEWLINE
CL_ABAP_CHAR_UTILITIES=>CR_LF
regards
Andrea
12-13-2011 1:20 PM
That´s not my question. My doubt is why it works when I write a short text but it does´nt work when using a very long text.
12-13-2011 1:23 PM
12-13-2011 1:27 PM
do you mean if I execute this code?
p_texto = 'HI THIS IS THE FIRST LINE#AND THIS ONE THE SECOND LINE'.
FIND FIRST OCCURRENCE OF 'LINE' IN p_texto RESULTS posicion.
Yes, sy-subrc = 0. -> It´s working properly.
12-13-2011 1:32 PM
As I told you before, the problem is not the length of the line.
The problem is that you see in your variable "#", but it is not "#". It could be a carriage return, a tabulator or other character that doesn't know how to display.
In my opinion you should search for cl_abap_char_utilities=>newline.
Regards
Andrea
12-14-2011 9:21 AM
Hi!!
Thank´s. I have tried with cl_abap_char_utilities=>newline.
and now it´s working.
Thanks a lot.
12-13-2011 1:57 PM
HI Jari,
I think you can try using FIND FIRST OCCURANCE......IN BYTE MODE instead of default character mode.
And for this, the pattern you are searching and the data object from you want to search has to be Byte-Like.
Thanks,
Anishek Kumar