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: 

Question about CO and CA operator

Former Member
0 Kudos

Hi,

I have a field for which I want to detect a case where if it is null or contains any alphabhet from a to z.

For this I have defined a constant:


  CONSTANTS: c_valid(26) TYPE c VALUE
  'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

But I get confused in using CO and CA operator. How can I achieve above logic.

Thanks,

CD

1 ACCEPTED SOLUTION

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You want to use CA(Contains Any) because you want to know if there are ANY alpha characters here, Contains Only would be if you wanted to test that it Only contains values other than alphas, in your case.

if lv_value is initial 
    or lv_value CA sy-abcde.

endif.

Regards,

Rich Heilman

3 REPLIES 3

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos

You want to use CA(Contains Any) because you want to know if there are ANY alpha characters here, Contains Only would be if you wanted to test that it Only contains values other than alphas, in your case.

if lv_value is initial 
    or lv_value CA sy-abcde.

endif.

Regards,

Rich Heilman

ThomasZloch
Active Contributor
0 Kudos

You can use SY-ABCDE instead of defining a constant.

IF field IS INITIAL OR field CA SY-ABCDE.

...

ENDIF.

CA = "contains any".

For detailed explanation of these operands, see ABAP online help for the IF-statement.

Thomas

Former Member
0 Kudos

Hello,

Use CA operator.

data: w_valid(26) TYPE c VALUE

'ABCDEFGHIJKLMNOPQRSTUVWXYZ',

w_value type char10 value 'Jayant'.

if w_value CA w_valid.

message 'Welcome to SCN' type i.

endif.

Hope it helps.

Thanks,

Jayant