05-16-2008 4:10 PM
Hi ,
i have a field on the selection screen where i am giving range of values .
using at selection on field , i want to check for all the vlaues in the ranges whether they are vaild or not .
ex : for plant : 100 -200. (range ) .
want to check whether the values from 100 to 200 are valid .
Thank you in advance . let me know please .
Regards,
Ry
05-16-2008 4:17 PM
Hi,
I don't know if I understood you right.
Like this?
TABLES mara.
SELECT-OPTIONS s_matnr FOR mara-matnr.
AT SELECTION-SCREEN ON s_matnr.
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr EQ s_matnr-low.
IF sy-subrc NE 0.
MESSAGE e000(zsd1) WITH '...'.
ENDIF.
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr EQ s_matnr-high.
IF sy-subrc NE 0.
MESSAGE e000(zsd1) WITH '...'.
ENDIF.
Or with several lines in options:
TABLES mara.
SELECT-OPTIONS s_matnr FOR mara-matnr.
AT SELECTION-SCREEN ON s_matnr.
LOOP AT s_matnr.
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr EQ s_matnr-low.
IF sy-subrc NE 0.
MESSAGE e000(zsd1) WITH '...'.
ENDIF.
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr EQ s_matnr-high.
IF sy-subrc NE 0.
MESSAGE e000(zsd1) WITH '...'.
ENDIF.
ENDLOOP.
Best regards.
Valter Oliveira.
05-16-2008 5:19 PM
HI Valter,
Thanks for the suggestion , but i have values 1 , 2 , 3 , 4 , 5.
in which 3 and 4 are invalid .
when i go with your suggestions , even with the loop at the select option field it checks only 1 and 5 .
suggest please.
regards,
Ry
05-16-2008 4:21 PM
Hi,
In the following code, i hav done the validation for EBELN.
In place of EBELN, you need to use Plant.
Your requirement will be fullfilled.
you declare internal table accordingly....in place of it_ebeln.
----
AT SELECTION-SCREEN ON
----
AT SELECTION-SCREEN ON so_ebeln.
PERFORM validate_ebeln.
&----
*& Form validate_ebeln
&----
FORM validate_ebeln.
SELECT ebeln
FROM ekpo
INTO TABLE it_ebeln
WHERE ebeln IN so_ebeln.
IF sy-subrc NE 0.
MESSAGE e020(z50871msg) WITH text-014.
ENDIF.
ENDFORM.
regards
Sandeep Reddy
05-16-2008 5:19 PM
Hi,
You can do in the following way.
suppose you want to know whether the enter value for a particular field is valid or not.
suppose plant 100-200.
1) during initialization bring the plant data into the plant internal table it_werks.
select werks from marc into table it_werks.
2)during at selection-screen on s_werks
write select statement as follows :
select single werks from it_werks into lv_werks where werks in s_werks.
if sy-subrc <> 0.
error message.
endif.
Hope its clear for you.
Reward points if helpful.
Thanks and Regards.
05-16-2008 5:34 PM
Hello again.
Ok, I thought it was only the first and last element.
To check all try this:
TABLES mara.
DATA: w_matnr TYPE matnr.
SELECT-OPTIONS s_matnr FOR mara-matnr NO-EXTENSION.
AT SELECTION-SCREEN ON s_matnr.
LOOP AT s_matnr.
w_matnr = s_matnr-low.
DO.
SELECT SINGLE matnr FROM mara INTO mara-matnr WHERE matnr EQ w_matnr.
IF sy-subrc NE 0.
MESSAGE e000(zsd1) WITH '...'.
ENDIF.
IF w_matnr = s_matnr-high.
EXIT.
ELSE.
ADD 1 TO w_matnr.
CALL FUNCTION 'CONVERSION_EXIT_ALPHA_INPUT'
EXPORTING
input = w_matnr
IMPORTING
output = w_matnr.
ENDIF.
ENDDO.
ENDLOOP.
Note the NO-EXTENSION statement. If you don't include it, you have to exclude from validation, the ones that user excluded himsetf (ex: he wants 1-5 except 4).
Best regards.
Valter Oliveira.
05-16-2008 5:38 PM
Hi,
Try to use this:
tables: t001w.
select options so_werks for t001w-werks.
select werks from t001w
into lt_werks
where werks in so_werks.
Into lt_werks there is all valid werks.
Regards,
Fernando
05-16-2008 8:19 PM
Why would you need to check the Value Range to see if they are valid? If they do not exist, there will be no data selected for those values.
EG: s_Range = 100 to 200.
select matnr bwkey
into corresponding fields of table i_mbew
from mbew
where bwkey in s_Range.
What are you trying to accomplish by checking the Values in the Rgange?
05-16-2008 8:23 PM
hi check this simple example...
tables:mara.
select-options:s_matnr for mara-matnr.
data: v_matnr(18) type c ,
wa(30) type c .
loop at s_matnr into wa .
clear v_matnr .
select single matnr from mara into v_matnr
where matnr = wa+3(18).
if sy-subrc ne 0.
write:/ ' material is not valid'.
else.
write:/ 'material processed'.
endif.
endloop.
regards,
venkat