‎2014 Mar 25 11:47 AM
Dear friends
when i execute standard function module in finance , i am getting error message , pls check the below screen shot,
how to capture the below error message so that i have display in my webdynpro component
Thanks
Vijaya
‎2014 Mar 25 11:55 AM
hi ,
Sap has provided option to capture exceptions while error occures in a FM .
Use this
DATA mtext TYPE string.
CALL FUNCTION ... EXCEPTIONS error_message = 4.
IF sy-subrc = 4.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
INTO mtext
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
Regards,
Sivaganesh
‎2014 Mar 25 12:19 PM
Hi Vijaya.
The solution given by Sivaganesh is perfect for all MESSAGEs without RAISING option.
If the MESSAGE has a RAISING option, you have to catch this EXCEPTION explicitely in your fm call
Regards,
Klaus
‎2014 Mar 25 11:57 AM
Please explain in detail how you are trigerring the FM.
By double clicking on the message you can get the message no. and ID.
‎2014 Mar 25 12:04 PM
lx_return TYPE BAPIRET2.
call FM.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid
TYPE sy-msgty
NUMBER sy-msgno
WITH sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4
INTO lx_return-message.
lx_return-type = sy-msgty.
ENDIF.
‎2014 Mar 25 12:11 PM
Hi Vijaya
Can you please provide the details of the FM which you are using along message id and message class detail
Nabheet
‎2014 Mar 25 2:14 PM
Hi Nabheet,
You can use the below FM for capturing the error message.
data: ls_msg TYPE bapiret2,
CALL FUNCTION '/SNP/DW01_UTILS_FORMAT_MESSAGE'
EXPORTING
iv_id = sy-msgid
iv_number = sy-msgno
iv_type = sy-msgty
iv_p1 = sy-msgv1
iv_p2 = sy-msgv2
iv_p3 = sy-msgv3
iv_p4 = sy-msgv4
IMPORTING
ew_result = ls_msg.
Regards,
Mohammed
‎2014 Mar 25 2:11 PM
Hi Vijaya,
in most cases there is a table T_RETURN as an output parameter in the function module which is BAPIRET2 struture where you can retrieve the error message
regards
‎2014 Mar 25 2:15 PM
Hi Vijaya,
You can use the below FM for capturing the error message.
data: ls_msg TYPE bapiret2,
CALL FUNCTION '/SNP/DW01_UTILS_FORMAT_MESSAGE'
EXPORTING
iv_id = sy-msgid
iv_number = sy-msgno
iv_type = sy-msgty
iv_p1 = sy-msgv1
iv_p2 = sy-msgv2
iv_p3 = sy-msgv3
iv_p4 = sy-msgv4
IMPORTING
ew_result = ls_msg.
Regards,
Mohammed
‎2014 Mar 25 2:22 PM
Hello,
User error_message after FM. this is capture all messagae (RAISING or without)
CALL FUNCTION 'ZTEST'
IMPORT
..........
EXCEPTIONS
error_message = 01
IF SY-SUBRC <>0.
" carry out exception handling
ENDIF.
Details fo error_message are explained in below doc
http://help.sap.com/abapdocu_70/en/ABAPCALL_FUNCTION_PARAMETER.htm
There are few threads also in SCN for the same. you can check it incase of doubt
Cheers,
Nag
‎2014 Mar 25 3:38 PM
Hello Vijaya,
Incase of BAPI's they have a return table parameter T_RETURN. Just read that return table to get the error message.
Incase of normal function modules, there will be exceptions raised for the message used inside the function module. Just read the sy-subrc after the FM and based on the sy-subrc value find the respective exception raised.
May be you can try like this, whenever the message is raised it will be stored in the system variable.
CALL FM.
check for the system variables.
sy-msgid = Message ID of the latest message raised.
sy-msgno = message number of the latest message raised.
sy-msgty = message type of the latest message raised.
sy-msgv1 = variable1 of the latest message raised.
sy-msgv2 = variable2 of the latest message raised.
sy-msgv3 = variable3 of the latest message raised.
sy-msgv4 = variable4 of the latest message raised.
Regards,
TP