‎2006 Sep 05 12:48 PM
Hi everyone
In my progrma I have a select-option as follows:
s_emp FOR knvv-kunnr
MATCHCODE OBJECT ZLG_EMP_REG_SEARCHHELPThe 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
‎2006 Sep 05 12:58 PM
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.
‎2006 Sep 05 12:58 PM
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.
‎2006 Sep 05 1:13 PM
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
‎2006 Sep 05 4:49 PM
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