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

Issue with CA operator

former_member295881
Contributor
0 Likes
1,720

Hello Experts,

I've a requirement, where I need to do validation on a field (gv_test1), which stored my results.

All I'm trying to do, is to check that if my variable 'gv_test1' has any special characters, which I've stored in a constant c_valchk.

For reference, here is my code.


constants: c_valchk(35)     type c value '<>?/`,./!@#$%&*-_+=~|\[{]}()"'.

data: gv_test1                   type char10.

    if gv_test1 ca c_valchk"ca
       clear: pwa_index_h1_postalcode.
    else.
       pwa_index_h1_postalcode = gv_test1.
    endif.

However, always my code goes and clear value in 'pwa_index_h1_postalcode' field, even when 'gv_test1' doesn't contain any special character. It never ever goes and copy value gv_test1 to pwa_index_h1_postalcode.

Can anybody see what mistake I'm making in my above code, and how to rectify it, please?

Many thanks in advance.

6 REPLIES 6
Read only

Former Member
0 Likes
1,411

Hi

Just check if any of the wildcard values maybe impacting the code.

Values like * % &

I'd try with just one invalid value at a time and test that, build up the string of invalid values as the testing is successful

Regards

Arden

Read only

Former Member
0 Likes
1,411

Hi Zero,

It`s due to the left leading blank. See c_valchk(35) length is 35, but actually only have 29 char, so other will fill with left leading blank. And your gv_test1 length is 10, if value is '1234567890', no blank, then it will copy value to pwa_index_h1_postalcode.


regards,

Archer

Read only

0 Likes
1,411

Thanks so much Archer and all others for your valuable input. Indeed it was length, which was causing the problem.

Read only

Former Member
0 Likes
1,411

you can always directly use

IF gv_test1 CA '<>?_' .      Instead of using using a variable.

OR change to c_valchk(29) instead of (35).

Read only

Tomas_Buryanek
Product and Topic Expert
Product and Topic Expert
0 Likes
1,411

Or better use STRING.

-- Tomas --
Read only

0 Likes
1,411

Thanks so much for your help Kalyan. Indeed it was issue with additional space.