Skip to Content
0
Former Member
Oct 20, 2005 at 12:13 PM

Error Messages.

54 Views

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.