on 03-24-2008 4:44 AM
Hi
I have a couple of questions guys..
How to check whether a string contains '$' or ',' in it in ABAP?
and how to check that the string contains only integer values ??
Thanks in advance.
Regards,
Puneet
Hi,
U can use the following Condition,
IF string CA '$' .
....
....
ELSEIF string NA sy-abcde.
.....
.....
ENDIF.
Regards,
Padmam.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Try this Code,
data : begin of temp,
a type char4,
end of temp.
data wa like temp.
data itab like table of temp.
wa-a = '1234'.
append wa to itab.
wa-a = 'ab$d'.
append wa to itab.
loop at itab into wa.
if wa-a ca '$'.
write : / sy-tabix,' ',wa-a,'Contain $ Symbol' .
elseif wa-a na sy-abcde.
write : / sy-tabix,' ',wa-a,'Contains only Integer Values' .
endif.
endloop.
Regards,
Padmam.
Hello Saurabh,
You are right! But the UPPER case inconsistency is not the only mistake of using sy-abcde. What happens with all other symbols like <,{,],&,^ .....? Using sy-abcde treats them all as numeric values. The only numeric values are 0123456789. And those have to be used for a comparison!
Heinz
Hello Puneet,
Try this:
data: w_string type string.
parameters p_in(72).
w_string = p_in.
if w_string CN '0123456789'.
write: / 'Not only integer in string', w_string.
else.
write: / 'Only integer in string', w_string.
endif.
For similar checks you can use these Language elements for Logical expressions:
CO, CN, CA, NA, CS, NS, CP, NP.
Have fun and success,
Heinz
Here is additional information for a check in a table (internal table): you should perform a loop run and remember all index fields where the check failed and save them in a seperate itab. If this index table is empty you can conclude that every check was fine.
Heinz
Edited by: Heinz on Mar 23, 2008 10:10 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
86 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.