Using Message Class in SAP ABAP

Author | Last Updated| | 245 Comments Facebook Share Twitter Share Google Plus Share A+ A-


Learn how to use message class in SAP ABAP programs, Function Modules and other ABAP programing areas.

Step1:What is message class in SAP ABAP ? medium Top^

Message Class is nothing but a container of messages, the main purpose of this message class is re-usability and readability. A message class can be reused in multiple programs and Function modules.The Message Class can be created in two ways.

  1. Direct way using T-code SE91.
  2. Through Program.

You know all the message texts under message classes are stored in T100 table, each message in message class has a number and value.

We can able to pass parameters to message class to raise parameters along with messages.

Syntax1 : Syntax1: MESSAGE <MESSAGE TYPE><MESSAGE NUMBER> (<MESSAGE CLASS NAME>). 
Syntax2 : Step1 : REPORT <REPORT NAME> MESSAGE-ID <MESSAGE CLASS NAME> ."add message is at the report header (1st line)
          Step2 : MESSAGE <MESSAGE TYPE><MESSAGE NUMBER> . "directly specify messages

The below is the syntax for raising messages with parameters.

MESSAGE <MESSAGE TYPE><MESSAGE NUMBER> WITH <PARAMETER> "Parameter must be defined in message class

By using message class we can raise following messages.

Message Type Effect Description
A

Termination Message

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 menu.

E

Error Message

Depending on the program context, an error dialog appears or the program terminates.

I

Information

The message appears in a dialog box. Once the user has confirmed the message, the program continues immediately after the MESSAGE statement.

S

Status Message

The program continues normally after the MESSAGE statement, and the message is displayed in the status bar of the next screen.

W

Warning

Depending on the program context, an error dialog appears or the program terminates.

X

Exit

No message is displayed, and the program terminates with a short dump. Program terminations with a short dump normally only occur when a runtime error occurs. Message type X allows you to force a program termination. The short dump contains the message ID.

Step2:Creating message class in SAP Medium Top^

The message class can be created in two ways,

  1. Using SE91 (message maintenance ) t-code.
  2. Using SE38 program.

Creating message class using SE38 program.

REPORT <REPORT NAME> message-id <MESSAGE CLASS> . "Double click on message class click create
REPORT  ZSAPN_MESSAGE_CLASS message-id ZSAPN_MESSAGE . "double click on ZSAPN_MESSAGE and click create

Creating message class using SE91.

Go to SE91 and give message class as ZSAPN_MESSAGE and click create.

Creating message class in SAP

Select messages tab, save it in a package (local object for test) and start adding messages.

Message class in SAP ABAP

 

Step3:Using message class in ABAP programs Medium Top^

There are two ways of using message classes in ABAP programs.

  • Defining message class for a report.
  • Using messages of a message class directly from message class.

For using message class by defining at report level, we have to define a message class by using below code (example).

REPORT ZSAPN_MESSAGE_CLASS message-id ZSAPN_MESSAGE . "report message-id message class 
       MESSAGE S001. "Raise message here S = Success message type and 001 = message no in ZSAPN_MESSAGE message class

The below is the code for using message class directly by using message number and message class name at message level.

MESSAGE s000(ZSAPN_MESSAGE). " here ZSAPN_MESSAGE is the message class name

Example(SE38 program)

REPORT  ZSAPN_MESSAGE_CLASS .

MESSAGE s000(ZSAPN_MESSAGE).
        OR
REPORT  ZSAPN_MESSAGE_CLASS MESSAGE-ID ZSAPN_MESSAGE.

MESSAGE S000.

By using the above code we can raise success message like below.

message classes in SAP ABAP

Example with parameters

we use &to specify parameters in message of a message class.

Message class using parame in SAP ABAPters

REPORT  ZSAPN_MESSAGE_CLASS.

MESSAGE S001(ZSAPN_MESSAGE) WITH '002' '003' .
        OR
REPORT  ZSAPN_MESSAGE_CLASS MESSAGE-ID ZSAPN_MESSAGE.

MESSAGE S001 with '002' '003'.

By using the above code we can raise success message with parameters like below.

Message class with parameters in SAP

Tutorial Comments

Total Comments: Add your Comment
29 Mar 2018

good explanation..keep on provide the other topics...change the tcode se93...using se91 we can create the message class.

29 Mar 2018

nice explanation..It will really helpful for beginners in sap

29 Mar 2018

there is no message type called STATUS message it should be SUCCESS Message. Otherwise the document looks good.

29 Mar 2018

Very good explanation. it is help full to abap beginners

29 Mar 2018

thanx sir ....its very useful.....

29 Mar 2018

much clear and it is self explanatory to understand for a fresher to understand

29 Mar 2018

much clear and it is self explanatory to understand for a fresher to understand

29 Mar 2018

no doubt sir..this is the best side i have ever seen on sap........but sir if we wants to do some project work on sap project in that case can u suggest us any site or something so that we can make ourself prepare for future knowledge.............. sincerely varun

