12-22-2014 5:20 PM
Hi All,
I'm uploading an XL file.
One field needs to be validated as having only numbers between '1' and '999'. It is of type char 3.
I tried LV_NUM CO '0123456789', but it does not work for single character numbers like '1'.
Please help.
Thanks,
Venkat
12-22-2014 5:29 PM
Hi venkat,
You can try CA instead of CO.
Sample code:
DATA: LV_NUM TYPE c LENGTH 3 VALUE '1'.
IF LV_NUM CA '0123456789'.
WRITE: / 'CONTAINS'.
ELSE.
WRITE: / 'NOT CONTAINS'.
ENDIF.
12-22-2014 5:38 PM
I tried CA but then special characters can come in it...then it fails...
12-22-2014 5:59 PM
Please give any example of special characters so I understand the situation.
12-23-2014 12:41 AM
For single charcter numbers the variable is also considering the trailing spaces as the character length is C. You probably need to truncate the trailing spaces or define as string.
12-23-2014 2:27 AM
Hi Venkat,
You will have to probably try as below: You will have to give a space as below:
LV_NUM CO '0123456789 '.
Thanks,
Naveen
12-23-2014 4:04 AM
Hi Venkat,
Please find the below code.
DATA: LV_NUM TYPE CHAR3.
LV_NUM = '12'.
IF LV_NUM CO '0123456789 '. "Add empty space after 9...
WRITE 'EQUAL'.
ELSE.
WRITE 'NOT EQUAL'.
ENDIF.
Also find the link below for string comparison
String Comparison operators - ABAP Development - SCN Wiki
Regards
Rajkumar Narasimman
12-23-2014 4:58 AM
Hi,
Try with CO.
DATA: LV_NUM TYPE c LENGTH 3 VALUE '123'.
IF LV_NUM CO '0123456789'.
WRITE: / 'CONTAINS'.
ELSE.
WRITE: / 'NOT CONTAINS'.
ENDIF.
It will not consider special characters.