03-13-2007 4:44 PM
Hi all,
I want to know the various methods of writing messages. I used ...
**1**
IF SY-SUBRC <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
**2**
MESSAGE E000(ZCA) WITH LV_MESSAGE.
**3**
data msgtxt(255).
open dataset imp_dat for input in text
mode encoding default message msgtxt.
**4**
data msgtxt(255).
if sy-subrc ne 0.
write: / 'File Open Error'(004),imp_dat, msgtxt.
Are there more? Could you please explain these and others which might exist.
Thanks,
Charles.
03-13-2007 4:47 PM
03-13-2007 4:47 PM
03-13-2007 4:49 PM
in 3 ways u can write it.
Variant 1
<b>MESSAGE xnnn.</b>
Additions:
1. ... WITH f1 ... f4
2. ... RAISING exception
3. ... INTO f
Effect
Sends the message nnn from message class i with type x. You can specify the message class i in the MESSAGE-ID addition to the REPORT, PROGRAM or other introductory statement.
Example
MESSAGE I001.
If you want to use a different message class, you can specify one in parentheses after the message number: MESSAGE I001(SU).
When the statement is executed, the following system variables are set:
SY-MSGID (Message class)
SY-MSGTY (Message type)
SY-MSGNO (Message number)
Addition 1
... WITH f1 ... f4
Effect
The contents of the fields fi are inserted into the message text to replace the placeholders &i. If you used unnumbered placeholders in your message text (&), they are replaced successively with the contents of the fields f1 to f4.
To make messages easier to translate, ensure that you use numbered placeholders ( &1 to &4) if you need to insert more than one variable in a message text.
If you want to use the ampersand character itself in a message text, enter &&.
In the long text of a message, the symbol &Vi& is replaced with the field contents of fi at runtime.
You can specify between one and four fields after WITH.
Note
Only the first 50 characters of any field will be displayed.
Example
MESSAGE E004 WITH 'Hugo'.
Note
When the statement is executed, the system fields SY-MSGV1, SY-MSGV2, SY-MSGV3, and SY-MSGV4 are filled with the contents of f1 to f4.
Addition 2
... RAISING exception
Effect
Only within a function module or method ( FUNCTION, METHOD):
Triggers the exception exception.
If the caller of the function module or method handles the exception itself, control returns directly to the caller (see CALL FUNCTION and CALL METHOD). The EXPORTING, CHANGING, (and RETURNING) parameters of the function module or method only contain the current value from the procedure if they are defined to be passed by reference. They are not filled if they are passed by value.
The caller can, however, use the values from the system fields that are filled when the message is sent (see above).
If the caller does not handle the exception itself, the message is displayed (see RAISE).
You cannot use this addition in conjunction with the ... INTO cf addition.
Note
If, during a Remote Function Call, an error occurs in the target system, details of the error message are passed bac to the calling system in the following system fields: SY-MSGNO, SY-MSGID, SY-MSGTY, SY-MSGV1, SY-MSGV2, SY-MSGV3, and SY-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 contents of SY-MSGID, SY-MSGTY, SY-MSGNO, and SY-MSGV1 assigned by the system.
In RFC-enabled function modules, no ABAP statements are allowed that would end the RFC connection (for example, LEAVE, SUBMIT or the AND RETURN addition).
Example
MESSAGE E001 RAISING NOT_FOUND.
Addition 3
... INTO f
Effect
The message is not displayed, but the formatted message text is placed in the field f. The message type is irrelvant.
Note
You cannot use this addition in conjunction with the ...RAISING exception addition. The addition sets the following system variables: SY-MSGID (message class), SY-MSGTY (message type), SY-MSGNO (message number), and SY-MSGV1, SY-MSGV2, SY-MSGV3, SY-MSGV4 (parameters).
Example
DATA msgtext(72).
...
MESSAGE E004 WITH 'Hugo' INTO msgtext.
Variant 2
<b>MESSAGE ID id TYPE mtype NUMBER n.</b>
Effect
As in variant 1, but you can set the
ID
message class
TYPE
message type
NUMBER
message number
dynamically. You can use any other additions that are valid for the basic form of the statement.
Example
MESSAGE ID 'SU' TYPE 'E' NUMBER '004' WITH 'Hugo'.
The example displays message 004 from message class SU (see above) as an error message, and its first placeholder is replaced with 'Hugo'.
Example
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
The message is constructed dynamically from the system fields SY-MSGID, SY-MSGTY, SY-MSGNR, SY-MSGV1, SY-MSGV2, SY-MSGV3, and SY-MSGV4. This applies to situations where the system fields have been set by an exception following CALL FUNCTION or CALL TRANSACTION ... USING
Variant 3
<b>MESSAGE xnnn(mid).</b>
Effect
Like variant 2
Example
MESSAGE X004(SU) WITH 'Hugo'.
Note
Runtime errors:
MESSAGE_TYPE_UNKNOWN: Message type unknown
MESSAGE_TYPE_X: Deliberate program termination with short dump
03-13-2007 4:51 PM
hi,
You can use MessageManager to display the messages.
Ex:
IWDMessageManager man=wdThis.wdGet<<Controller>>().wdGetAPI().getMessageManager();
man.reportSucess("<<Message>>");
man.reportWarning("<<Message>>");
03-13-2007 4:55 PM
Hi charles,
1) This is triggered by a function module and the system variables are filled by output of the function module. In case where there is an error these fields get populated and displayed.
2) Message E(Message type)000(Message Number)ZCA(Message class - you can create a class of your own in Tcode SE91) WITH LV_MESSAGE(parameter to be passed to message).
3) Explicitly insert messaged into a file.
4) Display Message on Screen using write format. Here you cannot derive the functionality of a message, you just tend to display the output.
5) Message 'test Message' type 'I'.
This is similar to 2 but doesnt have a message class so simply give message text and specify type.
There could be many more.. Depending on the situation you may even have error tables for the transactions..
Hope this helps..
Let me know if you have further questions..
BR
Rakesh
03-13-2007 5:18 PM
One more
message id 'V1' type 'E' number '008' display like 'I'
with '1' '2'.
Here message will display like info instead of Error.
This can be used in PBO messaging
aRs