2007 Jan 16 10:42 AM
Hi,
In my program,I have one 'Period' select option,having string length '3', I want only number should be entered in this select option,if user enter other than number any value then it should show an error message.
currently I am using 'CA' operator but problem in this is that out of '3' if any one contain number then instead of getting error message i am getting short dump.for it is giving error message if all '3' character are alphabet.
e.g.: 1. If Period = 388, working fine.
2. If period = ABC, Getting error message.
3. If period = p18, getting short dump.
I want the error message for third case also not a shot dump.
I used 'cO' also but the problem in his is that it not except the only one character like only '1' or '2' it want all the three field should be filled.
Can anyone help me out in his problem.
Thanks
Chetan.
Hi,
In my program,I have one 'Period' select option,having string length '3', I want only number should be entered in this select option,if user enter other than number any value then it should show an error message.
currently I am using 'CA' operator but problem in this is that out of '3' if any one contain number then instead of getting error message i am getting short dump.for it is giving error message if all '3' character are alphabet.
e.g.: 1. If Period = 388, working fine.
2. If period = ABC, Getting error message.
3. If period = p18, getting short dump.
I want the error message for third case also not a shot dump.
I used 'cO' also but the problem in his is that it not except the only one character like only '1' or '2' it want all the three field should be filled.
Can anyone help me out in his problem.
Thanks
Chetan.
2007 Jan 16 11:02 AM
2007 Jan 16 11:03 AM
Hi Chetan.
When you declare the select options declare it this way.
select-options : s_field(3) type n.
The system will automatically take care that you can enter only number of length 3.
Thanks,
Sutapa.
2007 Jan 16 11:07 AM
hi
why you do not use type n variable in your selection screen then it will accept only numeric values.
other way,
data : vdata,
pos type i.
do 3 times.
vdata = string+pos(1).
if vdata ca '<nos>'.
else.
error msg
endif.
pos = pos + 1.
enddo.
or use fm
NUMERIC_CHECK
regards
shiba dutta
2007 Jan 16 11:08 AM
Hi chetan
Instead of using 'Contains Any (CA)' operator, use the SEARCH operator.
To search a character field for a particular pattern, use the SEARCH statement as follows:
SEARCH <c> FOR <str> <options>.
The statement searches the field <c> for <str> starting at position <n1>. If successful, the return code value of SY-SUBRC is set to 0 and SY-FDPOS is set to the offset of the string in the field <c>. Otherwise, SY-SUBRC is set to 4.
use the following for <options>
<pattern> Searches for <pattern> (any sequence of characters). Trailing blanks are ignored.
PLZ REWARD POINTS
2007 Jan 16 11:18 AM
hi chetan
follow this.. it will automatically check your requirement.
if you want that move to character field... you can..
<b>data: v_num type NUM03,</b>
v_char_low type CHAR03,
v_char_high type CHAR03
<b>select-options s_number for v_num</b>.
v_char_low = s_number-low.
v_char_high = s_number-high.
Please Close this thread.. when u r problem is solved
Reward if Helpful
Regards
Naresh Reddy K
2007 Jan 16 11:20 AM
check the code with your entries .
REPORT zforum12 message-id vij.
parameters : val(3) type c.
data : final(3) type c,
cnt type i,
v type c,
n type i.
at selection-screen.
cnt = strlen( val ).
do cnt times.
move val+n(1) to v.
if v ca '0123456789'.
move v to final+n(1).
else.
message e999 with 'Not a valid input'.
endif.
n = n + 1.
if n = cnt .
exit.
endif.
enddo.
condense final no-gaps.
start-of-selection.
write:/ final .regards,
vijay
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |