‎2009 Apr 16 6:43 AM
Dear All,
I have one problem, that i want to exclude some words from my string.
eg : string = abcdefghijklmnop.
i want to dispay this string like fghi* (starting from 6th position)
can you help me out this problem.
Thanks in advance.
Regards,
Sujeet
‎2009 Apr 16 6:56 AM
Hi,
try below code
DATA : w_st TYPE string,
w_st2 TYPE string,
n TYPE i.
w_st = 'abcdefghijklmnop'.
n = STRLEN( w_st ).
n = n - 6.
w_st2 = w_st+6(n).
WRITE : / w_st2.Regards
Bala Krishna
‎2009 Apr 16 6:46 AM
data : g_string type string,
l_string type string.
g_string = abcdefghijklmnop.
l_string = g_string+06(10)
write l _string.
‎2009 Apr 16 6:49 AM
Sujeeth,
Take some temporary variable as shownn below
Data: Temp_Var type c length 15.
move string+5(11) to temp_var.
write: temp_var.
Hope it is useful
Thanks,
Babu Kilari
‎2009 Apr 16 6:54 AM
Try this code
data: string1 type string value 'abcdefghijklmnop',
string2 type string.
string2 = string1+05(10).
write string2.
‎2009 Apr 16 6:57 AM
@ SAP User,
Offset should be 05 not 06. Because SAP Calculates the string from 0th Position
@ Gayathri.
Length should be 11 not 10. If you give it as 10, the last character will be missed out.
Plz check
Thanks,
Babu Kilari
‎2009 Apr 16 6:56 AM
Hi,
try below code
DATA : w_st TYPE string,
w_st2 TYPE string,
n TYPE i.
w_st = 'abcdefghijklmnop'.
n = STRLEN( w_st ).
n = n - 6.
w_st2 = w_st+6(n).
WRITE : / w_st2.Regards
Bala Krishna
‎2009 Apr 16 7:01 AM
Hi Sujeet,
i hope that u know the concept of Offset .
the above given solutions are based on this method of OFFSET.
pls read the library for better understanding.
eg.
data:
w_string(15) type c value 'netweaver'.
w_char type string.
w_char = w_string+6(4).the following code calculates the string specfied from 6 th pos onwards till the length provided here '4'.
w_char will contain value ver
hope u got the concept..
thanks
ravi
‎2009 Apr 16 7:34 AM
Hi all,
I know string operation.
but thing is, as i have posted previously that i want "fghi*".
means start from 6th position till 10th.
= i have to display with my string, it doesn't mean i want all words after pos 10.
Have a Nice Day,
Regards,
Sujeet
‎2009 Apr 16 7:42 AM
Hi Sujeeth,
I think you havent mentioned your requirement properly before. Please check the same.
Anyways, Now you got the reply from Lakshmi Priya Isnt it?
Thanks,
Babu Kilari
‎2009 Apr 16 7:45 AM
Please check this code
data : string1 type string value 'abcdefghijklmnop',
string2 type string.
string2 = string1+05(11).
write string2.
‎2009 Apr 16 8:09 AM
Hi,
Test the following Sample Code Hope will solve out your problem,
DATA: string TYPE string VALUE 'abcdefghijklmnop',
moff TYPE i,
st_len TYPE i.
st_len = STRLEN( string ).
FIND FIRST OCCURRENCE OF 'fghi' IN string
MATCH OFFSET moff.
IF sy-subrc EQ 0.
st_len = st_len - moff.
WRITE: string+moff(st_len).
ENDIF.Please Reply if any Issue,
Best Regards,
Faisal
‎2009 Apr 16 7:40 AM
Hi,
string = abcdefghijklmnop.
to dispay this string like fghi* (starting from 6th position)
If the position is 6,then the offset will be 5 as the starting pos is considered as 0.
From total length we need only till 10th pos from 6th .
now the
string = string+5(5).
Edited by: Lakshmi Priya Gaddam on Apr 16, 2009 8:41 AM
‎2009 Apr 16 7:41 AM
data : l_var1 type string,
l_var2 type string.
l_var1 = 'abcdefghijklmnop'.
l_var2 = l_var1+5(5)
write: l_var2.
Regards,
Joan
Edited by: Joan Jesudasan on Apr 16, 2009 8:46 AM
‎2009 Apr 16 7:42 AM
DATA : STR TYPE STRING VALUE 'abcdefghijklABCD',F(2),C(2),
strlen type n.
C = strlen( STR ).
F = C - 5 .
WRITE / STR+5(F).
hOPE THIS WILL SOLE UR PROBLEM......
‎2016 Apr 07 7:08 AM
‎2016 Apr 07 7:40 AM
‎2016 Apr 07 8:06 AM