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

Field Comparision

Former Member
0 Likes
721

Hi,

I have a variable (type c, len60) and a constant defined as:


  CONSTANTS: c_valid(58) TYPE c VALUE
  ' !"%&()''*+-/,.=;:?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

I want to determine a condition in the program,

If variable contains any char other than those in c_valid,

variable = some constant value

I think this can be done using CO operator but not sure about how to use it,

Pleas help me code this condition,

Thanks,

CD

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
700

  IF field CO c_valid.
     <do something>
  ELSE.
     <do something else>
  ENDIF.
5 REPLIES 5
Read only

Former Member
0 Likes
701

  IF field CO c_valid.
     <do something>
  ELSE.
     <do something else>
  ENDIF.
Read only

0 Likes
700

Thanks for the reply,

I always get confused with CO operator,

Will it do the complete comparision or go charcter by charcter..

Read only

0 Likes
700

It will ensure that every character in the "Field" is contained within your constant value. If any character is not in the constant wil will get a FALSE response on the IF.

Read only

0 Likes
700

It aint working,

this what i tried:


data: title(60) TYPE c.

CONSTANTS: c_valid(58) TYPE c VALUE
' !"%&()''*+-/,.=;:?_0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'.

    IF NOT title CO c_valid.
      title = 'works'.
    ENDIF.

But this condition is true for all the cases, am i doing something wrong here,

Here are the examples i've used:

The 48 laws of power

Inglés intermedio

Read only

0 Likes
700

solved it was a case issue