Skip to Content
author's profile photo Former Member
Former Member

validations on selections

hi guru's ,

i developed report with select options.....,

if no data found in the with that selections criteria , i want see the error message that

no data found .........

and returns to the output screen

hw can i achieve it.

Regards

Anand.N

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 11:23 AM

    HI

    see this report , if you give wrong data or if don't give any data that will be send an error

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

    <b>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.</b>

    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>

    START-OF-SELECTION.

    *set pf-status '100'.

    IF R1 EQ 'X'.

    SELECT MATNR

    WERKS

    PSTAT

    EKGRP

    FROM MARC

    INTO TABLE IT_PLANT

    WHERE WERKS = P_WERKS.

    LOOP AT IT_PLANT.

    WRITE : SY-VLINE , 2 IT_PLANT-MATNR COLOR COL_KEY,

    21 SY-VLINE , 22 IT_PLANT-WERKS COLOR COL_KEY,

    27 SY-VLINE ,28 IT_PLANT-PSTAT COLOR COL_NORMAL,

    43 SY-VLINE ,44 IT_PLANT-EKGRP COLOR COL_NORMAL.

    ENDLOOP.

    ENDIF.

    IF R2 EQ 'X'.

    SELECT EBELN EBELP MATNR WERKS LGORT

    FROM EKPO

    INTO TABLE IT_PONO

    WHERE EBELN IN S_EBELN.

    LOOP AT IT_PONO.

    WRITE : SY-VLINE , 2 IT_PONO-EBELN COLOR COL_KEY,

    12 SY-VLINE , 13 IT_PONO-EBELP COLOR COL_KEY,

    18 SY-VLINE , 19 IT_PONO-MATNR COLOR COL_NORMAL,

    37 SY-VLINE , 38 IT_PONO-WERKS COLOR COL_NORMAL,

    44 SY-VLINE , 45 IT_PONO-LGORT COLOR COL_NORMAL, 49 SY-VLINE..

    ENDLOOP.

    ENDIF.

    TOP-OF-PAGE.

    IF R1 EQ 'X'.

    *ULINE AT /1(48).

    WRITE : SY-VLINE ,2 'MATERIAL NUMBER',

    21 SY-VLINE , 22 'PLANT',

    27 SY-VLINE , 28 'STATUS',

    43 SY-VLINE , 44 'GRUP', 48 SY-VLINE.

    ULINE AT /1(48).

    ENDIF.

    IF R2 EQ 'X'.

    WRITE : SY-VLINE , 2 'PO NUMBER',

    12 SY-VLINE, 13 'ITEM',

    18 SY-VLINE,19 'MATERIAL NUMBER',

    37 SY-VLINE, 38 'PLANT',

    44 SY-VLINE, 45 'GRUP',

    49 SY-VLINE.

    ULINE AT /1(50).

    ENDIF.

    END-OF-PAGE.

    ULINE AT /1(50).

    WRITE :/10 'PAGE NUMBER', SY-PAGNO.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 11:28 AM

    hi,

    select data into internal table using that selection criteria, and than check that internal table is empty or not by,

    SELECT matnr FROM mara INTO CORRESPONDING FIELDS OF TABLE itab WHERE matnr = '000' (ur condition).

    IF itab[] IS INITIAL.

    WRITE 'No data Found'.

    ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 11:32 AM

    Hi,

    In start of selection event check SY-SUBRC value .

    START-OF-SELECTION.
    
    SELECT ....... where <field> in <select-option>. "select statement
      IF sy-subrc <> 0.
        MESSAGE 'Data NOT Found' TYPE 'S'.
        SUBMIT (sy-repid) VIA SELECTION-SCREEN.
      ENDIF.

    Add a comment
    10|10000 characters needed characters exceeded

  • author's profile photo Former Member
    Former Member
    Posted on Nov 20, 2007 at 11:35 AM

    Hi Anand,

    Use this code :

    Select-options : s_matnr for mara-matnr.

    At Selection-Screen.

    Select matnr into table t_matnr from mara where matnr in s_matnr.

    if t_matnr is initial.

    message e001. "e001- no data found

    endif.

    Regards,

    Hemant

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 20, 2007 at 11:42 AM

    Hi,

    Refer this code

    &----


    *& Form sub_alv_display *

    &----


    • This form displays the output using REUSE_ALV_GRID_DISPLAY *

    • function module *

    ----


    FORM sub_alv_display .

    *--Local Internal Table

    DATA : li_sort TYPE slis_t_sortinfo_alv.

    *--Define print list

    wa_print-no_print_listinfos = c_chk.

    wa_print-no_coverpage = c_chk.

    *--If the No zero stock lines is checked in the selection screen

    IF p_sline IS NOT INITIAL.

    DELETE i_final WHERE einme = c_zero.

    ENDIF.

    IF NOT i_final[] IS INITIAL.

    *--Call the function module to display the ALV report

    CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'

    EXPORTING

    i_callback_program = v_repid

    is_layout = wa_layout

    it_fieldcat = i_fieldcat

    i_default = c_chk

    i_save = c_save

    is_variant = wa_variant

    it_events = i_events

    is_print = wa_print

    it_sort = li_sort

    TABLES

    t_outtab = i_final

    EXCEPTIONS

    program_error = 1

    OTHERS = 2.

    IF sy-subrc <> 0.

    MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

    ENDIF.

    ELSE.

    *--No data found for the given selection criteria.

    MESSAGE i001.

    LEAVE LIST-PROCESSING.

    ENDIF.

    ENDFORM. "sub_alv_display

    Reward points

    Reagrds,

    Prashant

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.