29 Mar 2018

TCode to create message class is SE91 not SE93 (SE93 is used to create Transaction Code).

29 Mar 2018

excellent this post is very help full to beginners

29 Mar 2018

excellent this post is very help full to beginners

29 Mar 2018

Thank you for sharing the knowledge, I've observed SE93 TCode for message class maintenance SE91 - Message Maintenance: Initial Screen. SE93 - Maintain Transaction.

29 Mar 2018

Thank you for sharing the knowledge, I've observed SE93 TCode for message class maintenance SE91 - Message Maintenance: Initial Screen. SE93 - Maintain Transaction.

29 Mar 2018

great example in this case. But I think should add another example or more example

29 Mar 2018

Thank you . Very clear explanation and helpful.

29 Mar 2018

Thank you . Very clear explanation and helpful.

29 Mar 2018

yeah this site is so useful for the SAP consultant. Great job !

29 Mar 2018

i like it this topic its very helpful . thank you for share:)

29 Mar 2018

Nice Concepts ..................................................................................... gooooooooooooooooooooooooooood

29 Mar 2018

by giving a small comments i cant judge it . this is a best site which i never seen ever before... very useful. And if u add a real time scenarios its will be helpfull.

29 Mar 2018

Tutorials in SAPNUTS are really helpful. For live examples if possible would be more better.

29 Mar 2018

Really Good Stuff to learn in SAPNUTS

29 Mar 2018

Good, very nice. please continue your job.

29 Mar 2018

Excellent!!!!!Well demonstrated. Very helpful !!!!!

29 Mar 2018

very nice topic it was grooming towards sap abap beginners.

29 Mar 2018

Nice Article for beginners and good screens

29 Mar 2018

How can we handle this with message handler?

29 Mar 2018

Nice document.easy to understand

09 May 2018

online name brand viagra viagra shipped overnight viagra wikipedia [url=http://canadiannowv.com/#]viagra cheapest price[/url]

09 May 2018

Последние новости здесь [url=http://mybiysk.ru/]mybiysk.ru[/url]

09 May 2018

best car insurance rates best insurance best car insurance rates [url=https://bestinsurance.us.org]best auto insurance companies[/url]

09 May 2018

online casino online casino online casino [url=https://onlinecasinoiplay.com/#]online casino[/url]

10 May 2018

fantasy springs resort casino san manuel online casino hollywood casino online | [url=https://onlinecasinocss.com/#]free casino slots online[/url]

10 May 2018

[url=https://onlinecasinoinus.com/#]online casino[/url] [url=https://onlinecasinoinus.com/#]online casino[/url] [url=https://onlinecasinoinus.com/#]online casino[/url] online casino online casino online casino online casino

16 Mar 2020

priceofisatwalmart 2cdd miglior prezzo is

18 Mar 2020

[url=https://amoxiltab.com/]where can i buy amoxil[/url]

20 Mar 2020

[url=https://nolvadex365.com/]nolvadex 10mg india[/url] [url=https://acyclovir3.com/]acyclovir online purchase[/url] [url=https://lipitor2020.com/]generic lipitor canada pharmacy[/url] [url=https://valtrexc.com/]how much is a valtrex prescription[/url] [url=https://allopurinolsale.com/]allopurinol 100mg[/url] [url=https://chloroquineotc.com/]chloroquine[/url] [url=https://wellbutrin3.com/]wellbutrin 150[/url] [url=https://doxycyclinenorx.com/]doxycycline monohydrate[/url] [url=https://neurontin365.com/]neurontin 2400 mg[/url] [url=https://ciproflx.com/]cipro 500mg[/url]

22 Mar 2020

Find out [url=https://nudestripper.net/category/teens/]free teens porn[/url] for free :)

23 Mar 2020

Cool + per post _________________ [URL=https://en.bestsmartbets.site/casino-ferber-horaires/]Casino ferber horaires[/URL]

26 Mar 2020

[url=https://bolnichniy.website/bolnichniy-list-na-5-dney/][img]https://i.ibb.co/D5FP42c/il-570x-N-1986543144-8hc2.jpg[/img][/url] I'm constipated

28 Mar 2020

Hello folks, just came across your articles, really like your works! Would like to share some useful links, hope you like it. [url=https://flvto.ch/de]Youtube Converter[/url] [url=https://2conv.ch/]Youtube to mp3[/url] [url=https://keepvid.best/]Keepvid[/url] [url=https://ytmp3.ch/]Youtube to mp3 converter[/url]

29 Mar 2020

[url=http://azithromycin360.com/]azithromycin 500mg without prescription[/url] [url=http://sildalistab.com/]sildalis 100mg 20mg[/url] [url=http://ventolininhaler.top/]buy ventolin[/url] [url=http://chloroquineotc.com/]chloroquine price in india[/url] [url=http://hydroxychloroquine365.com/]hydroxychloroquine for sale[/url] [url=http://toradoliv.com/]toradol otc[/url]

Leave a Comment

Enter Comment Text