Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

how to display error message in abap

Former Member
0 Kudos

How to dispaly error message in report?

i have to check the range bewteen two days and if it is not in range have to display error message only once.

next time if i press the execute button report will get executed without showing the warning message.

i am calculating the days between two dates, i am displaying the error message but if i press the execute button i will not allow me to execute the report.it again shows me the error message.i have to skip this in 2nd time.

can any one suggest what to do with this?

7 REPLIES 7

Former Member
0 Kudos

Hi Manas, Check the below code...


PARAMETERS p_matnr TYPE mara-matnr.
DATA lv_msg_ct TYPE c.

INITIALIZATION.
  CLEAR lv_msg_ct.

AT SELECTION-SCREEN.

  IF sy-ucomm EQ 'ONLI'.
    IF lv_msg_ct IS INITIAL.
      lv_msg_ct = 'X'.
      MESSAGE E208(00) WITH 'Error' .
    ELSE.
      MESSAGE s208(00) WITH 'Message'.
    ENDIF.
  ENDIF.

0 Kudos

hello suman,

i am using select-option in my report. And i have to check the difference between two dates in select option input box( low-value and high-value). if it is greater then suppose 10 then i have to display warning message at once and then if click on execute button , the report should get executed without showing any warning messages in report.

here i am attaching my source code.please take a close look and tell me where should i have to make change.

SELECT-OPTIONS :s_bedat FOR ekko-bedat.

AT SELECTION-SCREEN ON s_bedat.

IF NOT s_bedat IS INITIAL.

PERFORM bedat_validate. " Perform for Purchasing Document Date Validation

ENDIF.

FORM bedat_validate . " Form for Purchasing Document Date Validation

DATA : diffr TYPE i.

CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'

EXPORTING

i_datum_bis = s_bedat-high

i_datum_von = s_bedat-low

  • I_KZ_EXCL_VON = '0'

  • I_KZ_INCL_BIS = '0'

  • I_KZ_ULT_BIS = ' '

  • I_KZ_ULT_VON = ' '

  • I_STGMETH = '0'

  • I_SZBMETH = '1'

IMPORTING

e_tage = diffr

  • EXCEPTIONS

  • DAYS_METHOD_NOT_DEFINED = 1

  • OTHERS = 2

.

IF sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

ELSE.

IF diffr GT 31.

MESSAGE s009(zerrormsg) WITH text-000 DISPLAY LIKE 'W'.

LEAVE TO LIST-PROCESSING.

ENDIF.

ENDIF.

ENDFORM. " BEDAT_VALIDATE

0 Kudos

As mentioned earlier, you have to use a flag variable to show the message once. Check the below code.


TABLES ekko.

DATA lv_msg_ct TYPE c.

SELECT-OPTIONS :s_bedat FOR ekko-bedat.

INITIALIZATION.
  CLEAR lv_msg_ct.


AT SELECTION-SCREEN ON s_bedat.
  LOOP AT s_bedat.
    IF NOT s_bedat-low IS INITIAL AND NOT s_bedat-high IS INITIAL.
      PERFORM bedat_validate. " Perform for Purchasing Document Date Validation
    ENDIF.
  ENDLOOP.

START-OF-SELECTION.

  WRITE:/ 'Display output'.

*&---------------------------------------------------------------------*
*&      Form  bedat_validate
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
FORM bedat_validate . " Form for Purchasing Document Date Validation
  DATA : diffr TYPE i.
  CALL FUNCTION 'DAYS_BETWEEN_TWO_DATES'
    EXPORTING
      i_datum_bis             = s_bedat-high
      i_datum_von             = s_bedat-low
    IMPORTING
      e_tage                  = diffr
    EXCEPTIONS
      days_method_not_defined = 1
      OTHERS                  = 2.
  IF sy-subrc EQ 0.
    IF diffr GT 31 AND lv_msg_ct IS INITIAL.
      lv_msg_ct = 'X'.
      MESSAGE e009(zerrormsg) DISPLAY LIKE 'W' WITH text-000 .
    ENDIF.

  ENDIF.

ENDFORM. " BEDAT_VALIDATE

0 Kudos

Thank u suman.....It's working ..

Thank u so much!!!!!

raymond_giuseppi
Active Contributor
0 Kudos

The classic way should have been to sent a "W" warning message and not an "E" error message, so user can either correct the dates range or press Enter to ignore.

Regards,

Raymond

0 Kudos

hi Raymond,

yes u r right.....i am sending warning message instead of sending it like an error message.

Thnks 4 ur solution...

Regards

Manas

Former Member
0 Kudos

Please do not use TYPE 'E' as error message use type 'W' for warning as then user by pressing enter can continue.