2015 Mar 04 12:09 AM
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.
Thanks so much for your help Kalyan. Indeed it was issue with additional space.
2015 Mar 04 12:39 AM
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
2015 Mar 04 2:04 AM
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
2015 Mar 04 12:28 PM
Thanks so much Archer and all others for your valuable input. Indeed it was length, which was causing the problem.
2015 Mar 04 3:09 AM
you can always directly use
IF gv_test1 CA '<>?_' . Instead of using using a variable.
OR change to c_valchk(29) instead of (35).
2015 Mar 04 6:52 AM
2015 Mar 04 12:30 PM
Thanks so much for your help Kalyan. Indeed it was issue with additional space.
| User | Count |
|---|---|
| 6 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |