Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

ABAP programming: Data validation

Hi everybody,

I wanted to know how to display error messages if a user enters invalid data at the selection screen in a particular select-options field. Also the selection screen should be redisplayed after the message.

thanks

Tags:
Former Member
Former Member replied

Hi,

Check this code

REPORT z_sdn.
TABLES:
  vbak.

DATA:
  w_vbeln TYPE vbak-vbeln.

SELECT-OPTIONS:
  s_vbeln  FOR vbak-vbeln.             " Sales Document

*----------------------------------------------------------------------*
*                 AT SELECTION-SCREEN ON s_vbeln EVENT
*----------------------------------------------------------------------*
AT SELECTION-SCREEN ON s_vbeln.

* Subroutine to validate the sales document entered by user.
  PERFORM f0000_validate_sales_doc.

START-OF-SELECTION.
  WRITE: / 'TEST'.
*&---------------------------------------------------------------------*
*&      Form  f0000_validate_sales_doc
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM f0000_validate_sales_doc .

  IF s_vbeln[] IS NOT INITIAL.
* Select query to fetch sales document
    SELECT vbeln                       " Sales Document
      FROM vbak
      INTO w_vbeln
     UP TO 1 ROWS
     WHERE vbeln IN s_vbeln.

    ENDSELECT.                         " SELECT vbeln
    IF sy-subrc NE 0.
      MESSAGE 'The entries you have specified do not exist in master table' TYPE 'E'.
    ENDIF.                             " IF sy-subrc NE 0.
    CLEAR w_vbeln.
  ENDIF.                               " IF s_vbeln IS NOT INITIAL

Regards

Abhijeet

0 View this answer in context
Not what you were looking for? View more on this topic or Ask a question