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

Strings

amit_khare
Active Contributor
0 Likes
1,394

Hi All,

I want to concatenate two string as such that all the white spaces will be there in solution.

e.g. -

str = ' asd '.

str1 = ' ddd '.

output string should be -

' asd ddd '.

How can i do that?

Points will be rewarded.

Regards

Amit

15 REPLIES 15
Read only

Former Member
0 Likes
1,358

Hi just use simple concatenate statement as

concatenate str str1 into str3 separated by space.

Hope this helps.

Read only

0 Likes
1,358

Hi Imtiaz,

I tried that but its removing the white spaces.

Regards

Amit

Read only

0 Likes
1,358

Try this it is working in my system.

data : str(10),str1(10),str3(10).

str = ' asd '.

str1 = ' ddd '.

concatenate str str1 into str3 separated by space.

write str3.

Read only

Former Member
0 Likes
1,358

Hi,

You need to concatenate with the space in between,

like for ex,

concatenate 'str' ' ' 'str1' into str2.

Hope this helps,

Rgds,

Read only

Former Member
0 Likes
1,358

Hi Amit,

Use 'Separated by SPACE' while concatenating string1, string2 to String3.

Regards,

Sudhakar.

Read only

0 Likes
1,358

Hi All,

I think you didnt got my requirement.

I dont want to put space in between instead i want to keep all the white spaces in tact if present in data.

like material description is of 40 char and i have a data of 22 char and i concatenate it with say, ernam field data then all the unfilled white spaces whould be there in the answer field.

Amit

Read only

0 Likes
1,358

Hi Amit,

You move to taking positions

like ex:

data : str(60).

str+0(40) = maktx.

str+41(20) = ernam.

Thanks,

siri.

Read only

Former Member
0 Likes
1,358

Hi,

Try this.

Cancatenate str str1 into str2

separated by space.

Thanks,

Siri.

Read only

Former Member
0 Likes
1,358

Hi Amit,

Just try like this,

DATA: C1(10) VALUE 'Sum',

C2(3) VALUE 'mer',

C3(5) VALUE 'holi ',

C4(10) VALUE 'day',

C5(30),

SEP(3) VALUE ''.

CONCATENATE C1 C2 C3 C4 INTO C5 SEPARATED BY SEP.

WRITE / C5.

Hope it helps u.

Thanks&Regards,

Ruthra.

Read only

Former Member
0 Likes
1,358

hi

try the keyword SEPERATED BY

regards

Arun

Read only

Former Member
0 Likes
1,358

Hi Amit,

Concatenate str1 str2 into str3 separated by space : should work. If not try this one.

data: str1(10),

str2(10),

str3(21).

str3+0(10) = str1.

str3+12(10) = str2.

Regards,

Sudhakar.

Read only

Former Member
0 Likes
1,358

Hi Amit,

When we use CONCATENATE,the trailing blanks are ignored. <b>The addition SEPARATED BY <s> retains them.</b>

Hope u understood.

Thanks&Regards.

Ruthra.R

Read only

Former Member
0 Likes
1,358

Hi Amit.

DAta: final_string(63)

final_string+0(40) = p_mat_desc.

final_string+41(12) = p_ernam.

You will have the required data in final_stirng.

Reward points if it helps you.

Regards,

Sudhakar.

Read only

Former Member
0 Likes
1,358

Hi Amit,

1. If u see the documentation of concatenate,

it clearly specified the problem

related to white spaces.

2. Moreover it also tells something about STRING.

3. Use this code (Just copy paste)

There are different type of variables,

and notice how they behave differently.

REPORT zauth .

DATA : matnr TYPE STRING.

DATA : pernr LIKE pa0001-pernr.

DATA : ebeln LIKE ekko-ebeln.

DATA : ernam LIKE ekko-ernam.

DATA : ab(100) TYPE c.

DATA : cd(100) TYPE c.

DATA : ef TYPE STRING.

matnr = ' 001 '.

pernr = '776'.

EBELN = '25 '.

ernam = 'SAPUSER'.

CONCATENATE matnr ernam INTO ab .

CONCATENATE pernr ernam INTO cd .

CONCATENATE ebeln ernam INTO ef .

WRITE 😕 ab.

WRITE 😕 cd.

WRITE 😕 ef.

I hope it helps.

Regards,

Amit M.

Read only

amit_khare
Active Contributor
0 Likes
1,358

Hi All,

Thanks for the suggetions .Problem is solved and points are awarded as promised.

Amit