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

Code to select

Former Member
0 Likes
666

Hi ,

I need to get only the last 10 characters of a field into another variable.How do I do this?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
637

hi ramana,

look at this one.

str = 'welcome to sdn'.

str = str + 5(2).

write : / str.

output is me.

Hope this helps u.

Regards...

Arun.

Reward points if useful.

5 REPLIES 5
Read only

Former Member
0 Likes
638

hi ramana,

look at this one.

str = 'welcome to sdn'.

str = str + 5(2).

write : / str.

output is me.

Hope this helps u.

Regards...

Arun.

Reward points if useful.

Read only

former_member187255
Active Contributor
0 Likes
637

Ramana,

Try this...

DATA text TYPE string VALUE `123451234567890`.

shift text BY 5 PLACES.

write : text.

Read only

Former Member
0 Likes
637

Hi Ramana,

Using offset you can do this.

For Example:

DATA: F1(8) VALUE 'ABCDEFGH',

F2(8).

DATA: O TYPE I VALUE 2,

L TYPE I VALUE 4.

MOVE F1 TO F2. WRITE F2.

MOVE F1+O(L) TO F2. WRITE / F2.

MOVE F1 TO F2+O(L). WRITE / F2.

CLEAR F2.

MOVE F1 TO F2+O(L). WRITE / F2.

MOVE F1O(L) TO F2O(L). WRITE / F2.

This produces the following output:

ABCDEFGH

CDEF

CDABCD

ABCD

CDEF

Hope this helps.

Thanks,

Srinivasa

Read only

Former Member
0 Likes
637

Hi,

Please try this.


DATA: L_FIELD1(15) TYPE C VALUE '1234567890ABCDE',
      L_FIELD2(10) TYPE C,
      L_LEN TYPE I,
      L_POS TYPE I.
                                        
L_LEN = STRLEN( L_FIELD1 ).
L_POS = L_LEN - 10.
SHIFT L_FIELD1 BY L_POS PLACES.
MOVE L_FIELD1 TO L_FIELD2.
                                       
WRITE: L_FIELD2.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
637

data value(20) type C.

DATA VALUE1(10) TYPE C.

DATA length1 type i .

VALUE = 'HAVE A NICE DAY'.

length1 = STRLEN( VALUE ).

IF LENGTH1 > 10.

LENGTH1 = LENGTH1 - 10.

VALUE1 = VALUE+LENGTH1(10).

ELSE.

VALUE1 = VALUE+0(10).

ENDIF.

WRITE LENGTH1.

WRITE VALUE1.

now the VALUE1 has the o/p : ' A NICE DAY' --the last 10 characters alone.

i hope this solves ur problem.reward points if useful