Application Development 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: 

maintain space

Former Member
0 Kudos

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

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

7 REPLIES 7

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

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

0 Kudos

Thanks you Soooo much Rich .....

0 Kudos

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 ?

0 Kudos

> 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.

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi,

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

Regards,

jaya

former_member194669
Active Contributor
0 Kudos

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.