on 10-20-2005 1:13 PM
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.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.