‎2010 Jan 25 11:46 AM
Hi,
I'm using the standard function 'MD_STOCK_REQUIREMENTS_LIST_API' to get data like transaction MD04. In some conditions, that function shows an error message that isn't raised throught the function module to my report, the error it's just displayed and then the program is stopped.
Is there any way to use TRY-CATCH or something like this to catch the error message and then continue my report flow? I tried this, but the error isn't being catched:
TRY.
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = ls_replacement-matnr
werks = ls_replacement-werks
TABLES
mdpsx = lt_mdpsx
* MDEZX =
EXCEPTIONS
OTHERS = 1.
CATCH cx_root INTO go_cx_root.
* Read the error....
ENDTRY.
‎2010 Jan 25 11:53 AM
why not we try with 'BAPI_MATERIAL_STOCK_REQ_LIST' BAPI - which is calling this function module anyway.
‎2010 Jan 25 11:53 AM
why not we try with 'BAPI_MATERIAL_STOCK_REQ_LIST' BAPI - which is calling this function module anyway.
‎2010 Jan 25 11:54 AM
Because it isn't available in the SAP system that I'm working with
‎2010 Jan 25 11:57 AM
Oh...try as below where this bapi does
IMPORTING
e_mt61d = ls_mt61d
e_mdkp = ls_mdkp
e_cm61m = ls_cm61m
e_mdsta = ls_mdsta
TABLES
mdpsx = lt_mdpsx
mdezx = lt_mdezx
mdsux = lt_mdsux
EXCEPTIONS
error_message = 1.
‎2010 Jan 25 12:14 PM
Use 'message into(see f1 help)' or fm BALW_BAPIRETURN_GET2.
Pass the system variables you will get the message in export parameter of the fm.
data:gt_return type table of bapireturn.
data:ls_return type bapireturn.
if sy-subrc <> 0.
clear ls_return.
MESSAGE ID sy-msgid
TYPE sy-msgtyp
NUMBER sy-msgno
WITH sy-msgv1
sy-msgv2
sy-msgv3
sy-msgv4
INTO ls_return-message.
append ls_return to gt_return.
endif.
Edited by: Keshav.T on Jan 25, 2010 5:47 PM
‎2010 Jan 25 12:48 PM
Hi Keshav,
That's the problem that I'm having. The problem is that in the standard code of the funcion module there is an error MESSAGE statement that stops the process flow of my report.
I'm only looking for some way to "CATCH" the error message, in order to continue my report execution without showing the message to the user.
‎2010 Jan 25 1:16 PM
Can you try with exception as error_message?
.
EXCEPTIONS
*error_message = 1.*
.
‎2010 Jan 25 2:07 PM
As manohar as suggested, use the bapi and catch the exception using the fm or message into.
It will be solved.
‎2010 Jan 25 6:15 PM
Hi Keshav,
As I said before, In my system release the BAPI isn'tl available yet... The system is really "outdatet..."
And there is no way to catch the error message via EXCEPTIONS parameter in the function module, because the error isn't being RAISED by the function (That's the source of my problem!). The function module shows the message instead of raising it to my report... And I'm trying to find some way to manage the error message to prevent my program to be stopped by the FM
‎2010 Jan 25 6:48 PM
Try to find the reason why the exception is raised, you can correct the error .
Also check link:[http://help.sap.com/saphelp_47x200/helpdata/en/9f/db96ef35c111d1829f0000e829fbfe/content.htm]
Edited by: Keshav.T on Jan 26, 2010 12:20 AM
‎2010 Jan 25 9:32 PM
Marshal,
LISTEN and do what Manohar suggested.
EXCEPTIONS
error_message = 1.
This exception is internal to ABAP engine. It will not be defined in the exceptions of the FM. Whenever an FM calls 'E' message, the ABAP engine generates ERROR_MESSAGE exception and passes it to the calling program. If the calling program doesn't have a line for that exception, then the program will be terminated.
Just try it out instead of resisting
‎2010 Jan 26 8:16 AM
Thank you Manohar and thank you Sudhi Karkada, you "opened" my mind at last
When I read the Manohar answers I thought he was missing something or he was talking about the BAPI and I didn't understood it. Sorry for that.
Thank you again for that knowledge, it's not the first time that I found an standard function module with that kind of problem.
‎2010 Jan 25 10:11 PM
Maybe:
CALL FUNCTION 'MD_STOCK_REQUIREMENTS_LIST_API'
EXPORTING
matnr = ls_replacement-matnr
werks = ls_replacement-werks
TABLES
mdpsx = lt_mdpsx
* MDEZX =
EXCEPTIONS
material_plant_not_found = 1
plant_not_found = 2
OTHERS = 3.Rob