on 05-14-2009 8:52 AM
Hi
I have some strings that i have to process and i only need the last 7 characters out of each one.The problem is that those strings have different length each time.Is there any offset function that can help me or how can i do this in the easy way.I would not want to count the length of the string each time to process it using offsets
thanks
Hi,
Try this, hope it will solve ur problem .
x(3) type c.
strn = ''aaaa aaa aaa''
x = strlen( strn ) .
x = x - 7.
strn2 = strn+x(7).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
First of all thanks for the fast response.
I have tried with this code:
data: str(20) type c.
LOOP AT gt_lips INTO gs_lips.
str = strlen( gs_lips-vgbel ).
if str > 7.
str = str - 7.
gs_lips-vgbel = gs_lips-vgbel + str(7).
endif.
modify gt_lips from gs_lips.
ENDLOOP.
but at this line: gs_lips-vgbel = gs_lips-vgbel + str(7). the program fails.I do not know why it fails.
Hi,
Try this..
LOOP AT gt_lips INTO gs_lips.
str = strlen( gs_lips-vgbel ).
if str > 7.
str = str - 7 - 1. " now you get the last 7 char
" The sum of position and offset should not be greater than field length
gs_lips-vgbel = gs_lips-vgbel + str(7).
endif.
modify gt_lips from gs_lips.
ENDLOOP.
Hi,
try this:
DATA: STR TYPE STRING.
DATA: STRL TYPE I.
*
STR = '0123456789abcdefg'.
STRL = STRLEN( STR ).
*
IF STRL > 7.
STRL = STRL - 7.
STR = STR+STRL(7).
ENDIF.
WRITE: / STR.
regards, Dieter
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Use class CL_RECA_STRING_SERVICES method RIGHT and indicate the number of characters you want to get from the right (=7) as below.
CALL METHOD cl_reca_string_services=>right
EXPORTING
id_string = my_string
id_length = 7
RECEIVING
rd_string = my_last_7_chars.
Hope this will help you.
Issa
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
You use STRLEN to count the length.
Lets suppose a variable v_var of length 10.
DATA: v_var type char10,
v_var1 type char7,
v_len type i.
v_var = 'ABCDEFGHIJ'.
v_len = strlen( v_var ).
v_len = v_len - 7.
if v_len < 0.
v_len = 0.
endif.
v_var1 = v_var+v_len(7).
Hope this resolves ur query.
Regards,
Nikhil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Refer the following program with string length calculation.
data:
w_string type string,
w_string1 type string,
w_off type i value 0,
w_off1 like w_off.
w_string = 'vjhsdfahdfseht'.
w_off = strlen( w_string ).
w_off1 = w_off - 7.
w_string1 = w_string+w_off1(7).
write:
w_string1.
Thanks,
Nithya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Do like this...
parameter : s(100).
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = s
lang = 'E'
IMPORTING
RSTRING = S
EXCEPTIONS
TOO_SMALL = 1
OTHERS = 2
.
S = S+0(7).
CALL FUNCTION 'STRING_REVERSE'
EXPORTING
string = s
lang = 'E'
IMPORTING
RSTRING = S
EXCEPTIONS
TOO_SMALL = 1
OTHERS = 2
.
WRITE S.
Regards
Debarshi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.