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

Padding balnk spaces

Former Member
0 Likes
566

Hi,

consider this example:

Data: l_var1(5), l_var2(5), l_var3(20).

l_var1 = 'abcde'. l_var2 = '12345'.

CONCATENATE l_var1 l_var2 INTO l_var3 separated by SPACE.

As a result: l_var3 = 'abcdef12345'.

The above is the actual result result.

The desired result is:: l_var3 = 'abcdef12345 ' (10 blank spaces )

How do we go about it?

Hi,

consider this example:

Data: l_var1(5), l_var2(5), l_var3(20).

l_var1 = 'abcde'. l_var2 = '12345'.

CONCATENATE l_var1 l_var2 INTO l_var3 separated by SPACE.

As a result: l_var3 = 'abcdef12345'.

The above is the actual result result.

The desired result is:: l_var3 = 'abcdef12345 ' (10 blank spaces )

How do we go about it?

5 REPLIES 5
Read only

LucianoBentiveg
Active Contributor
0 Likes
546

Data: l_var1(5), l_var2(5), l_var3(20).

l_var1 = 'abcde'. l_var2 = '12345'.

CONCATENATE l_var1 '##########' l_var2 INTO l_var3.

REPLACE l_var3 with '# '.

Regards.

Read only

Former Member
0 Likes
546

Hi,

we can not get the blank spaces in the Charecter type fields, if you want the put a DOT (.) at the last charecter

Regards

Sudheer

Read only

Former Member
0 Likes
546

You can do something like this,

data : l_space type char1 value ' '.

" < Type it with num lock on holding the ALT key and 0160 from num pad, by that you will get space ASCII or copy paste the value from character map to the value addition in your constants declaration>

Data: l_var1(5), l_var2(5), l_var3(20).

l_var1 = 'abcde'. l_var2 = '12345'.

CONCATENATE l_var1 l_var2 INTO l_var3 separated by SPACE.

l_var3+10(10) = l_space.

This will put the blanks in the end.

~Ranganath

Read only

Former Member
0 Likes
546

for what purpose do u want the spaces... normally ABAP shows without spaces...

if u want spaces and if there is one more field u can concatenate and u will find the spaces. But if this is the last field then the only solution is u need to concatenate with a extra symbol which is of no use as such but it will retain the spaces...

Read only

Former Member
0 Likes
546

l_len = strlen(l_var3).

do.

l_initial = 1.

if l_var3+l_initial(1) CA sy-abcde.

concatenate l_var3 ` ` into l_var3.

endif.

if l_var3+l_initial(1) eq '/*'.

exit.

endif.

enddo.

Add the above piece of code to your prog...

Regards,

Pavan.