‎2007 Aug 08 2:18 PM
Hi,All:
I want to truncate a string. but I just need the right side 4 digits.
Is there any function module to implement it.
for example '123456', I just need '3456'.
for example '12345' , I just need '2345'.
Thanks,
‎2007 Aug 08 2:22 PM
length = strlen('PRABHU').
length = length - 4.
output = input+length(4).
Regards
Peram
‎2007 Aug 08 4:02 PM
‎2007 Aug 08 2:22 PM
Hi!
lv_length = strlen(your_string).
subtract 4 from lv_length.
WRITE:/ your_string+lv_length(4).
Regards
Tamá
‎2007 Aug 08 2:22 PM
do this way...
v_str = strlen ( field ).
v_str1 = v_str - 4.
field1 = field+v_str(4).
‎2007 Aug 08 2:23 PM
Hi Yunfa,
You can use <b>strlen</b> option to find the length of the string.
Now deduct 4 from the length and store that in a variable say 'v_len'.
Now you can have <b><field>+v_len(4)</b> for your solution.
<b>Reward points if this helps,</b>
Kiran
‎2007 Aug 08 2:28 PM
Hi,
try this:
DATA: STR TYPE STRING VALUE 'testfrom2007'.
DATA: CSTR(4).
DATA: STRL TYPE I.
*
STRL = STRLEN( STR ).
IF STRL > 4.
STRL = STRL - 4.
CSTR = STR+STRL(4).
ELSE.
CSTR = STR.
ENDIF.
*
WRITE: CSTR.
Regards, Dieter
‎2007 Aug 08 2:33 PM
hi yunfa.......
try out this coding:
data:
test type string VALUE '12345678909',
len type i,
result type i.
len = STRLEN( test ). " find the length of the string
len = len - 4. "determines the offset
result = test+len(4). " produces the last 4 digits---regards,
alex b justin
‎2007 Aug 08 2:33 PM
You can use it for wa_test as char or wa_test2 as string...
Regards,
Laurent
data wa_test(12) type c value '0123456789'.
data wa_test2 type string value '0123456789'.
data wa_count type i.
condense wa_test2 no-gaps.
wa_count = strlen( wa_test ) - 4. " <- 4 is the count of digit you need
shift wa_test by wa_count places left.
write : / wa_test.
‎2007 Aug 08 2:35 PM
hI zhang,
str = 123456
len = strlen ( str ) -> len = 6
str1 = len - 4.
final_str = str + str1(4) -> 2(6).
Reward points for all helpful ans;s.
kiran.M
‎2007 Aug 08 4:13 PM
Hi,
Try this code
report ztest_46.
types : begin of t_t,
v_1(1) type c,
v_2(10) type c.
types : end of t_t.
data : wa_t type t_t.
move '123456' to wa_t.
write : wa_t-v_2.
move '12345' to wa_t.
write : wa_t-v_2.
aRs