2022 Dec 13 10:21 AM
Hi everyone,
I am having an issue where I need to read the message after saving. So, the requirement is that via our custom program, it should use the call transaction to open a business transaction, and after the user saves the data in the transaction, it will return back in our custom program. In the custom program, I have the below successful message 'Equipment plan * is saved':
How can I read this message that comes in my custom program, as I need to use the value of the equipment plan in a latter point?
Also, I cannot use BDC as the user needs to input the values by himself.
Thank you all in advance!
R
2022 Dec 13 2:24 PM
To read the message from a business transaction in a custom program in ABAP, you can use the MESSAGE statement along with the GET addition to retrieve the message from the message buffer.
MESSAGE <id> TYPE <type> NUMBER <number> WITH <data> [RAISING <exception>]
[DISPLAY LIKE <display>] [PLACEMENT <position>] [GET].
The GET addition is used to retrieve the message from the message buffer and store it in the specified variables. The <id>, <type>, and <number> parameters are used to identify the message you want to retrieve. The <data> parameter specifies the variables where the message text and other information will be stored.
For example, if you want to retrieve the message with ID SY, type E, and number 123, and store the message text in a variable called MESSAGE_TEXT, you could use the following code
DATA: MESSAGE_TEXT(200) TYPE C.
MESSAGE SY TYPE E NUMBER 123 WITH MESSAGE_TEXT GET.
This will retrieve the message from the message buffer and store it in the MESSAGE_TEXT variable. You can then use this variable to display the message or process it further in your custom program.
Note that the MESSAGE statement only retrieves messages from the message buffer, so it will only work for messages that have been generated and sent to the buffer by the system.
2022 Dec 13 10:25 AM
Hello,
CALL TRANSACTION offers a MESSAGES INTO itab option. From a first sight, I would expect that catching the message should work...
Kind regards
Jan
2022 Dec 13 10:42 AM
Hi @jmodaal,
Thank you for your reply.
If I use, e.g., Call Transaction 'ME21N', it would offer Using after that, not Messages INTO. If I had use Call Transaction 'ME21N' USING itab Messages INTO itabmess it would be fine, but I do not want to use the bdcdata, as the user has to input the values by himself. Do you maybe have another idea?
Kind regards,
R
2022 Dec 13 11:16 AM
Hello tk_gerald,
did you try leaving the bdcdata empty?
data: bdcData type standard table of bdcdata with empty key,
me21nMessages type standard table of bdcmsgcoll with empty key.
call transaction 'ME21N' using bdcdata messages into me21nMessages.
Kind regards
Jan
2022 Dec 13 12:18 PM
Hi @jmodaal,
Yes, I did not try prior with the bdcdata empty. Now it is working.
Many thanks,
R
2022 Dec 13 2:24 PM
To read the message from a business transaction in a custom program in ABAP, you can use the MESSAGE statement along with the GET addition to retrieve the message from the message buffer.
MESSAGE <id> TYPE <type> NUMBER <number> WITH <data> [RAISING <exception>]
[DISPLAY LIKE <display>] [PLACEMENT <position>] [GET].
The GET addition is used to retrieve the message from the message buffer and store it in the specified variables. The <id>, <type>, and <number> parameters are used to identify the message you want to retrieve. The <data> parameter specifies the variables where the message text and other information will be stored.
For example, if you want to retrieve the message with ID SY, type E, and number 123, and store the message text in a variable called MESSAGE_TEXT, you could use the following code
DATA: MESSAGE_TEXT(200) TYPE C.
MESSAGE SY TYPE E NUMBER 123 WITH MESSAGE_TEXT GET.
This will retrieve the message from the message buffer and store it in the MESSAGE_TEXT variable. You can then use this variable to display the message or process it further in your custom program.
Note that the MESSAGE statement only retrieves messages from the message buffer, so it will only work for messages that have been generated and sent to the buffer by the system.
2022 Dec 15 6:40 PM
Hi,
you can try to read the sy-message parameters:
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4
INTO lv_message.