cancel
Showing results for 
Search instead for 
Did you mean: 

Error Messages.

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Former Member
0 Kudos

Hello John. Your code works but it disables all other fields in selection screen after giving the error messaage. It does not allow to select the other fields.

And i even have to check other selection screen fields for errors.

Regards

Rahul

andreas_mann3
Active Contributor
0 Kudos

??? - the user formerly must correct his input !!!

otherwise use only at selection-screen.

regards Andreas

Former Member
0 Kudos

hi,

in this case you should give the correct value in that field then all the other fields get enabled

cheers,

sasi

Former Member
0 Kudos

hi

AT SELECTION-SCREEN ON SHP_PNT

if you display any error under this event you must give the correct value until then it won't allow further inputs

cheers,

sasi

Former Member
0 Kudos

Hi Rahul.

Sorry for the 3 minutes delay... (I think it is very annoying that while you post a question to me, a lot of people want to answer the question for me).

Your problem can be solved by using the AT_SELECTION_SCREEN ON BLOCK <name of the block>. In that case all fields of the block remain open for input.

Kind regards,

John.

Former Member
0 Kudos

Hello John it works good. But...

iF have to raise message for each and every selection scren options...the code will be too long.

Is it possible to raise the messages for each field whn twhere the error occurs..

at selection-screen on block bb.

select count( * )

from dbtable (all the fields iam validating are present in tht table)

where vstel in shp_pnt

and vbeln in delv_no.

if syst-dbcnt = 0.

message e000.

message e001 ---for ord_no

message e002 ---for del no.

.

.

.

endif.

We must raise the error messages whn ever the error occurs in that particular sclection screen field.

Regards

Rahul.

Former Member
0 Kudos

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.

Answers (2)

Answers (2)

Former Member
0 Kudos

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

Former Member
0 Kudos

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