11-01-2007 11:28 AM
What is the best way to validate a select option on the selection screen. Is there any way to do it without firing a select query.
11-01-2007 11:32 AM
11-01-2007 11:32 AM
That depends on what you want to validate e.g. something like
if s_bukrs[] is initial.
set cursor field 'S_BUKRS-LOW'.
message e398(00) with 'Enter a Company Code range'
space space space.
endif.
may be fine for basic proofing, and with small tables (esp. buffered ones) a quick trip to the database would not hurt (e.g. T001 for the above example). But doing a huge search through BKPF & BSEG to just check the screen parms is probablynot a great idea.
Jonathan
11-01-2007 11:35 AM
Hi,
Write Validation code with in Start-of-selection before firing SELECT query..if you found any incorrect data...
give some message and
SUBMIT zreport VIA SELECTION SCREEN.
Message was edited by:
Perez C
11-01-2007 11:37 AM
Hi,
If you want to validate the select options you can do it in at selection-screen event.
Please look at the below code :
tables : bsis.
select-options : so_bukrs like bsis-bukrs.
ranges : gr_bukrs for bsis-bukrs.
initialization.
gr_bukrs-sign = 'I'.
gr_bukrs-option = 'BT'.
gr_bukrs-low = '1005'.
append gr-bukrs.
at selection-screen.
delete so_bukrs where low in so_bukrs.
By doing this you can restrict the select statement not to retrive the data for 1005. even user inputs 1005 in the selection screen.
Thanks,
Sriram Ponna.
11-01-2007 11:39 AM
Hi,
Refer This code.
----
AT SELECTION SCREEN *
----
AT SELECTION-SCREEN.
*--This perform verify the material number in table MCHB.
PERFORM validate_material.
&----
*& Form validate_material *
&----
This form will verify the material number in table MCHB *
----
FORM validate_material.
*--It will verify the material number in table MCHB.
SELECT matnr UP TO 1 ROWS "Material Number
FROM mchb "Material Master
INTO mchb-matnr
WHERE matnr IN s_matnr.
ENDSELECT.
*--Check SUBRC
IF sy-subrc <> 0 AND mchb-matnr IS INITIAL.
*--Invalid Material
MESSAGE e065.
ENDIF.
CLEAR mara.
ENDFORM. "validate_material
Regards,
Prashant
11-01-2007 11:40 AM
You have to fire a select query within AT selection-screen ON event and fetch for only single record...
Something like...
Select matnr from mara
into lv_matnr
up to 1 rows
where matnr in s_matnr.
endselect.
if sy-subrc <> 0.
error.
endif.
Here you are just validating if a single valid record is found within the range then we should go ahead with the processing.