‎2011 Sep 20 2:49 PM
I have one code where I have to Seprate a string in lines based on Pattern '#'.
EG: first line##second line##third line.
output should be :
first line
second line
third line
do.
SEARCH content for '#'.
find hash in content.
if sy-subrc = 4.
gfs_content-content = content.
APPEND gfs_content TO git_content.
clear gfs_content.
exit.
else.
gfs_content-content = content+0(sy-fdpos).
APPEND gfs_content TO git_content.
clear gfs_content.
loc_count = sy-fdpos + 2.
SHIFT content BY loc_count PLACES.
endif.
enddo.
when I am changing the content value in Debugger, this code is working fine. but when I am executing it directly without any change in value in debugger, Sy-subrc = 4 after SEARCH operation. Its not finding the "#" position.
What could be the possible reason.
‎2011 Sep 20 2:57 PM
The SEARCH statement is obsolete, i´d try using the followup statement called FIND.
Hopefully this will work out like you need it.
‎2011 Sep 20 3:03 PM
‎2011 Sep 20 3:11 PM
I guess you are trying to find the newline character. If that's the case you should use CL_ABAP_CHAR_UTILITIES=>CR_LF instead of '#'.
By the way, may be this piece of code is more suitable for what you are trying to do:
SPLIT content AT CL_ABAP_CHAR_UTILITIES=>CR_LF INTO TABLE GFS_CONTENT.
‎2011 Sep 20 3:18 PM
@@Arseni thanks a lot.....it worked....excellent solution....
Edited by: abhi1185 on Sep 20, 2011 4:18 PM
‎2011 Sep 20 3:27 PM
<removed by moderator>
Moderator message: please leave this reminder to the moderators.
Edited by: Thomas Zloch on Sep 20, 2011 8:33 PM