‎2010 Nov 09 2:28 PM
Hi All,
Can you guys please take a look at this and let me know why this CO operation is not working.
DATA: _tparam(14) TYPE c.
DATA: lv_str(10) TYPE c.
lv_str = '1234567890'.
_tparam = '90'
CONDENSE _tparam NO-GAPS.
IF tparam CO lvstr.
l_var = _tparam.
ELSE.
l_var = 200.
ENDIF.
I did even check the sy-fdpos value, the returned value is correct but the statement in the if block is not getting executed. The else block part is getting executed which is really surprising. I checked the documentation in help.sap.com . But the behaviour I see here is interesting.
Thanks,
Varun
‎2010 Nov 09 2:32 PM
_tparam also contains spaces (it's declared (14)type c). You don't have a space in your legal characters string....
‎2010 Nov 09 2:32 PM
_tparam also contains spaces (it's declared (14)type c). You don't have a space in your legal characters string....
‎2010 Nov 09 2:42 PM
Hi,
I do not agree with what you are saying, since I am assigning the value 90 only though the length is 14. Even then I am condensing the _tparam value saying no-gaps. I think that should take care of what you are saying.
Thanks,
Varun
‎2010 Nov 09 2:44 PM
Condensing will not reduce the size of variable _tparam to 10
Read the F1 help of Comparison operators for character-type operands.
‎2010 Nov 09 2:49 PM
I changed the code like this.
IF _tparam CO '1234567890'.
l_var = _tparam.
ELSE.
l_var = 200.
ENDIF.
Still it does not work. I tried the other options suggested by Keshav too. It did not work.
Thanks,
Varun
‎2010 Nov 09 2:49 PM
after your statements, _tparam contains '90 ' or 90 followed by 12 spaces. Your legal characters string does not contain a space! Therefore, _tparam does not contain only 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 or 0, does it?!! Change your legal characters to C11 and put a space on the front of the string of legal characters.
‎2010 Nov 09 2:51 PM
Do us a favor and add a space in your comparison string:
'0123456789 'and try again.
‎2010 Nov 09 2:52 PM
Again i say change both the variables to type string. then use your old code
‎2010 Nov 09 2:52 PM
tparam has only '90' no spaces. Where as lvstr has 0,1,2,3,4,5,6,7,8,9.
‎2010 Nov 09 2:56 PM
Hi,
It worked when I included a space in the string.
IF _tparam CO '1234567890 '.
l_var = _tparam.
ELSE.
l_var = 200.
ENDIF.
Can you guys explain me why it worked when we included a space ??
Thanks,
Varun
‎2010 Nov 09 3:02 PM
Great, and FYI, I do usually try to take care about what I write in this forum, with an occasional notable failure.
‎2010 Nov 09 3:07 PM
‎2010 Nov 09 2:41 PM
lv_str - char10. tparam - char14. This is the problem.
Change it as
DATA: _tparam(14) TYPE c.
DATA: lv_str(14) TYPE c.
or change both the variables to type string.