0
votes

When working with RFC-enabled Function Modules I often add custom return messages. These are defined as message classes with IDs and parameters. Now I receive those messages perfectly in my calling program, but since the caller can be on a different system the message classes I defined on the source system are unknown. Standard output of these messages to a message manager or application log fails as the text can't be generated.

What is the best practice for making these types of messages meaningful in the calling environment?

Is there an alternative to filling the text field in the source program, for instance by using MESSAGE_TEXT_BUILD? If I fill that text will standard SAP code not try to overwrite it from a non-existent message class?

2
Changed and added as answer.icbytes
Do you get the return in BAPIRET2 structure? Is the message field in the structure filled with the correct text? In a different system, this field will be more useful.jhamu
@jhamu This is in fact the approach I decided to use in the end. As mentioned in the question, by using MESSAGE_TEXT_BUILD to fill the MESSAGE field of the BAPIRET2 structure. This works as long as the calling system doesn't regenerate the text from the message parameters.Lilienthal

2 Answers

1
votes

Best option I can think of is to make your own RFC function module that takes in a message id, number, etc and returns a message string. You will have to distribute this to all the systems. You code it as:

FUNCTION zget_message.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     REFERENCE(i_msgid) TYPE msgid
*"     REFERENCE(i_msgno) TYPE msgno
*"     REFERENCE(i_msgv1) TYPE msgv1
*"     REFERENCE(i_msgv2) TYPE msgv1
*"     REFERENCE(i_msgv3) TYPE msgv1
*"     REFERENCE(i_msgv4) TYPE msgv1
*"  EXPORTING
*"     VALUE(e_message) TYPE  string
*"----------------------------------------------------------------------

  MESSAGE ID i_msgid TYPE 'I' NUMBER i_msgno 
          WITH i_msgv1 i_msgv2 i_msgv3 i_msgv4 
          INTO e_message.

ENDFUNCTION.

There is probably a SAP standard RFC that does this somewhere but I don't know what it is.

0
votes

As far as i know, You should be informed,or it should be defined and documented, which messages a remote caller can use inside the remote system, so that the calling app just gets them back to show them. In terms of classes, which interfer on both systems, I do not know anything, that would prevent collisions/missing id's/classes. So You for Yourself will have to deal with that. No, I researched, there is definetely no way to deal with that, You as developer should be aware, that any remote assigned messages are NOT used locally.