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

Validating a select-option

Former Member
0 Likes
494

Hi everyone

In my progrma I have a select-option as follows:

s_emp FOR knvv-kunnr 
          MATCHCODE OBJECT ZLG_EMP_REG_SEARCHHELP

The matchcode retricts the search help list to a sub-set of customers on the KNVV table where their KUNNR is between 1000000 and 4000000 inclusive. However, it is possible (and desirable) for users to type in a range or multiple selection in the select-option and therefore possible (but un-desirable) for them to enter values outside this range. Does anybody know of a simple way of checking that the parameters in the select-option will not result in KUNNR values that fall outside this range?

Thanks in advance

Andy

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
452

Try your example in this format:

This is the example, ijn which I am checking that the user can't enter the value which is outside the range.

IF NOT s_glacc-low IS INITIAL.

SELECT SINGLE kstar INTO v_kstar FROM csku

WHERE kstar = s_glacc-low.

IF sy-subrc = 0.

IF NOT s_glacc-high IS INITIAL.

SELECT SINGLE kstar INTO v_kstar FROM csku

WHERE kstar = s_glacc-high.

IF sy-subrc <> 0.

MESSAGE e006." WITH 'Enter Correct G/L Account Number High Value'.

ENDIF.

ENDIF.

ELSE.

MESSAGE e007." WITH 'Enter Correct G/L Account Number Low Value'.

ENDIF.

ENDIF.

Sushil.

3 REPLIES 3
Read only

Former Member
0 Likes
453

Try your example in this format:

This is the example, ijn which I am checking that the user can't enter the value which is outside the range.

IF NOT s_glacc-low IS INITIAL.

SELECT SINGLE kstar INTO v_kstar FROM csku

WHERE kstar = s_glacc-low.

IF sy-subrc = 0.

IF NOT s_glacc-high IS INITIAL.

SELECT SINGLE kstar INTO v_kstar FROM csku

WHERE kstar = s_glacc-high.

IF sy-subrc <> 0.

MESSAGE e006." WITH 'Enter Correct G/L Account Number High Value'.

ENDIF.

ENDIF.

ELSE.

MESSAGE e007." WITH 'Enter Correct G/L Account Number Low Value'.

ENDIF.

ENDIF.

Sushil.

Read only

Former Member
0 Likes
452

Hi,

use below logic.

ranges:r_kunnr for knvv-kunnr.

initialization;.

r_kunnr-sign = 'I'.

r_kunnr-option = 'BT'.

r_kunnr-low = 1000000.

r_kunnr-high = 4000000 .

append r_kunnr.

At selction screen.

read table r_kunnr index 1.

if not s_emp[] is initial.

delete s_emp where not low in r_kunnr-low.

if sy-subrc eq 0.

message 'invalid range'.

endif.

delete s_emp where not high in r_kunnr-high.

if sy-subrc eq 0.

message 'invalid range'.

endif.

endif.

Regards

Amole

Read only

0 Likes
452

Thanks for your replies.

I opted for Amole's solution as it didn't involve any reads of the database. However, I modified it so that it doesn't delete the data.

Thanks again

Andy