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

Trailing spaces requried

Former Member
0 Likes
1,369

Data:
str1(10) type c,
str2(10) type c,
str3(30) type c.

str1 = 'street1   '.
str2 = 'street2   '.
CONCATENATE str1 str2 INTO str3 SEPARATED BY ';'.

Write / str3

the output obviously will become:

street1;street2.

but what i wanted is to maintain the existing trailings

so it should be:

street1<blank><blank><blank>;street2<blank><blank><blank>.

It seems the forum also does not allow trailing spaces.

What should I do?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,335

HI,

TRU OFFSET IDEA.

DATA:SRC(100).

SRC+0(40) = STREET1

SRC+40(42) = ' '.

SRC+42(40) = STREET2

SRC+82(42) = ' '.

REWARD POINTS,

KUMAR

11 REPLIES 11
Read only

Former Member
0 Likes
1,336

HI,

TRU OFFSET IDEA.

DATA:SRC(100).

SRC+0(40) = STREET1

SRC+40(42) = ' '.

SRC+42(40) = STREET2

SRC+82(42) = ' '.

REWARD POINTS,

KUMAR

Read only

0 Likes
1,335

Hi ,

Try this out using offset,

str3+0(15) = str1.

str3+15(15) = str2.

u will get the spaces as it is.

Regards,

Balakumar.G.

Read only

Former Member
0 Likes
1,335

Hi Mizan,

You can use this for your requirement.

Data:
str1(10) type c,
str2(10) type c,
str3(30) type c.

str1 = 'street1   '.
str2 = 'street2   '.
CONCATENATE str1 str2 INTO str3 SEPARATED BY ';' RESPECTING BLANKS .

Write / str3.

Regards,

Samson Rodrigues.

Read only

Former Member
0 Likes
1,335

Hi,

DATA:

str1(10) TYPE c,

str2(10) TYPE c,

str3(30) TYPE c.

str1 = 'street1 '.

str2 = 'street2 '.

str3+0(7) = str1.

str3+11(1) = ';'.

str3+12(7) = str2.

WRITE / str3.

Regards,

V.Balaji

Read only

Former Member
0 Likes
1,335

use : RESPECTING BLANKS

CONCATENATE str1 str2 INTO str3 SEPARATED BY ';' RESPECTING BLANKS

Read only

Former Member
0 Likes
1,335

Hi,

Check the help on Keyword CONCATENATE, there you find an option 'RESPECTING BLANKS'.

Use this option while concatenating two strings, it will keep the blanks intact.

Regards,

Mayank

PS: Reward points if its helpful.

Read only

Former Member
0 Likes
1,335
Data:
str1(10) type c,
str2(10) type c,
str3(30) type c,
str4(10) type c.

str4 = '      '.
str1 = 'street1   '.
str2 = 'street2    '.
CONCATENATE str1 str2 INTO str3 SEPARATED BY  str4.

Write / str3.

hi

i hv changed ur code like this i have add str4 for space now it will display all trailing spaces please check

Read only

0 Likes
1,335

Doesn't seem too practical for the separator if the data extracted is dynamicly but based on the field length specified locally. But anyhow seems 'RESPECTING BLANKS' do not work for 4.7. I heard there is a way to use TRANSLATE still testing it out right now.

Read only

Former Member
0 Likes
1,335

Try using the the addition for CONCATENATE statement

... RESPECTING BLANKS

Effect

The addition RESPECTING BLANKS is only allowed during string processing and causes the closing spaces for data objects dobj1 dobj2 ... or rows in the internal table itab to be taken into account. Without the addon, this is only the case with string.

Note

With addition RESPECTING BLANKS, statement CONCATENATE can be used in order to assign any character strings EX>text - taking into account the closing empty character - to target str of type string: CLEAR str. CONCATENATE str text INTO str RESPECTING BLANKS.


TYPES text   TYPE c LENGTH 10. 
DATA  itab   TYPE TABLE OF text. 
DATA  result TYPE string. 

APPEND 'When'  TO itab. 
APPEND 'the'   TO itab. 
APPEND 'music' TO itab. 
APPEND 'is'    TO itab. 
APPEND 'over'  TO itab. 

CONCATENATE LINES OF itab INTO result SEPARATED BY space. 
... 
CONCATENATE LINES OF itab INTO result RESPECTING BLANKS.

After the first CONCATENATE statement, result contains "When_the_music_is_over", after the second statement it contains "When______the_______music_____is________ over______" . The underscores here represent blank characters.

Hope this helps.

Thanks,

Balaji

Read only

Former Member
0 Likes
1,335

do this

Data:

str1(10) type c,

str2(10) type c,

str3(30) type c,

str4(10) type c.

str4 = ' ;'.

str1 = 'street1 '.

str2 = 'street2 '.

CONCATENATE str1 str2 INTO str3 SEPARATED BY str4.

Write / str3.

Read only

Former Member
0 Likes
1,335

Hi,

We can't do that.