06-18-2008 6:30 PM
Hi. I have the follow problem.
Data: a(16) TYPE c.
How can I do to get the last ten digits of this data, if this variable not always has the same number of characters???
For example:
a = '123456789abcdefg' OR
a = '123456789abc'.
06-18-2008 6:34 PM
try to do this:
Data: a(16) TYPE c.
data: leng type i,
first type i.
data: last10(10) type c.
leng = strlen( a ).
first = leng - 10.
last10 = a+first(10).
06-18-2008 6:34 PM
try to do this:
Data: a(16) TYPE c.
data: leng type i,
first type i.
data: last10(10) type c.
leng = strlen( a ).
first = leng - 10.
last10 = a+first(10).
06-18-2008 6:36 PM
use :
a+n
a(n)
a+n(n)
where n is the position to move the cursor or the number of char to get..
For example:
a = '123456789abcdefg'
a(3) = '123'.
a+4(5) = '5678a'.
06-18-2008 6:38 PM
Hi,
check this example.
DATA: a(16) TYPE c.
DATA: b(10) TYPE c.
DATA: len TYPE i.
a = '123456789abcdefg'.
len = STRLEN( a ).
len = len - 10.
b = a+len(10).
WRITE: / b.
THanks
Naren
06-18-2008 6:54 PM
small change in above code
DATA: a(16) TYPE c.
DATA: b(10) TYPE c.
DATA: len TYPE i.
a = '123456789abcdefg'.
len = STRLEN( a ).
if len Gt 10.
len = len - 10.
b = a+len(10).
else.
b = a.
endif.
WRITE: / b.