on 02-05-2008 6:25 AM
Hi Experts,
I am using BAPI to post MIGO in one of my application. If the MIGO is successfully gets posted then BAPI returns no message, but if there is some error in posting then it returns an error message. Now I want to print that error message in catch block by calling method RAISE_ERROR_MESSAGE. How to use try catch block in ABAP. Please suggest with example.
Thanks and Regards.
Vaibhav Tiwari.
Hi Vaibhav
You may not catch exceptions returned by function module using try endtry block.
It works well with the exception returned by methods.
In case of function modules or BAPI what u can do is to check sy-subrc returned and give message accordingly. If it returns a structure like bapireturn then display message returned.
in case of exception returned by a method, do it like this...
data: excep type cx_root.
data: v_str type string.
try.
*any method call or division by zero (for ex)
catch cx_root into excep.
endtry.
if excep is not initial.
CALL METHOD excep->if_message~get_text
receiving
RESULT = v_str.
.
endif.
*display the value returned in v_str on screen
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi vaibhav.....
check this link:
[link|help.sap.com/saphelp_nw70/helpdata/en/a9/b8eef8fe9411d4b2ee0050dadfb92b/content.htm -]
in order to raise a message fo a bapi return you can go for if condition...
like
if i_return is not initial.
message.
endif.
---regards,
alex b justin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.