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

substrings in ABAP ?

Former Member
0 Likes
521

I am trying to convert a value from a string or a number.

I just want to grab either the first number or the first character

of one variable and assign it to another variable.

How do I do this?

How do I do this if I'm trying to return just the third character or number in the value?

Where could I have looked this up myself in the documentation?

3 REPLIES 3
Read only

Former Member
0 Likes
495

You can take the offset like...

say u want the first character of variable v1 you take it as v2 = v1+0(1)

for 3rd character v2 = v1+2(1)

You can do f1 on your code and go to the operations on strings. you can get the help there.

Read only

Former Member
0 Likes
495

Hi,

DATA: V_CHAR8(8) VALUE '12345678'.

DATA: V_CHAR.

V_CHAR = V_CHAR8(1).

Thanks,

Naren

Read only

Former Member
0 Likes
495

This can be achieved using offset: Is this what you are looking for?

data: str(3) type c value 'xyz'.

write:/ str+1(2). "Extract two chars starting from position 1.

Output: xy.

Thanks,

Santosh