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

How to insert a space into a string?

Former Member
0 Likes
16,876

Hello everyone,

I have a problem inserting a space into a string. It has to be between gs_ma-prename and gs_ma-name.

I don't want to use "SEPARATED BY SPACE" at the end, because that's not the layout I want and just ' ' doesn't work...

DATA lv_body TYPE string.

  CONCATENATE 'Bitte genehmigen.'
  CL_ABAP_CHAR_UTILITIES=>NEWLINE
  CL_ABAP_CHAR_UTILITIES=>NEWLINE
  'Mit freundlichen Grüßen'
  CL_ABAP_CHAR_UTILITIES=>NEWLINE
  CL_ABAP_CHAR_UTILITIES=>NEWLINE
  gs_ma-prename gs_ma-name
  INTO lv_body.

Thanks for help!

Best regards!

1 ACCEPTED SOLUTION
Read only

former_member222860
Active Contributor
0 Likes
6,039

Hi Patrick,

Here's the logic:

data: v_str type string.

concatenate 'mahesh' '&' 'reddy' into v_str.
replace '&' WITH SPACE INTO v_str.

write:/ v_str.

output:   mahesh reddy

cheers\

Mahesh

Edited by: Mahesh Reddy on Feb 4, 2009 9:56 AM

19 REPLIES 19
Read only

former_member386202
Active Contributor
0 Likes
6,039

This message was moderated.

Read only

0 Likes
6,039

Hi,

thanks for your fast answer, but that doesn't work

Background of my questions is, that I want to have this string into an Outlook E-Mail body.

Regards!

Read only

Former Member
0 Likes
6,039

This message was moderated.

Read only

Former Member
0 Likes
6,039

This message was moderated.

Read only

0 Likes
6,039

@subash

Thanks, but doesn't work, too

Read only

Former Member
0 Likes
6,039

Hi Patrick ,

To get a space between 2 strings without using 'Separted by Space' , you can use a delimeter where you can have the value 'SPACE' and use it in your concatenate statement .

Here's a sample code :

DATA :

w_name1 TYPE string ,

w_name2 TYPE string ,

w_name3 TYPE string ,

w_deli TYPE c .

w_deli = space .

w_name1 = 'SAP' .

w_name2 = 'ABAP' .

CONCATENATE w_name1 w_name2 INTO w_name3 SEPARATED BY w_deli .

Regards ,

Amuktha .

Read only

matt
Active Contributor
0 Likes
6,039

>

> Hi Patrick ,

> To get a space between 2 strings without using 'Separted by Space' , you can use a delimeter where you can have the value 'SPACE' and use it in your concatenate statement .

>

> Here's a sample code :

>

>

> DATA :

> w_name1 TYPE string ,

> w_name2 TYPE string ,

> w_name3 TYPE string ,

> w_deli TYPE c .

>

> w_deli = space .

> w_name1 = 'SAP' .

> w_name2 = 'ABAP' .

>

> CONCATENATE w_name1 w_name2 INTO w_name3 SEPARATED BY w_deli .

>

> Regards ,

> Amuktha .

This is identical to SEPARATED BY space. The only difference is using a variable rather than a literal. So what's the point?

Please note, that all answers involving CONCATENATE a ' ' b INTO c or variants along these lines have been rejected, because THEY DON'T WORK. Please take the time to test your suggestions before posting.

matt

Read only

Former Member
0 Likes
6,039

This message was moderated.

Read only

0 Likes
6,039

Still no result...maybe it has something to do with Outlook...

Read only

matt
Active Contributor
0 Likes
6,039

Patrick - what layout do you want?

If it's what I think you want, you have to do it in two steps:

DATA lv_body TYPE string.
 
CONCATENATE gs_ma-prename gs_ma-name INTO  lv_body SEPARATED BY space.
CONCATENATE 'Bitte genehmigen.' 
    CL_ABAP_CHAR_UTILITIES=>NEWLINE
    CL_ABAP_CHAR_UTILITIES=>NEWLINE
    'Mit freundlichen Grüßen'
    CL_ABAP_CHAR_UTILITIES=>NEWLINE
    CL_ABAP_CHAR_UTILITIES=>NEWLINE
    lv_body
  INTO lv_body.

This will give you Bitte genehmigen##Mit freundlichen Grüßen##firstname@lastname where # is newline and @ is space.

matt

Edited by: Matt on Feb 4, 2009 10:07 AM

Read only

former_member222860
Active Contributor
0 Likes
6,040

Hi Patrick,

Here's the logic:

data: v_str type string.

concatenate 'mahesh' '&' 'reddy' into v_str.
replace '&' WITH SPACE INTO v_str.

write:/ v_str.

output:   mahesh reddy

cheers\

Mahesh

Edited by: Mahesh Reddy on Feb 4, 2009 9:56 AM

Read only

Former Member
0 Likes
6,039

try this

DATA lv_body TYPE string.

CONCATENATE 'Bitte genehmigen' ' = ' space INTO lv_body SEPARATED BY space.

CONCATENATE lv_body 'x' INTO lv_body .

write: lv_body.

Read only

Former Member
0 Likes
6,039

hi,

you need to use ALT+255 instead of space.

check this similar thread

thanks

Read only

0 Likes
6,039

Mahesh Reddy solved the problem

Thanks to everybody who tried to help!

Best regards!

Read only

Former Member
0 Likes
6,039

yes patrick, ALT+255 works, as rimpa said....

Read only

Sergiu
Contributor
0 Likes
6,039

Simplest way:

CONCATENATE {dobj1 dobj2 ...}

            INTO result

            [RESPECTING BLANKS].

Read only

kakshat
Product and Topic Expert
Product and Topic Expert
0 Likes
6,039

Try this...

lv_result = gs_ma-prename && space && gs_ma-name

Read only

Former Member
0 Likes
6,039

I understand that this is a very old thread. For what it's worth, the following is the correct way of adding a space to a string. Hopefully it'll provide someone with the answer they're looking for in the future.

CONCATENATIVE 'my string' ` ` 'second string after space' INTO lv_whatever_variable.

Use ` ` (not ' ') to have ABAP interpret it as an actual space.

Read only

0 Likes
6,039

Thanks for teh suggestion