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: 

Doubt in Select options??

Former Member
0 Kudos

I have a select options defined in my program. How do i check if the value entered by the user exists in the check table defined, before start-of-selection??

Also how can i give an appropriate message??

Thanks in advance

8 REPLIES 8

Former Member
0 Kudos

Hi,

U can check at a selection-screnn event.

U can pass this value to the check table and validate.

Assign points if useful.

Former Member
0 Kudos

Hi,

Check the entered value from the check table in event AT SELECTION-SCREEN ON xxxx.

xxxx is the select option.

hope this willhelp.

reward point if helpful.

- Umesh

kiran_k8
Active Contributor
0 Kudos

Prakash,

tables:mara.

data:begin of imakt occurs 0,

makt like makt-maktx,

end of imakt.

select-options s_matnr for mara-matnr.

select maktx from makt into table imakt where matnr = s_matnr.

if sy-subrc NE 0.

Message 'No Data' type 'S'

endif.

K.Kiran.

Message was edited by:

Kiran K

Former Member
0 Kudos

Hi Kiran,

My doubt is that if the user enters an absurd value in the select option i should be able to prompt him. How do i do that??

varma_narayana
Active Contributor
0 Kudos

Hi Prakash.

Check this code:

TABLES : KNA1.

SELECT-OPTIONS : S_KUNNR FOR KNA1-KUNNR.

AT SELECTION-SCREEN .

<b> SELECT * FROM KNA1 UP TO 1 ROWS WHERE KUNNR IN S_KUNNR.

ENDSELECT.

IF sy-subrc NE 0.

MESSAGE 'Customer not found with this Criteria' type 'E'.

ENDIF.</b>

reward if Helpful.

Former Member
0 Kudos

hi,

try like this.

SELECT-OPTIONS: S_MATNR LIKE MARA-MATNR.

AT SELECTION-SCREEN.

SELECT SINGLE MATNR FROM MARA WHERE MATNR = S_MATNR.

IF SY-SUBRC NE 0.

MESSAGE 'ENTER CORRECT VALUE' TYPE 'E'.

ENDIF.

IF HELPFUL REWARD SOME POINTS.

WITH REGARDS,

Suresh Aluri.

Former Member
0 Kudos

Hi

see this example you do like this

REPORT ZNNR_REPORT NO STANDARD PAGE HEADING MESSAGE-ID ZNNR LINE-SIZE 100 LINE-COUNT 65(4).

******DATA DECLARATIONS**********

DATA : BEGIN OF IT_PLANT OCCURS 0,

MATNR LIKE MARA-MATNR,

WERKS LIKE MARC-WERKS,

PSTAT LIKE MARC-PSTAT,

EKGRP LIKE MARC-EKGRP,

END OF IT_PLANT.

DATA : BEGIN OF IT_PONO OCCURS 0,

EBELN LIKE EKKO-EBELN,

EBELP LIKE EKPO-EBELP,

MATNR LIKE EKPO-MATNR,

WERKS LIKE EKPO-WERKS,

LGORT LIKE EKPO-LGORT,

END OF IT_PONO.

TABLES EKKO.

********END OF DATA DECLARATIONS*********

********SELECTION SCREEN DESIGN ***********

SELECTION-SCREEN BEGIN OF BLOCK B1 WITH FRAME TITLE TEXT-001.

PARAMETER : P_WERKS LIKE MARC-WERKS MODIF ID S1.

SELECT-OPTIONS : S_EBELN FOR EKKO-EBELN NO INTERVALS MODIF ID S2.

SELECTION-SCREEN END OF BLOCK B1.

SELECTION-SCREEN BEGIN OF BLOCK B2 WITH FRAME TITLE TEXT-004.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R1 RADIOBUTTON GROUP G1 DEFAULT 'X'.

SELECTION-SCREEN COMMENT 5(20) TEXT-002 FOR FIELD R1.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN BEGIN OF LINE.

PARAMETERS : R2 RADIOBUTTON GROUP G1.

SELECTION-SCREEN COMMENT 5(20) TEXT-003 FOR FIELD R2.

SELECTION-SCREEN END OF LINE.

SELECTION-SCREEN END OF BLOCK B2.

******END OF SELECTION SCREEN DESIGN****************

*********INITIALIZATION OF SELECTION SCREEN ELEMENTS.*****

INITIALIZATION.

P_WERKS = '1000'.

S_EBELN-LOW = '4500016926'.

S_EBELN-OPTION = 'EQ'.

S_EBELN-SIGN = 'I'.

APPEND S_EBELN.

CLEAR S_EBELN.

************END OF INITIALIZATION***********************

***********SCREEN MODIFICATIONS*******************

AT SELECTION-SCREEN OUTPUT.

LOOP AT SCREEN.

IF R1 EQ 'X' AND SCREEN-GROUP1 EQ 'S2'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

IF R2 EQ 'X' AND SCREEN-GROUP1 EQ 'S1'.

SCREEN-INPUT = 0.

MODIFY SCREEN.

ENDIF.

ENDLOOP.

********END OF SCREEN MODIFICATIONS*****************

<b>***************SCREEN VALIDATIONS *****************

at selection-screen.

SELECT SINGLE *

FROM EKKO

INTO EKKO

WHERE EBELN IN S_EBELN.

IF SY-SUBRC <> 0.

SET CURSOR FIELD 'S_EBELN-LOW'.

MESSAGE E999 WITH TEXT-005.

ENDIF.

********end of screen validation*****************</b>

<b>Reward if usefull</b>

Former Member
0 Kudos

Hi prakash

you can try the following code before event start-of-selection.

-


code start----


data: v_matnr type matnr.

at selection-screen.

  • Validate matnr field for example

clear v_matnr.

SELECT single matnr FROM mara " check table

INTO v_matnr

WHERE matnr IN s_matnr.

IF sy-subrc NE 0.

MESSAGE e001(zms). " Invalid material number

ENDIF.

-


code end----


Note:- 001 is the message number of the message class ZMS. Create message class & message no. in SE91 tcode.

Thanks,

Bhawani