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

maintain space

Former Member
0 Likes
990

Hi Frn's ,

how can i mantain space in a string type varaible ....

senario is like .....

1) abc .

2) 10 spaces .

3) def .

now i want to put "abc" than 10 spaces and than "def " in a variable of type string .

thanks and Regards ..

Priyank

1 ACCEPTED SOLUTION
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
942

Try this, using a placeholder.

data: v_field1 type string.
data: v_field2 type string.
data: v_result type string.

v_field1 = 'ABC'.
v_field2 = 'DEF'.

CONCATENATE v_field1  '%%%%%%%%%%' v_field2 into v_result.
TRANSLATE v_result using '% '.
write:/ v_result.

Regards,

Rich Heilman

Hi Frn's ,

how can i mantain space in a string type varaible ....

senario is like .....

1) abc .

2) 10 spaces .

3) def .

now i want to put "abc" than 10 spaces and than "def " in a variable of type string .

thanks and Regards ..

Priyank

7 REPLIES 7
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
943

Try this, using a placeholder.

data: v_field1 type string.
data: v_field2 type string.
data: v_result type string.

v_field1 = 'ABC'.
v_field2 = 'DEF'.

CONCATENATE v_field1  '%%%%%%%%%%' v_field2 into v_result.
TRANSLATE v_result using '% '.
write:/ v_result.

Regards,

Rich Heilman

Read only

0 Likes
942

Thanks you Soooo much Rich .....

Read only

0 Likes
942

Rich I have question please

CONCATENATE v_field1 '%%%%%%%%%%' v_field2 into v_result.

TRANSLATE v_result using '% '.

if v_field1 or v_field2 contains the value of % then ?

Read only

0 Likes
942

> Rich I have question please

> if v_field1 or v_field2 contains the value of % then ?

> a®s

As OP said the values of first variable would be "ABC" and third variable 'DEF',it means those values would be constant forever. So there is no reason if these values contains %.

Okay I agree if these values contains % than you may use & as place holder

Cheers,

Amit.

Read only

Former Member
0 Likes
942

hI,

I hope it will take only 1 char space even if we put more space in between abc & def. I remembered that there is no solution for this because even if we put space, it automatically deleted. You can use symbol instead of space when you pass the data and remove while displaying.

Regards,

~Satya

Read only

Former Member
0 Likes
942

Hi,

use with single-quote (') ,here u can write a string with spaces in between.

Regards,

jaya

Read only

former_member194669
Active Contributor
0 Likes
942

Try this way also


report  zars no standard page heading
        line-size 170
        line-count 65(4).
data: v_field1 type string.
data: v_field2 type string.
data: v_field3(10) type c value space.
data: v_result type string.

v_field1 = 'ABC'.
v_field2 = 'DEF'.

CONCATENATE v_field1 v_field3 v_field2 into v_result respecting blanks.

write : v_result.