ABAP: Message usage

Source: Internet
Author: User

In the SAP system, message is provided to users.ProgramAn important means of running information. The following is the help in the SAP system.

Message

Variants:

1.Message xnnn.

2.Message ID type mtype number n.

3.Message xnnn (MID ).

4.Message MSG type mtype.

Effect

Sends a message. messages are stored in the tableT100, Are processed using transaction se91 and can be created by Forward Navigation.

The ABAP runtime environment handles messages according to the type declared inMessageStatement and the context in which the message was sent. The following message types exist:

A-abend
: Transaction terminated
E-Error
: Error message
I-Info
: Information
S-status
: Status message
W-warning
: Correction possible
X-exit
: Transaction terminated with short dump

Messages are mainly used to handle user input on screens. The following table shows the behavior of each Message Type in each context. An explanation of the numbers used is wrongly ded at the end of the table:

A e I s w x
------------------------------------------------------------
Pai Module 1 2 3 4 5 6
Pai module for Poh 1 7 3 4 7

6
Pai module for POV 1 7 3 4 7

6
--------------------------------------------------------------
At selection-screen... 1 8 3 4 9 6
At selection-screen for Poh 1 7 3 4 7 6
At selection-screen for POV 1 7 3 4 7 6
At selection-screen on Exit 1 7 3 4 7 6
--------------------------------------------------------------
At line-selection 1 10 3 4 10 6
At PFN 1 10 3 4 10 6
At user-command 1 10 3 4 10 6
--------------------------------------------------------------
Initialization 1 11 3 4 11 6
Start-of-selection 1 11 3 4 11 6
Get 1 11 3 4 11 6
End-of-selection 1 11 3 4 11 6
--------------------------------------------------------------
Top-of-page 1 11 3 4 11 6
End-of-page 1 11 3 4 11 6
Top-of-page... 1 10 3 4 10 6
--------------------------------------------------------------
Load-of-Program 1 1 4 4 6
--------------------------------------------------------------
PbO Module 1 1 4 4 4 6
At selection-screen output 1 1 4 4 6
--------------------------------------------------------------
Procedure: see

Messages
--------------------------------------------------------------

  1. The message appears in a dialog box and the program terminates. When the user has confirmed the message, control returns to the next-highest area. All the internal sessions are deleted from the stack.

  2. The message appears in the status line. Then Pai terminates and the system returns to the current screen. All the screen fields combined usingFieldOrChainAre now ready for input. The user must enter new values. The system triggers the pai event again, with the new values.
  3. The message appears in a dialog box. Once the user has confirmed the message, the program continues immediately afterMessageStatement.
  4. The message appears in the status line of the next screen. The program continues immediately after the message statement.
  5. The message appears in the status line. then the system continues as in 2, cannot that the user can quit the message using enter without having to enter new values. the system continues handling the pai event from immediately after the message statement.
  6. No message is displayed and a runtime error,Message_type_x, Is triggered. The short dump text contains the Message identification.
  7. The program terminates with a runtime errorDynpro_msg_in_help. While F1 and F4 are processed, the system cannot send error messages or warnings.
  8. The message appears in the status line. Then the system stops selection screen processing and returns to the selection screen itself. The screen fields specified in the additions toAt selection-ScreenStatement are now ready for input. The user must enter new values. The system then starts processing the selection screen again with the new values.
  9. The message appears in the status line. then the system continues as in 8, cannot the user can quit the message using enter, without having to enter new values. the system continues handling the pai event from immediately after the message statement.
  10. The message appears in the status line and the processing block terminates. The list level is displayed as before.
  11. The message appears in the status line and the processing block terminates. The system then returns to the program call.
  12. For a demonstration of messages in different contexts, see Example programs for messages.

Variant 1

Message xnnn.

Extras:

1.... With F1... F4

2.... Raising exception

3.... Into F

4.... Display like mtype

Effect

Outputs the messageNnnFrom the message classIWith the typeX. You must specify the message classIUsingMessage-IDAddition toReportStatement,Program, Or another introductory program statement.

Example

Message i001.

    • You can specify a different message class in parentheses after the error number, for exampleMessage i001 (SU).
    • When executing the Statement, the following system variables are set:

      *SY-MSGID(Message class)
      *SY-MSGTY(Message Type)
      *SY-MSGNO(Message number)

Addition 1

... With F1... F4

Effect

Inserts the contents of a fieldFiIn the message instead of in the placeholder& I. If unnumbered variables (&) are used in a message text, these are replaced consecutively by the fieldsF1ToF4.
To aid compilation, only numbered variables (& 1 to & 4) are to be used in future if several fields are involved.
If a "&" is supposed to appear in the message at runtime, you must enter&&.
In the long text of a message, the symbol & VI & is replaced by the field contentsFi.
AfterWith, You can specify 1 to 4 fields.

