Skip to Content
avatar image
Former Member

Doubt in Select options??

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

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

7 Answers

  • avatar image
    Former Member
    Oct 11, 2007 at 08:58 AM

    Hi,

    U can check at a selection-screnn event.

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

    Assign points if useful.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2007 at 08:59 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 11, 2007 at 09:00 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      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??

  • Oct 11, 2007 at 09:07 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2007 at 09:10 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2007 at 09:19 AM

    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>

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 11, 2007 at 09:22 AM

    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

    Add comment
    10|10000 characters needed characters exceeded