2023 Dec 14 1:51 PM
Let's say, I have an exception object with a non-dynamic T100 interface (message id and type is assigned in the coding). Now, I need to get the whole message in order to pass it to a BAPIRET2 structure. In the T100 interface, I have only the names of the attributes that populate MSGV1, MSGV2 ... in components called ATTR1, ATTR2....
To get the values for MSGV.. I have to do a series of dynamical assigns.
I am wondering if there is any standard tool for this? It seems to be a common task, but I did not find anything.
2023 Dec 14 2:43 PM
Are not variables in sy-msg* variables?
If not then you can get them there by triggering MESSAGE from exception object.
It is nice to prepare some utility method for that. Here is example without method:
TRY.
"...
CATCH zcx_exception INTO DATA(lo_exception).
MESSAGE lo_exception INTO ls_bapiret2-message.
ls_bapiret2-message_v1 = sy-msgv1.
"...
ENDTRY.
EDIT: ah sorry, it seems that MESSAGE oref INTO is not allowed 😞
EDIT2: You can try CL_MESSAGE_HELPER method SET_MSG_VARS_FOR_IF_T100_MSG that fills sy-msgv* and other fields 🙂
2023 Dec 14 2:43 PM
Are not variables in sy-msg* variables?
If not then you can get them there by triggering MESSAGE from exception object.
It is nice to prepare some utility method for that. Here is example without method:
TRY.
"...
CATCH zcx_exception INTO DATA(lo_exception).
MESSAGE lo_exception INTO ls_bapiret2-message.
ls_bapiret2-message_v1 = sy-msgv1.
"...
ENDTRY.
EDIT: ah sorry, it seems that MESSAGE oref INTO is not allowed 😞
EDIT2: You can try CL_MESSAGE_HELPER method SET_MSG_VARS_FOR_IF_T100_MSG that fills sy-msgv* and other fields 🙂
2023 Dec 14 4:02 PM
CL_MESSAGE_HELPER was exactly what I looked for. Thank you so much.