Application Development 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: 

Validating a select option

Former Member
0 Kudos

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.

6 REPLIES 6

Former Member
0 Kudos

Hi Gaurav,

Put a validation at the level of data element....

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

former_member386202
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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.