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

Compare Integer value to Char value

Former Member
0 Likes
8,264

Hi Experts,

I have one query. I have one amount field. I wanted to validate that this field should not contain any text i.e. SY-ABCDE.

Example:

data: lv_var TYPE I.

LV_VAR = '100.00'.

IF LV_VAR NE SY-ABCDE.

"SOME MESSAGE

ENDIF.

While debugging I found that still control is going to inside above mentioned if condition.

Can anybody will suggest me how to write condition for it.

Thanks,

Neha

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
2,552

Hi ,

try this way...


 data: lv_var TYPE I.
 
 LV_VAR = '100.00'.
 
 IF LV_VAR NE SY-ABCDE. "comment this
 IF LV_VAR CA SY-ABCDE. "write CA if the variable contains any alphabets the below statement executes

 "SOME MESSAGE
 
 ENDIF.
 

Prabhudas

3 REPLIES 3
Read only

Tamas_Hoznek
Product and Topic Expert
Product and Topic Expert
0 Likes
2,552

If you want to work with SY-ABCDE, you should code it like IF LV_VAR CA SY-ABCDE.

But since SY-ABCDE contains only the 26 latin alphabet characters (and that in caps only), I'd rather say:

IF LV_VAR NO '1234567890 .'.
  <some message>
ENDIF.

Read only

Former Member
0 Likes
2,553

Hi ,

try this way...


 data: lv_var TYPE I.
 
 LV_VAR = '100.00'.
 
 IF LV_VAR NE SY-ABCDE. "comment this
 IF LV_VAR CA SY-ABCDE. "write CA if the variable contains any alphabets the below statement executes

 "SOME MESSAGE
 
 ENDIF.
 

Prabhudas

Read only

Former Member
0 Likes
2,552

>

> LV_VAR = '100.00'. => THis doesnt have a alphabetic value right??

> IF LV_VAR NE SY-ABCDE. ======> NE means not equal to.. and of course 100.00 is NE 'ABCD...XYZ"

> "SOME MESSAGE ==============> so it does in.

> ENDIF.

> While debugging I found that still control is going to inside above mentioned if condition.

> Neha

neha,

hope you understnad now

so for checking...

first do this...

translate lv_var to uppercase. " this is needed bychane the string contains lower case.. and sy-abcde doesnt contain lower case elements.
if lv_var CA sy-abcde.
 message 'contains chars' type 'I'.
endif.

Edited by: Soumyaprakash Mishra on Oct 12, 2009 8:33 PM