‎2006 Jun 08 10:04 AM
Hi all,
How will i get the last 6 letters from a variable that is of type character? And in that 6 letters i should not take preceding zero's if any.
TIA,
sinthu
‎2006 Jun 08 10:07 AM
hi
use <b>offset</b>
data : str(16) value '111003456',
temp(10) type c,
c ,
a type i value 0,
count type i,
j type i value '0'.
count = strlen( str ).
a = strlen( str ).
count = count + 1.
do count times.
c = str+a(1).
if c ne '0'.
if j = 7.
exit.
else.
concatenate c temp into temp.
j = j + 1.
endif.
endif.
a = a - 1.
enddo.
write 😕 temp.
‎2006 Jun 08 10:07 AM
hi
use <b>offset</b>
data : str(16) value '111003456',
temp(10) type c,
c ,
a type i value 0,
count type i,
j type i value '0'.
count = strlen( str ).
a = strlen( str ).
count = count + 1.
do count times.
c = str+a(1).
if c ne '0'.
if j = 7.
exit.
else.
concatenate c temp into temp.
j = j + 1.
endif.
endif.
a = a - 1.
enddo.
write 😕 temp.
‎2006 Jun 08 10:08 AM
hi Sinthu,
Use <b>offset</b>
i.e,
data var1(10) type c value 'sinthunair'.
var1 = var1 + 3(6) " this statement will fetch the last 6 characters to var1.
write var1 no-zero.
Regards,
Santosh
‎2006 Jun 08 10:10 AM
hii
len = strlen(string) ." this will
"calculate the length
" of your string
strlen = strlen - 6 . " since only last 6 letters are
" needed
<b>string_new = string + strlen(6) .</b> " this will
" capture last 6 letters
<b>CONDENSE string_new NO-ZERO NO GAPS .</b>
WRITE:/ string_new .
use offset with no zero and no gaps.
syntax:
<b><f>[+<o>][(<l>)]</b>
The operation of the statement is performed for the part of the field <f> that begins at position <o>+1 and has a length of <l>.
If the length <l> is not specified, the field is processed for all positions between <o> and the end of the field.
String = string1+3(4).
Assuming that string1 = abcdefgjk.
Here string will contain defg.
Regards
Naresh
‎2006 Jun 08 10:11 AM
Hi,
w_length = strlen(w_field)
w_length = w_length - 6
w_newfield = w_field+w_length(6).
condense w_newfield.
Regards,
Ravi
‎2006 Jun 08 10:11 AM
Hi Sinthu,
You can use Offset, and in case you do not want zeroes.
also use condense.
If this is useful, award points pls..
Regards,
Bharadwaj
‎2006 Jun 08 10:11 AM
data: char(10).
data: char2(6).
char2 = char+3(6).
This will work , please award points if found helpful
‎2006 Jun 08 10:15 AM
Hi,
check this...
REPORT ZTEST_LAST_SIX_WITHOUTZERO .
data: char(12),
six(6),
len type i,
len6 type i.
char = '123450000123'.
len = strlen( char ).
len6 = len - 6.
write char+len6(6) to six no-zero.
write six.regards
vijay
‎2006 Jun 08 10:18 AM
Hi
Check this code it will work for u
CONSTANTS: lc_6 TYPE i VALUE '6'.
DATA : lv_strlen TYPE i,
xv_offer_num type char20,
yv_offer_6ch type char6.
CLEAR : lv_strlen.
Calculate String Lenght
lv_strlen = STRLEN( xv_offer_num ).
Take last 6 charectors
IF lv_strlen >= lc_6.
lv_strlen = lv_strlen - lc_6.
yv_offer_6ch = xv_offer_num+lv_strlen(lc_3).
ELSE.
yv_offer_6ch = xv_offer_num.
ENDIF.
Reward Points if solved.
to remove leading zero
conversion_exit_alpha_output........fm and pass yv_offer_6ch has input and output parameter
Reagards.
‎2006 Jun 08 10:34 AM
Hi Sinthu,
The below code may help you in solving your problem.
data:
cc(10) type c value '0000000089',
len type i.
len = strlen( cc ). "To get length of character string
len = len - 6. "Offset for last six characters
write cc+len(6) no-zero to cc. "no-zeros in the result
condense cc. "Codensing the result
write:/ cc.
Thanks,
Vinay