Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Reading the message from business transaction to custom program

Raxph
Participant
0 Kudos
508

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

1 ACCEPTED SOLUTION

harishankar714
Participant
434

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.

6 REPLIES 6

jmodaal
Active Contributor
0 Kudos
434

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

Raxph
Participant
0 Kudos
434

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

jmodaal
Active Contributor
434

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

Raxph
Participant
0 Kudos
434

Hi @jmodaal,

Yes, I did not try prior with the bdcdata empty. Now it is working.

Many thanks,

R

harishankar714
Participant
435

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.

ThorstenHoefer
Active Contributor
0 Kudos
434

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.