2007 Oct 21 4:55 PM
Hi,
I have message number in internal table. I want to display message txt on report.
Can somebody tell me how I can move the message text to a variable, using message number stored in variable.
Variables details is as follows.
DATA: lv_msg_id type sy-msgno.
DATA: lv_msg_text(60) type c.
lv_msg_id = '010'.
I want to store msg text in lv_msg_text.
Thanks.
Hi,
I have message number in internal table. I want to display message txt on report.
Can somebody tell me how I can move the message text to a variable, using message number stored in variable.
Variables details is as follows.
DATA: lv_msg_id type sy-msgno.
DATA: lv_msg_text(60) type c.
lv_msg_id = '010'.
I want to store msg text in lv_msg_text.
Thanks.
2007 Oct 21 5:17 PM
The message statement has an INTO option allowing you to store the message in a field insteat of showing it on the screen directly.
MESSAGE E010(MESSAGE_CLASS) WITH VAR1 VAR2 VAR3 VAR4
INTO lv_msg_txt.
If you need to assign message class, number and type dynamically use the following version:
MESSAGE ID my_mid TYPE my_mtype NUMBER my_num WITH my_var1 my_var2 my_var3 my_var4 INTO lv_msg_txt.
Rgds.
Roman
2007 Oct 21 5:22 PM
Hi,
You can also use the Function Module BAPI_MESSAGE_GET_DETAIL to get the message passing the Message Id, No, variables etc.
Reward if useful
Regards,
Abhishek
2007 Oct 22 12:24 AM
Hi Roman,
Thanks for your reply.
I used your statment but I am getting this result.
Data: gc_msgid type sy-msgid value 'zmy_msg_class'.
data: lv_errid type sy-msgno.
lv_errid = '010'.
MESSAGE ID gc_msgid TYPE 'I' NUMBER gi_error_list-errid
INTO lv_err_txt.
Result: I:zmy_msg_class:010
Can you please see what is wrong in this.
2007 Oct 22 12:37 AM
Hi,
Can you try
MESSAGE gi_error_list-errid(gc_msgid) INTO lv_err_txt.
Regards,
Atish
2007 Oct 22 3:09 AM
Hi Atish,
I used your statement and it is giving me following error.
Three-digit error number XXX required in the "MESSAGE EXXX.. Statement.
2007 Oct 22 3:13 AM
Hi,
I think you can use your earlier statement only
MESSAGE ID gc_msgid TYPE 'I' NUMBER gi_error_list-errid
INTO lv_err_txt.
What is the error you getting in this.
Regards,
Atish
2007 Oct 22 5:55 AM
> I:zmy_msg_class:010
This ist the standard message which is shown if the specified message is not existing or does not have a translation to your logon language.
check if the name of the message class and the number are really correct. Perhaps writing the message class in capital letters might help.
2021 Jul 23 8:45 AM
You can use function module: FORMAT_MESSAGE
But remmeber about language translation. If it doesn't exist you don't get value in variable.
Here it's example code:
DATA: text TYPE string.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
id = 'AUTH_WIZ' " Application Area
lang = sy-langu
no = '003'
v1 = 'TEST VALUE' " 1st parameter
v2 = sy-msgv2 " 2nd parameter
v3 = sy-msgv3 " 3rd parameter
v4 = sy-msgv4 " 4th Parameter
IMPORTING
msg = text
EXCEPTIONS
not_found = 1.
IF sy-subrc <> 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ELSE.
WRITE:/ text.
ENDIF.
This simple FM check only table T100 as select single, so sometimes better is use select on T100 and get all message to global table/class attribute and after use read table on it. It's much better when u have many messages to handle in your class/ program.
DATA: messages TYPE HASHED TABLE OF t100 WITH UNIQUE KEY msgnr.
SELECT *
FROM t100
INTO TABLE @messages[]
WHERE sprsl = @sy-langu
AND arbgb = 'AUTH_WIZ'.
IF sy-subrc EQ 0.
READ TABLE messages INTO DATA(message) WITH KEY msgnr = '003'.
IF sy-subrc EQ 0.
REPLACE '&' IN message-text WITH 'TEST VALUE'.
WRITE:/ message-text.
ENDIF.
ENDIF.
2021 Jul 25 5:01 AM
Hi Dear, you can code in different ways. see one sample on below ABAP Code, please!
Best Regards!
data: lv_text type string.
"BAPI Message text
message id lw_bapiret2-id
type lw_bapiret2-type
number lw_bapiret2-number
with lw_bapiret2-message_v1
lw_bapiret2-message_v2
lw_bapiret2-message_v3
lw_bapiret2-message_v4
into lv_text.
message s223(z1) with (lv_text) display like 'I'.
| User | Count |
|---|---|
| 6 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |