‎2006 Oct 04 1:00 PM
Hi Experts,
i have a string like this.
str = '00000003379#212RegVNegNoticeHLA.aspx.xml' So i want to read n.of characters from # to begin of the string. ie 00000003379#.The value for str will come dinamically.How can we do this?
Regards
‎2006 Oct 04 1:08 PM
lstr --> is your string
split lstr at '#' into lval lfile.
llen = strlen( lval ) + 1. (1 is to include the count for #).
Regards
Anurag
‎2006 Oct 04 1:02 PM
Hi Ravi,
Try the "Split" statement :
split str at '#' into w_rec01 w_rec02.Best Regards,
Erwan
‎2006 Oct 04 1:06 PM
1. Split the string at symbol # and store it in a variable
2. find the length of the string variable
regards
vivek
award points if this helps
‎2007 Sep 03 9:33 AM
Hi Experts
I have one long string and from which i should take only last 4 chars
how to do it
please tell me
rajesh
‎2006 Oct 04 1:03 PM
Hello Ravi,
Use this code.
DATA: STR1 TYPE STRING,
STR2 TYPE STRING.
SPLIT STR AT '#' INTO STR1 STR2.
CONCATENATE STR1 '#' INTO STR1.
write: STR1.
If useful reward.
Vasanth
‎2006 Oct 04 1:16 PM
Hi,
Thanks for replies.
Problem is i am gettin value for str in debugging like this.
str = 00000003758#Account_Agreements-Combination.aspx.xml #
So at the end some where i am getting one more #.
‎2006 Oct 04 1:19 PM
str = 00000003758#Account_Agreements-Combination.aspx.xml #
v_len = strlen( str ).
v_len = v_len - 1.
str = str+0(v_len).
now use split at #
split str at '#' into v_num v_new.
Regards,
Ravi
‎2006 Oct 04 1:20 PM
ok , if you are uploading it from an excel file you will get that # at last , so add 3 more line to remove that
len = strlen( str ).
len = len - 1.
str = str+0(len).so this will remove the last # from str
‎2006 Oct 04 1:30 PM
what if the second '#' is somewhere in between & not always at the end?
you can use the following to cover that scenario..
report zp_string.
data w_str type
string value '00000003758#Account_Agre#ements-#Combination.aspx.xml #'.
data w_len type i.
data: w_str2 type string.
search w_str for '#' and mark.
w_len = sy-fdpos.
w_str2 = w_str+0(w_len).
write:/ w_str.
write:/ w_str2.~Suresh
‎2006 Oct 04 1:33 PM
Hi Ravi,
You may n no of #'s in your line. To get length of string upto last '#' then try with this code.
DATA: L_LOC TYPE I,
L_LNG TYPE I,
L_CMD TYPE STRING,
L_FIL TYPE STRING,
STR TYPE STRING.
L_LENGTH = STRLEN( STR ).
L_LOC = 1.
WHILE SY-SUBRC = 0.
SEARCH STR FOR '#' STARTING AT L_LOC.
IF SY-FDPOS > 0.
ADD SY-FDPOS TO L_LOC.
L_CMD = STR(L_LOC).
L_LNG = L_LENGTH - L_LOC.
L_FIL = STR+L_LOC(L_LNG).
ELSE.
ADD 1 TO L_LOC.
ENDIF.
ENDWHILE.
WRITE:/ 'Length of string upto last # is ', L_LOC.
Thanks,
Vinay
‎2006 Oct 04 2:23 PM
‎2006 Oct 04 1:07 PM
hi,
try this.
SEARCH string for '#'.
l_from = sy-fdpos - 1.
search string for '#' starting at l_from.
l_to = sy-fdpos - 1.
l_len = l_to - l_from.
v_cutout = string+l_from(l_len).
Regards,
anver
‎2006 Oct 04 1:08 PM
lstr --> is your string
split lstr at '#' into lval lfile.
llen = strlen( lval ) + 1. (1 is to include the count for #).
Regards
Anurag
‎2006 Oct 04 1:10 PM
Hi Ravi,
chk this
REPORT YCHATEST.
DATA : STR TYPE STRING,
STR1 TYPE STRING,
STR2 TYPE STRING,
LEN TYPE I.
STR = '00000003379#212RegVNegNoticeHLA.aspx.xml'.
SPLIT STR AT '#' INTO STR1 STR2.
LEN = STRLEN( STR1 ).
LEN = LEN + 1. " to include #
WRITE : LEN.
‎2006 Oct 04 1:11 PM
Hi Ravi,
Try this:
split str at '#' into str1 str2.
if sy-subrc = 0.
l_count = strlen( str1 ).
endif.
Dharitree
‎2006 Oct 04 1:12 PM
Hi,
use below logic
data lv_len type i.
str = '00000003379#212RegVNegNoticeHLA.aspx.xml'
search str for '#'.
lv_len = sy-fdpos - 1.
lv_len will have length of string.
<b>or
split str at '#' str1 str2.
lv_len = strlen(str1).</b>
Regards
amole