2012 Jun 28 12:38 PM
Hi,
I have created a custom RFC which calls a standard transaction internally using SUBMIT statement.
The problem I face is that I am not able to capture the message when the standard transaction ends in error, as the control does not come back to the RFC.
Please let me know how can I capture error messages in such case. The RFC is called from another system and I need to pass the error message to the calling system.
Regards,
Dawood
Hi,
I have created a custom RFC which calls a standard transaction internally using SUBMIT statement.
The problem I face is that I am not able to capture the message when the standard transaction ends in error, as the control does not come back to the RFC.
Please let me know how can I capture error messages in such case. The RFC is called from another system and I need to pass the error message to the calling system.
Regards,
Dawood
2012 Jun 28 12:48 PM
Hi Dawood,
After executing, CALL TRANSACTION stmt, depending upon the SY-SUBRC value dispaly the Error Message .
2012 Jun 28 1:23 PM
I need to use SUBMIT pgm as I am also passing the selection criteria.
2012 Jun 28 2:41 PM
Are you getting correct data in SYST structure?
I think you should generally get the error message in sy-msgid and sy-msgno etc.
Populate those messages in structure BAPIRET2 and send it back to the system.
2012 Jun 28 6:25 PM
Hi Dawood,
Please try using the FM FORMAT_MESSAGE to get all the messages generated at Run-time.
Below is the Demo code:
CALL TRANSACTION 'MM01' USING BDCDATA MODE 'A' UPDATE 'S'.
If sy-subrc ne 0.
CALL FUNCTION 'FORMAT_MESSAGE'
EXPORTING
* ID = SY-MSGID
LANG = 'EN'
* NO = SY-MSGNO
* V1 = SY-MSGV1
* V2 = SY-MSGV2
* V3 = SY-MSGV3
* V4 = SY-MSGV4
IMPORTING
MSG = TEXT
* EXCEPTIONS
* NOT_FOUND = 1
* OTHERS = 2
.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
CONCATENATE INDEX TEXT INTO TEXT SEPARATED BY ' . ' .
Thus you can capture Message No and corresponding Text and use it as Exceptions as per requirement.
Best Regards,
Sachin
2012 Jun 29 12:06 AM
This cannot be done using the SUBMIT statement, because the moment SUBMIT is called the control is transferred to the called program. If an error is raised in this program, the processing stops and the control does not return back to the main program (your RFC) for processing.
In case of RFC it is always advised not to raise any error messages, instead pass the errors back as parameters to the RFCs (like most BAPI calls have the BAPIRETURN table to capture errors).
The only option that I see is to encapsulate the logic of the program that you are calling in your RFC and instead of issuing error messages, capture them in a parameter table returned by the RFC.
-Puneet
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |