Function Terminates current dialog step with an error message
Example ABAP
s10errormessage( ). 
Format ABAP
data:
  myexplanation type string,
  myhtmlformat type string,
  mymsgid type sy-msgid,
  mymsgno type sy-msgno,
  mynoexplanation type string,
  mypar1 type string,
  mypar2 type string,
  mypar3 type string,
  mypar4 type string,
  mytext type string.

  s10errormessage(
    exporting
      explanation = myexplanation
      htmlformat = myhtmlformat
      msgid = mymsgid
      msgno = mymsgno
      noexplanation = mynoexplanation
      par1 = mypar1
      par2 = mypar2
      par3 = mypar3
      par4 = mypar4
      text = mytext ). 
Parameters
Name Type Description
explanation string
Message explanation
htmlformat string
'X' = message text is in HTML
msgid sy-msgid
Message Id table T100
msgno sy-msgno
Message number table T100
noexplanation string
No explanation display
par1 string
Message parameter 1
par2 string
Message parameter 2
par3 string
Message parameter 3
par4 string
Message parameter 4
text string
Messsage text
Description By s10errormessage() the current dialog step is terminated and an error message is displayed. Example: 

ABAP

if vtimehhmm > etimehhmm.
  s10errormessage( 'Start time is after end time' ).
endif. 

If you have defined an element of the class in the HTML page

HTML

<div class="messagearea"></div>

the message will be displayed there. Otherwise, it appears as a popup:

The popup is displayed below the HTML element that triggered the action, in this example the Save button.

If an explanation is to be displayed with the error message, the display as a popup is always used.

If the error message results from a check method of the object, the attribute to be checked receives the input focus. If several attributes are checked, the first attribute receives the input focus.

ABAP

* validations
   methods:
      validate_time
        importing
          vtimehhmm type string
          etimehhmm type string.   method validate_time.

* correct times?
    if vtimehhmm > etimehhmm.
      s10errormessage( 'Start time is after end time' ).
    endif.

  endmethod. 
The message text can either be specified directly or stored in the SAP message table T100 depending on the language. For the T100 table, specify the parameters "msgid" and "msgno". For application specific language dependent messages you can also use the function  s10localize() :

ABAP

s10errormessage( s10localize( 'TIME_INTERVAL_ERROR' ) ).

The placeholders &1, &2, &3, &4 will be replaced in the text by the specified variable values. When passing the parameters, remember to produce the external format so that, for example, a customer number is displayed without leading zeros. Example:

ABAP
s10errormessage( 
      exporting 
          msgid = 'F2' 
          msgno = '153' 
          par1 = s10getuservalue( 'kunnr' ) ). 

If you use a message from table T100, the explanation of the message stored in the SAP system is also displayed.

Example of using a standard SAP message with explanation:

ABAP

s10errormessage(
         exporting
           msgid = '00'
           msgno = '058'
           par1 = search_land1
           par4 = 'T005'). 

You can suppress the explanation with the parameter "noexplanation = 'X' ".

The message itself is output as text without formatting. If you need special formatting, you can set the parameter "htmlformat = 'X' " and use HTML in the message text:

ABAP

s10errormessage(
         exporting
          text = |Country key  |
                 && search_land1 && || 
                 && | not included in table T005|
          htmlformat = 'X' ). 

This then also refers to an explanation given with "explanation":

ABAP

s10errormessage(
exporting
 text = |Country key  <span style='font-weight:bold;color:red'>|
        && search_land1 && |</span>| 
        && | not included in table <b>T005</b>|
  explanation  = |<b>Note</b>|
        && |<br>The country table T005 is maintained by SAP |
        && |in client 000 by Support Packages.|
  htmlformat  = 'X' ). 

 

Components S10 Framework