2008 Dec 05 11:59 PM
HI Folks,
I got a problem where my callee FM has a SAP message (ie. Message e(XXXX) xxxx).
How can I suprress it, and then later on fetch the message from memory?
Thanks,
Charlie
2008 Dec 08 5:44 PM
It doesn't matter...The other exception should have caught everything already. However I did try your suggestion and it does not work.
Furthermore, I cannot change FM anyway. So it won't make a difference because I have no authority to make any modification to the FM.
I appreciate your suggestions but I think this is a dead end.
However, I remember there is a function module in SAP that initialize text, then any message text message executed afterwards would go into a buffer. Another FM can retrieve it.
I don't remember those FM, and thats why I am posting here to see if anyone else have used it or know those fm.
2008 Dec 06 2:20 AM
By passing correct data to FM you can avoid the message.Check where-used-list for function module for sample coding.
2008 Dec 06 3:00 AM
normally you can code exception condition others = <some number> to supress the error message from the Function module call, then later you can check sy-subrc and give the message as you wish
so
call function xxxxx
exporting
importing
exceptions
e1 = 1
e2 = 2
others = 9.
2008 Dec 08 4:39 PM
That won't work because too many program is using the function module, and I cannot change the calling fm. So I have to find a way to suppress that message. So no can do on your suggestion, though its a good one.
2008 Dec 08 4:45 PM
Hi Charlie
If you are allowed to copy that FM and then handle the message part inside that new copied one.
I had a similer problem with one of the standard FM and as per the requirement user was asking for customize message so I copied that FM and pass all the message to log table and then in code i read that log table to customize the message for my code.
Neha
2008 Dec 08 4:46 PM
can you explain again. i assume you are using a function module ( SAP or custom ), and there you are getting an SAP message back from the call.
What I asked you to change you call statment to code for exceptions Others = ....
I did nto ask you to change the calling FM, vbut rather the code in which you are calling the FM.
2008 Dec 08 5:03 PM
I would never get an exception from the fm, because the message statement insdie the fm would have already stopped the program.
2008 Dec 08 5:06 PM
Here is my scenario:
FM:
FUNCTION xxx
MESSAGE e002(xxx).
ENDFUNCTION.
Calling program:
CALL FUNCTION xxx
...
EXCEPTIONS
other = 1.
The message e002 statement will stop the program. I would like to suppress it, and fetch from memory later. I don't have to option of changing the FM and perfer not to make another copy.
2008 Dec 08 4:43 PM
Hi,
You can catch the error message when calling the function module..
CALL FUNCTION 'xxxxx'
......
EXCEPTIONS
error_message = 1. " This will catch the error message.
Thanks
naren
2008 Dec 08 5:02 PM
That actually won't work because in the calling FM. It has a message statement with typ 'E'. like:
MESSAGE e002(xxx).
Even if I call it with following
CALL FUNCTION 'xxx'
EXCEPTIONS
other = 1.
It will never come out of the FM because it already errored out to screen at the message statement. I did try that but didn't work.
2008 Dec 08 5:08 PM
Hi,
Please see my reply..
also from help..
If the error_message addition is specified after EXCEPTIONS, all MESSAGE statements that are executed during the processing of the function module and do not have the RAISING addition are affected as follows:
Messages of the type S, I, or W are not sent but are noted in the log background processing.
Messages of the type E and A trigger the exception error_message and set sy-subrc to n_error. The message class, message type, message number, and the contents of possible placeholders for the MESSAGE statement are in the fields sy-msgid, sy-msgno, sy-msgty, and sy-msgv1, ... , sy-msgv4.
Thanks
naren
2008 Dec 08 5:20 PM
I understand, but here is the problem:
If the fm has exception defined, and the message had the statement with raising, then your suggestion would work: For example:
MESSAGE e002(xx) raising other.
But my calling fm does not have exception defined and the message statement is:
MESSAGE e002(xxx)
without the raising part.
So it stops and does not return.
2008 Dec 08 5:25 PM
Hi,
Please try it...I have used it in the past to suppress error message...and standard sap help says...that will catch the error messages raised without raising..
If the error_message addition is specified after EXCEPTIONS, all MESSAGE statements that are
executed during the processing of the function module and
do not have the RAISING addition
are affected as follows:
Thanks
Naren
2008 Dec 08 5:31 PM
I did try it, here is my test FM:
FUNCTION Z_CY_TEST_MG.
*"----
""Local Interface:
*" EXCEPTIONS
*" OTHER
*"----
MESSAGE e002(zq).
ENDFUNCTION.
And the calling program:
&----
*& Report Z_CY_TEST_MG
*&
&----
*&
*&
&----
REPORT Z_CY_TEST_MG.
CALL FUNCTION 'Z_CY_TEST_MG'
EXCEPTIONS
other = 1.
if sy-subrc = 1.
write: / 'error caught'.
endif.
If I have the statement "MESSAGE e002(zq) raising other", then its fine. But if I have it with out raising, then the message statements stop the program..
2008 Dec 08 5:35 PM
Hi,
Looks like you didn't the try the way I have mentioned..
REPORT Z_CY_TEST_MG.
CALL FUNCTION 'Z_CY_TEST_MG'
EXCEPTIONS
error_message = 1 " added this code..
other = 2.
if sy-subrc = 1.
write: / 'error caught'.
endif.
Thanks
Naren
2008 Dec 08 5:44 PM
It doesn't matter...The other exception should have caught everything already. However I did try your suggestion and it does not work.
Furthermore, I cannot change FM anyway. So it won't make a difference because I have no authority to make any modification to the FM.
I appreciate your suggestions but I think this is a dead end.
However, I remember there is a function module in SAP that initialize text, then any message text message executed afterwards would go into a buffer. Another FM can retrieve it.
I don't remember those FM, and thats why I am posting here to see if anyone else have used it or know those fm.
2008 Dec 08 6:03 PM
This worked for me
Function module
FUNCTION Z_TEST.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"----------------------------------------------------------------------
message e398(00) with 'Error message'.
ENDFUNCTION.
program
REPORT ztest.
CALL FUNCTION 'Z_TEST'
EXCEPTIONS
ERROR_MESSAGE = 9.
IF sy-subrc NE 0.
WRITE : / 'xx'.
ENDIF.
output displayed
XX.
2008 Dec 08 5:49 PM
Hi,
It should work...and not sure what you are missing...
check the code in the FM SD_RFC_SALES_ITEM_MAINTAIN...it is calling the function module SD_SALES_ITEM_MAINTAIN and it is catching the error messages raised inside...
probably try creating a new function module and call the existing function module and inside the new function module..catch the error_message exception...
Thanks
Naren
2008 Dec 08 6:08 PM