Note

You can output up to 50 characters per field. If the field contains more characters, these are ignored.

Example

Message e0004 with 'hugo '.

Note

When executing the Statement, the contents of the fieldsF1ToF4Are assigned to the system fieldsSY-MSGV1,SY-MSGV2,SY-MSGV3AndSY-MSGV4.

Addition 2

... Raising exception

Effect

Only possible within a function module or a method (seeFunction,Method):
Triggers the exceptionException.
If the Program Calling the function module or method handles the exception itself, control returns immediately to that program (seeCall FunctionAndCall Method). Only then are the current values passed from the procedure toExporting-,Changing-(UndReturning) Parameters of the function module or method, if they are specified as pass-by-reference. However, the calling program can refer to the system field values (see above ).

If the calling program does not handle the exception itself, the message is output (seeRaise).
You cannot use this addition in conjunction with... Into cfAddition.

Note

If, duringRemote function call, An error occurs in the target system, details of the error message are passed back to the calling system in the following system fields:SY-MSGNO, SY-MSGID, SY-MSGTY, SY-MSGV1, SY-MSGV2, SY-MSGV3, AndSY-MSGV4. These fields are initialized before every RFC. If a short dump or a Type X message occurs, the short text of the dump is transferred to the caller, and the contentsSY-MSGID, SY-MSGTY, SY-MSGNO, AndSY-MSGV1Assigned by the system.

In RFC-enabled function modules, no ABAP statements are allowed that wocould end the RFC connection (for example, eitherLeaveOrSubmitWithoutAnd returnAddition ).

Example
Message e001 raising not_found.

Addition 3

... Into F

Effect

Instead of displaying the message, the system places the message text in the fieldF. The message type is not evaluated.

You cannot use this addition in conjunction with... Raising exceptionOrDisplay Like mtypeAddition. The system sets the following system variables:SY-MSGID(Message class ),SY-MSGTY(Message Type ),SY-MSGNO(Message number) andSY-MSGV1,SY-MSGV2,SY-MSGV3,SY-MSGV4(Parameters ).

Example

Data msgtext (72 ).

...

Message e004 with 'hugo' into msgtext.

Addition 4

... Display like mtype

Effect

The message display uses the icon of the Message TypeMtypeBut the message is handled according to its actual type.

Note

This addition cannot be used in conjunction with the addition....

Example

Message i004 display like 'E '.

Variant 2

Message ID type mtype number n.

Extras:

1.... With F1... F4

2.... Raising exception

3.... Into F

4.... Display like mtype

Effect

The Message Components are set dynamically:

ID
Message class
Type
Message Type
Number
Message number

The additionMessage-IDOf the introductory program statement is not required or is overridden.

Addition 1

... With F1... F4

Addition 2

... Raising exception

Addition 3

... Into F

Addition 4

... Display like mtype

Effect

As in variant 1.

Example

Message ID 'su 'type'e' number '004 'with 'hugo '.

Outputs the message with the number 004 and message-IDSu(See above) as an E (error) message and replaces the first variable (&) with 'hugo '.

Example

Message ID SY-MSGID type SY-MSGTY number SY-MSGNO
With SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

Constructs the message dynamically from the contents of the system fieldsSY-MSGID,SY-MSGTY,SY-MSGNR,SY-MSGV1,SY-MSGV2,SY-MSGV3, AndSY-MSGV4. These may, for example, be set by an exception afterCall FunctionOrCall transaction... using.

Variant 3

Message xnnn (MID ).

Extras:

1.... With F1... F4

2.... Raising exception

3.... Into F

4.... Display like mtype

Effect

As in variant 1. The message class is determined by specifyingMid. The additionMessage-IDOf the introductory program statement is not required or is overridden.

Addition 1

... With F1... F4

Addition 2

... Raising exception

Addition 3

... Into F

Addition 4

... Display like mtype

Effect

As in variant 1.

Example

Message x004 (SU) with 'hugo '.

Variant 4

Message MSG type mtype.

Extras:

1.... Raising exception
2.... Display like mtype

Effect

With this variant, the message can be passed directly in the form of a character-like field. The message type is specified using the requiredTypeAddition.

Addition 1

... Raising exception

Addition 2

... Display like mtype

Effect

As in variant 1.

Example

Message 'file not found. 'Type 'E '.

The text 'file not found. 'Is output as the error message.

Exceptions

Non-catchable exceptions

    • Cause: Message type unknown
      Runtime error:Message_type_unknown
    • Cause: triggers termination with a short dump
      Runtime error:Message_type_x

Additional help

Messages

Usage tips:
There is a limit on the length of the string that the message is displayed to, and multiple parameters of the message are allocated to display long display information, if the first parameter is displayed after string connection, the displayed information may be lost.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.