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

Trunc a string

Former Member
0 Likes
626

Hi

I need trunc 4 places of mlgt-lgpla. My LGPLA have 6 CHARACTERs but i need separate first two into a variable and delete the others.

I try with SPLIT, but doesn't work.

Can somebody help me ?

Thanks.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
593

Hello Ricardo,

See if this helps:

v_2char = v_lgpla+0(2).

v_lgpla being you variable containing the value of mlgt-lgpla.

The +0 applies to the position in the field. So at position zero;

the (2) applies to how many spaces to grab.

So we now have v_2char containing the 2 spaces after position 0 of v_lgpla.

Hope this helps.

Regards,

C

4 REPLIES 4
Read only

JozsefSzikszai
Active Contributor
0 Likes
593

you have to use offset:

lv_... = lgpla(2).

Read only

Former Member
0 Likes
593

Use offset:

DATA: w_var(2).

w_var = mlgt-lgpla(2).

Read only

Former Member
0 Likes
595

Hello Ricardo,

See if this helps:

v_2char = v_lgpla+0(2).

v_lgpla being you variable containing the value of mlgt-lgpla.

The +0 applies to the position in the field. So at position zero;

the (2) applies to how many spaces to grab.

So we now have v_2char containing the 2 spaces after position 0 of v_lgpla.

Hope this helps.

Regards,

C

Read only

former_member156446
Active Contributor
0 Likes
593
REPORT  zj_test.
DATA: string(6) TYPE c VALUE 'ABCDEF',
lv_string TYPE string.
DATA:lv_len TYPE i, count TYPE i VALUE '2'.

lv_len = STRLEN( string ).
lv_len = lv_len - count.

DO lv_len TIMES.

  string+count(1) = space.
  count = count + sy-tabix.

ENDDO.
WRITE:/ string.