Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

split char

Former Member
0 Likes
535

hy

i have a field wich is composed from char and num like 'R2004' OR 'R2025' and i would like to split it into two variable the first contain the caracter 'R' and the second contain the number ' 2004' and after that i would like to do

number =number+1(for example 2004 become 2005) and finally i concatenate them and that became :

( R2005;R2006..............).

thanks

3 REPLIES 3
Read only

former_member194669
Active Contributor
0 Likes
517

Welcome to SCN

Try this way


data: n(4) type n.
data: char(5) type c value 'R2004'.
n =  char+1(4).
n = n + 1.
char+1(4) = n.

aRs

Read only

Former Member
0 Likes
517

it seems u registered today only,

so read the forum rules. U must search the sdn before posting such simple questions.

Do it like this

var = var + 1(4)

u'll get the number in var which will be of char type then u can process further.

Read only

Former Member
0 Likes
517

Welcome to SCN.

I would suggest you to explore t-code ABAPDOCU as much as possible.Else Press F1 on Split,Concatenate and learn About Offsets of Strings.

Here is Sample code to start with:

REPORT.
DATA: ONE(5)   VALUE 'R2004',
     number(4),
      first.

first = one+0(1).
Number = one+1(4).
number = number + 1.
CONDENSE number NO-GAPS.
CONCATENATE first number INTO one.
write one.