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

contains #

Former Member
0 Likes
1,184

Hi,

I am trying to write the following code

if l_betrg ca '#'.

g_error = 'X'.

endif.

but even if l_betrg contains #, it is not going to g_error = 'X'

Could you please tell me where i am going wrong..I need to identify if l_betrg contains #. l_betrg is defined as

data: l_betrg(13) type c.

Thanks

Pranati

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,164

try this..

if l_betrg ca <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.</b>

g_error = 'X'.

endif.

<b>OR</b>

if l_betrg ca <b>CL_ABAP_CHAR_UTILITIES=>CR_LF.</b>

g_error = 'X'.

endif.

try this..

if l_betrg ca <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.</b>

g_error = 'X'.

endif.

<b>OR</b>

if l_betrg ca <b>CL_ABAP_CHAR_UTILITIES=>CR_LF.</b>

g_error = 'X'.

endif.

10 REPLIES 10
Read only

Former Member
0 Likes
1,165

try this..

if l_betrg ca <b>CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.</b>

g_error = 'X'.

endif.

<b>OR</b>

if l_betrg ca <b>CL_ABAP_CHAR_UTILITIES=>CR_LF.</b>

g_error = 'X'.

endif.

Read only

0 Likes
1,164

Hi chandrashekar,

Just curious.. y did not my code work?

Read only

0 Likes
1,164

it depends on the unicode , even i am not sure about that...

it works sometimes and sometimes not...

Read only

amit_khare
Active Contributor
0 Likes
1,164

Try this -

str1 type string value '#.

str2 type string.

move l_betrg to str2

if str2 cs str1.

g_error = 'X'.

endif.

Regards,

Amit

reward all helpful replies.

Read only

Former Member
0 Likes
1,164

Your test case scenario doesn't happen... There might be a mistake in the content of the Variable... Please check the code.

Regards,

Pavan P.

Read only

Former Member
0 Likes
1,164

Hi Praniti,

Use CP instead of CA.

Reward if useful!

Read only

seshatalpasai_madala
Product and Topic Expert
Product and Topic Expert
0 Likes
1,164

Hi,

Check in debug mode if this actually contains '#' may its a case that it contains some value which is getting displayed as #.

Regards,

Sesh

Read only

former_member188827
Active Contributor
0 Likes
1,164

i tried ur code.its working absolutely fine!!

data i_betrg(13) type c.

data g_error(1).

i_betrg = '#1234'.

if i_betrg ca '#'.

g_error = 'X'.

endif.

write g_error.

rgds

Read only

Former Member
0 Likes
1,164

Hi,

I think CA operator checks to see whether any letter in field1 is in field2.

Reward if helpful

Regards

Raghavendra.D.S

Read only

Former Member
0 Likes
1,164

Hi,

actual probem is "#" is not a value.... its just showing the deliminator..... u cant use in the condition.... actually sap use it when its unidentified value

  1. sign just determine the space or deliminator.....its actuall value is not a "#"... thats why your condition is being false..

regards,

shardul shah

Message was edited by:

Shardul Shah