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

Look for leftmost 4 characters from a variable

Former Member
0 Likes
1,360

Dear all,

I try to get 4 leftmost characters from a variable. Is there any function(such as leftmost(4, a)) in ABAP?

Thanks in advance

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,322

Hi,

If your variable is not a character field then you need to pass the value to char field.

After that use the logic given above.

Dear all,

I try to get 4 leftmost characters from a variable. Is there any function(such as leftmost(4, a)) in ABAP?

Thanks in advance

9 REPLIES 9
Read only

Former Member
0 Likes
1,322

Yo ucan use this simple command

VAR1 = VAR2+0(4).

Where VAR1 is assigned first 4 characters of VAR2.

Read only

Former Member
0 Likes
1,323

Hi,

If your variable is not a character field then you need to pass the value to char field.

After that use the logic given above.

Read only

varma_narayana
Active Contributor
0 Likes
1,322

Hi ..

We can directly Access the Leftmost 4 chars using:

DATA : VAR(10) VALUE 'ABCDEFGHIJ'.

WRITE:/ VAR(4).

<b>reward if Helpful.</b>

Read only

Former Member
0 Likes
1,322

hi

try this.

data: v1 type bseg-belnr.

data: v2(4) type c.

v2 = v1(4).

Read only

Former Member
0 Likes
1,322

thanks

Read only

Former Member
0 Likes
1,322

thanks

Read only

Former Member
0 Likes
1,322

thanks

Read only

Former Member
0 Likes
1,322

thanks

Read only

Former Member
0 Likes
1,322

thanks