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

last characters

Former Member
0 Likes
714

hi sap,

i have a field - objnr -ISTR030000001000007

i need to take out the first 12 characters and keep the last 7 characters.

so how can i do it can you pls tell me

regards,

laya.

6 REPLIES 6
Read only

I355602
Product and Topic Expert
Product and Topic Expert
0 Likes
693

Hi,

You can use the offset technique.

Refer:


data : objnr type objnr. "length for objnr is 18

objnr = 'STR030000001000007'.

data : v_str(10) type c.

v_str = objnr+11(7).

write : v_str, objnr.

Regards,

Tarun

Read only

Former Member
0 Likes
693

Use offsets.

data : v_str1 type string value 'ISTR030000001000007' ,
         v_str2 type(12) type c,
         v_str3 type(7) type c.

v_str2 = v_str1+0(12).
v_str3= vstr1+13(7).

Write: v_str2, v_str3.

Thanks

Read only

Former Member
0 Likes
693

Hi,

Try this Way..

DATA : l_len TYPE i.
DATA: l_value(7) TYPE c.
DATA l_objnr TYPE CHAR30.
l_objnr = 'ISTR030000001000007'.
l_len = STRLEN( l_objnr ).

l_len = l_len - 7 .

l_value = l_objnr+l_len(7).
WRITE l_value.

Read only

Former Member
0 Likes
693

Hi,

For this particular case use:

data: v_objnr(7) type c.

v_objnr = objnr+12(7).

Regards.

Read only

Former Member
0 Likes
693

Hi,

This is simple, hope below code snippet help you out:

data:objnr(19) value 'ISTR030000001000007',
       val(7) tyep c.
val = objnr+12(7).

write:/ val.

Pooja

Read only

Former Member
0 Likes
693

This message was moderated.