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: 

to check that string contains space

Former Member
0 Kudos

Hi...

I have one char string, If that string contains any space then I want to display a message.

how to check that string contains 'space'.

Regards,

Rohit

8 REPLIES 8

Former Member
0 Kudos

IF CA ' '.

should do the trick

0 Kudos

even i have tried by CA but its not working...

0 Kudos

data str type string.

str = 'test test'.

if str ca ''.

write 'blank is there'.

else.

write 'No blank'.

endif.

it will work...

Regards

Muthu

Former Member
0 Kudos

Hi, you can do a small work.

you can split the char string into substrings at spaces.

if there is space then it will be splitted and then you can check the sy-subrc.

if sy-subrc = 0,

then the char string had some space in it.

regards

jayati

Former Member

Hi ,

You can use condense also on that string and sy-subrc will be set to 0 if any space is there.

now check sy-subrc to know if any space is there or not.

let me know if this is helpful?

asik_shameem
Active Contributor
0 Kudos

Hi

Do like this.

DATA: gv_str TYPE STRING VALUE 'HELLO THERE'.

IF gv_str CA SPACE.
  MESSAGE 'ERROR' TYPE 'I'.
ENDIF.

Former Member
0 Kudos

hi,

try to do like this

data: str type string.

define same way str1 and str2.

split string at space into str1 str2.

if sy-surc = 0.

string contains space.

else.

process ur string for ur desired operation.

endif.

marcela_martinez
Participant
0 Kudos

Hi,

First of all try to SHIFT the string. Suppose your variable is named VAR:

SHIFT var LEFT DELETING LEADING SPACE.

IF var CA ' '.

WRITE:/ 'FIND SPACE'.

ENDIF.

Good luck and kind regards,

MMP.