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: 

contains #

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

0 Kudos

Hi chandrashekar,

Just curious.. y did not my code work?

0 Kudos

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

it works sometimes and sometimes not...

amit_khare
Active Contributor
0 Kudos

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.

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hi Praniti,

Use CP instead of CA.

Reward if useful!

0 Kudos

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

former_member188827
Active Contributor
0 Kudos

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

Former Member
0 Kudos

Hi,

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

Reward if helpful

Regards

Raghavendra.D.S

Former Member
0 Kudos

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