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

Error Messages.

Hello Every one.

I need help on displaying error messages.

I have declared a selection screen with 5 selection options.

When i enter the value in it, if it dose not present in the database table, it must throw an error. Its like validating the fields.

I have already declared the messages.

for eg.

if shp_pnt <> dbtable(shpping point)

messagee0001

endif.

iam unable to validate. If some one can give me the code for it that will be great.

Thanks in advance.

REPORT ZTPCONRP MESSAGE-ID ZO NO STANDARD PAGE HEADING.

TABLES: ZTPCON,

ZTPCTL,

ZTPSHP.

DATA: BEGIN OF I_ZTPCTL OCCURS 0,

VSTEL LIKE ZTPCTL-VSTEL,

ORDNO LIKE ZTPCTL-ORDNO,

VBELN LIKE ZTPCTL-VBELN,

INTERDATE LIKE ZTPCTL-INTERDATE,

ACK(1) TYPE C,

END OF I_ZTPCTL.

DATA: BEGIN OF I_ZTPCON OCCURS 0,

ORDNO LIKE ZTPCON-ORDNO,

VBELN LIKE ZTPCON-VBELN,

CONFTIME LIKE ZTPCON-CONFTIME,

CONFDATE LIKE ZTPCON-CONFDATE,

END OF I_ZTPCON.

DATA: BEGIN OF ITAB OCCURS 0,

VSTEL LIKE ZTPCTL-VSTEL,

ORDNO LIKE ZTPCTL-ORDNO,

VBELN LIKE ZTPCTL-VBELN,

INTERDATE LIKE ZTPCTL-INTERDATE,

CONFDATE LIKE ZTPCON-CONFDATE,

CONFTIME LIKE ZTPCON-CONFTIME,

ACK(1) TYPE C,

END OF ITAB.

DATA: V_VSTEL LIKE ZTPCTL-VSTEL.

SELECTION-SCREEN: BEGIN OF BLOCK BB.

SELECT-OPTIONS: SHP_PNT FOR ZTPCTL-VSTEL OBLIGATORY NO INTERVALS,

ORD_NO FOR ZTPCTL-ORDNO,

DELV_NO FOR ZTPCTL-VBELN,

CRE_DATE FOR ZTPCTL-ERDAT,

TRN_DATE FOR ZTPCTL-INTERDATE.

SELECTION-SCREEN END OF BLOCK BB.

INITIALIZATION.

CRE_DATE-HIGH = SY-DATUM.

TRN_DATE-HIGH = SY-DATUM.

APPEND CRE_DATE.

APPEND TRN_DATE.

  • at selection-screen.

  • select vstel

  • from ztpctl into v_vstel

  • where vstel in shp_pnt

  • and ordno in ord_no

  • and vbeln in delv_no

  • and erdat in cre_date

  • and interdate in trn_date.

  • endselect.

START-OF-SELECTION.

SELECT VSTEL ORDNO VBELN INTERDATE

FROM ZTPCTL INTO TABLE I_ZTPCTL

WHERE VSTEL IN SHP_PNT

AND ORDNO IN ORD_NO

AND VBELN IN DELV_NO

AND ERDAT IN CRE_DATE

AND INTERDATE IN TRN_DATE.

IF NOT I_ZTPCTL[] IS INITIAL.

SELECT ORDNO VBELN CONFTIME CONFDATE

FROM ZTPCON INTO TABLE I_ZTPCON

FOR ALL ENTRIES IN I_ZTPCTL

  • where ordno = i_ztpctl-ordno.

WHERE VBELN = I_ZTPCTL-VBELN.

ENDIF.

SORT I_ZTPCON BY ORDNO.

SORT I_ZTPCTL BY ORDNO.

LOOP AT I_ZTPCTL.

CLEAR I_ZTPCON.

READ TABLE I_ZTPCON WITH KEY VBELN = I_ZTPCTL-VBELN

  • read table i_ztpcon with key vbeln = i_ztpctl-vbeln

BINARY SEARCH.

IF SY-SUBRC EQ 0.

I_ZTPCTL-ACK = 'Y'.

MOVE I_ZTPCTL-VSTEL TO ITAB-VSTEL.

MOVE I_ZTPCTL-ORDNO TO ITAB-ORDNO.

MOVE I_ZTPCTL-VBELN TO ITAB-VBELN.

MOVE I_ZTPCTL-INTERDATE TO ITAB-INTERDATE.

MOVE-CORRESPONDING I_ZTPCON TO ITAB.

MOVE I_ZTPCTL-ACK TO ITAB-ACK.

APPEND ITAB.

CLEAR ITAB.

ELSE.

I_ZTPCTL-ACK = 'N'.

MOVE I_ZTPCTL-VSTEL TO ITAB-VSTEL.

MOVE I_ZTPCTL-VBELN TO ITAB-VBELN.

MOVE I_ZTPCTL-ORDNO TO ITAB-ORDNO.

MOVE I_ZTPCTL-INTERDATE TO ITAB-INTERDATE.

MOVE I_ZTPCTL-ACK TO ITAB-ACK.

APPEND ITAB.

CLEAR ITAB.

ENDIF.

ENDLOOP.

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2005 at 12:19 PM

    Hi Kesi,

    Just add:

    AT SELECTION-SCREEN ON SHP_PNT.

    select count( * )

    from tvst

    where vstel in shp_pnt.

    if syst-dbcnt = 0.

    message E001.

    endif.

    Regards,

    John.

    Add a comment
    10|10000 characters needed characters exceeded

    • Former Member Former Member

      Hi Rahul,

      Either you perform your validation for a block (thus leaving all select options input enabled) or you validate per selection option.

      There is no possibility to leave all fields input enabled while giving an error for just one field.

      Regards,

      John.

  • author's profile photo Former Member
    Former Member
    Posted on Oct 20, 2005 at 12:17 PM

    hi

    the error message like message e0001(Zo)

    for validating selection screen fields use

    AT Selection-Screen output on S_Matnr

    select single matnr from mara into test_matnr where

    matnr in s_matnr

    if sy-subrc <> 0

    message E001(Z0)

    endif

    cheers,

    sasi

    Message was edited by: sasikumar palanichamy

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 20, 2005 at 12:23 PM

    Why are you not able to do the validation and give messages in the AT SELECTION-SCREEN event?

    You will not normally validate select options as they represent a range of values and some of them may be valid. You will try to validate each one in that range. Instead, you will just try to get the data and if no data is retrieved, you can give a message "No data selected for the given criteria".

    If you want to validate the whole range, then in your at selection screen event do something like this.

    select * from <check table for shipping point>

    *(I dont remember which one it is I think it is TVST)

    where vstel in SHP_PNT.

    if sy-subrc <> 0.

    • no shipping point in the range is valid

    error message

    endif.

    Do not do it against your Z table because I think your Z table is not the value table for shipping points. All other select options, do not validate them.

    Srinivas

    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.