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

field should accept only numeric values not characters.

Former Member
0 Likes
4,517

Hi Experts,

for the following code,

SELECT-OPTIONS : I_VBELN FOR VBAK-VBELN DEFAULT 4563 TO 4965.

at run time, the low and high value range input boxes should accept only numeric values not any other values. How can I restrict that?.

Waiting for your kind reply.

Thanks in advance.

Hi Experts,

for the following code,

SELECT-OPTIONS : I_VBELN FOR VBAK-VBELN DEFAULT 4563 TO 4965.

at run time, the low and high value range input boxes should accept only numeric values not any other values. How can I restrict that?.

Waiting for your kind reply.

Thanks in advance.

11 REPLIES 11
Read only

Former Member
0 Likes
2,309

data w_vbeln(10) type n.

select-options s_vbeln for w_vbeln.

Read only

0 Likes
2,309

i need from table field.

Read only

0 Likes
2,309

Hi,

Could you please let us know what is exact scenario.

If you want to validate for numeric values only, if can use CA for pattern checking.

Use the code provided by others.

Thanks,

Sriram Ponna.

Read only

0 Likes
2,309

Do the validation like this -

SELECT VBELN up to 1 rows
from       VBAK
into        table t_tmp
where    VBLEN in S_VBELN
if sy-subrc ne 0.
 message s000(oo) with 'Invalid Sales Ord  no'.
 LEAVE LIST-PROCESSING.
endif.

If you want to do it at input level , then u ll have to shift to PARAMETERS instead of select-options. because in SELECT-OPTIONS u have the option of Wild card seraching.

if u use parameter then <b>VALUE CHECK</b> statement will do the trick for you. For select-options I guess u cant achieve it.

Read only

0 Likes
2,309

Hi, Just check my query once again.

Thnx

Read only

Former Member
0 Likes
2,309

Hi,

In the At SELCETION SCREEN event.


IF not I_VBELN -LOW CA '0123456789'.
 " Raise the error message
ENDIF.

IF not I_VBELN -HIGH CA '0123456789'.
 " Raise the error message
ENDIF.

Regards

Sudheer

Read only

0 Likes
2,309

Hi Sudheer,

Your code is not working properly.

Read only

Former Member
0 Likes
2,309

Use CA operator as in


if i_vbeln-low CA 'abcdefghijklmnopqrstuvwxyz'.
  ...Display here your error message...
endif.

or


if i_vbeln-low CN '1234567890'.
  ...Display here your error message...
endif.

Test also the i_vbeln-high.

But in case they entered a multiple single values that cannot be validate using high and low, you should use loop to validate each.

Read only

Former Member
0 Likes
2,309

ya you can do validation for VBAK-VBELN

select-options: s_vbeln for vbak-vbeln.

In main program add

AT SELECTION-SCREEN ON s_vbeln.

PERFORM sub_valid_vbeln.

FORM sub_valid_vbeln.

DATA lv_vbeln TYPE vbuk-vbeln.

  • Validation for company Code

IF s_vbeln-low IS INITIAL.

IF NOT s_vbeln-high IS INITIAL.

MESSAGE w001. "low should be added

ENDIF.

ELSE.

SELECT SINGLE vbeln FROM vbuk INTO lv_vbeln

WHERE vbeln = s_vbeln-low.

IF sy-subrc NE 0.

MESSAGE e007 WITH s_vbeln-low. " Invalid value

ENDIF.

ENDIF.

IF NOT s_vbeln-high IS INITIAL.

SELECT SINGLE vbeln FROM vbuk INTO lv_vbeln

WHERE vbeln = s_vbeln-high.

IF sy-subrc NE 0.

MESSAGE e007 WITH s_vbeln-high. " Invalid value

ENDIF.

ENDIF.

ENDFORM.

Rewards if useful....

Read only

0 Likes
2,309

Hi Minal,

Your code is working at validation level, but i need at entry or input level.

Read only

Former Member
0 Likes
2,309

Hi,

Copy paste this code .. you will understand.

<b>parameter : I_VBELN(20) type c.

data : l_len type i,

l_count type i.

initialization .

clear l_count.

At selection-screen on I_VBeLN.

l_len = STRLEN( I_VBELN ).

Do l_len times.

If I_VBELN+l_count(1) CA sy-abcde.

Message 'error' type 'E'.

endif.

l_count = l_count + 1.

enddo.

start-of-selection.

write I_VBELN.</b>

rewards if useful.

regards,

nazeer