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

shift

Former Member
0 Likes
550

I am having one field called v_ref with length of 18 .

This filed sometimes coming with length 10 and others

spaces in the right handside.Some times with length 13

and other 5 spaces.I need to populated this field in to

some other fileld without any spaces.When it is 10 I need

to populate in to one field and if it is 13 then I need to

populate in to some other field.Can you please suggest.

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
512

You can check the length using the STRLEN .

report zrich_0001.

data: str1 type string.

data: var1(18) type c.
data: var2(13) type c.

data: len type i.


str1 = 'ABCDEFGHIJK'.

len = strlen( str1 ).

if len > 13.
  var1 = str1.
else.
  var2 = str1.
endif.


write:/ var1.
write:/ var2.

Regards,

Rich Heilman

3 REPLIES 3
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
513

You can check the length using the STRLEN .

report zrich_0001.

data: str1 type string.

data: var1(18) type c.
data: var2(13) type c.

data: len type i.


str1 = 'ABCDEFGHIJK'.

len = strlen( str1 ).

if len > 13.
  var1 = str1.
else.
  var2 = str1.
endif.


write:/ var1.
write:/ var2.

Regards,

Rich Heilman

Read only

Laxmana_Appana_
Active Contributor
0 Likes
512

Hi,

Find the size of the contents and transfer the contents.

ex: x_fld is your field.

condense x_fld no-gaps.

x_len = strlen(x_fld).

if x_len = 10.

move x_fld to x_fld1

elseif x_len = 13.

move x_fld to x_fld2

endif.

Regards

Appana

Read only

ibrahim_u
Active Participant
0 Likes
512

if there are spaces you can use CONDENSE for clear spaces.

later you can learn how long is it using STRLEN.



data sample(18) type c.
data len type i.

sample = ' 1234567890       '.
len = STRLEN( sample ). "len=11
condense sample. "sample = '1234567890'
len = STRLEN( sample ). "len=10

i hope this will help

thanks ibrahim