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

Length Problem

Former Member
0 Likes
639

Data: x_value1 type string,

x_value2(10) type c.

if x_value1 co '1234'

concatenate '0' x_value1 into x_value2.

elseif x_value1 co'12345'.

concatenate '-' x_value1 into x_value2.

elseif x_value1 co '12345678'

concatenate '*' into x_value2.

endif.

x_value1 may contain 4 digits or 5 digits or 8 digits or 9 digitis or 10 digitis.based on the number of digits i need to concatenate '-' or '0' or '*'.

i tried by declaring x_value1(10) type c

also...but no answer...

how can i get ?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
609

Try the below code :

condense x_value1.

lth = strlen (x_value1).

case lth.

when 4.

lval = '0'.

when 5.

lval = '-'.

when 8.

lval = '*'.

endcase.

concatenate lval x_value1 into x_value2.

4 REPLIES 4
Read only

Former Member
0 Likes
609

When you use CO you are saying contains only, instead use the

DATA : i_strlen type i.

i_strlen = STRLEN(x_value1).

Case i_strlen.

when 4.

when 5.

Endcase.

hith

Sunil Achyut

Read only

Former Member
0 Likes
609

HI,

Based on the field length you can pass the different different variables,

lets see the example:

Data: x_value1 type string,

x_value2(10) type c,

len type i.

len = STRLEN(x_value1)

if len = 4.
concatenate '0' x_value1 into x_value2.
elseif len = 5.
concatenate '-' x_value1 into x_value2.
elseif len = 8.
concatenate '*' into x_value2.
endif.

Hope you understand

Regards

Sudheer

Read only

Former Member
0 Likes
609

Hi,

v_len = strlen(x_value1)

case v_len

when 1 or 2 or 3 or 4.

concatenate '0' x_value1 into x_value2

when 5 or 6 or 7 .

concatenate '-' x_value1 into x_value2

when 8 or 9 or 10 .

concatenate '*' x_value1 into x_value2

endcase.

Regards

Amole

Read only

Former Member
0 Likes
610

Try the below code :

condense x_value1.

lth = strlen (x_value1).

case lth.

when 4.

lval = '0'.

when 5.

lval = '-'.

when 8.

lval = '*'.

endcase.

concatenate lval x_value1 into x_value2.