Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 
Read only

Error message in ABAP class

Former Member
0 Likes
2,062

Hello ,

I have  standard class, in this class there is a bapi used . In this bapi a error messaged is raised.

How can i capture this error message in my z FM.

Please note that there is no expection in the standard class and error message is raised by the bapi.

ZFM ---> standard class ----> Bapi.

6 REPLIES 6
Read only

Former Member
0 Likes
1,397

Please call the ZFM within TRY...CATCH..ENDTRY block.

In CATCH, you can catch exception into a reference variable (for example CX_ROOT) and get the message from GET_TEXT method.

Read only

0 Likes
1,397

According to OP, standard class does not raise any exception, so TRY...CATCH... has nothing to catch.

Read only

matt
Active Contributor
0 Likes
1,397

Don't catch CX_ROOT. You should only catch exceptions you're expecting to have raised, and react to those accordingly. If you get an unexpected error and use CX_ROOT, it can be a pain to find the cause of the error - as those who use BW will know...

Read only

alex_campbell
Contributor
0 Likes
1,397

If the standard class doesn't expose the error to you, there's nothing you can do about it. Check to see if the class has any error parameters, or sets any attributes, with the error data. That's the point of classes, give the calling program (in your case, ZFM) access to what it needs, and hide from it everything else.

If you post which class you are using, and how you're calling it, someone with experience with that class may be able to be helpful

Read only

0 Likes
1,397

Hello Alex,

thanks for ur help.

FM : /SAPRCX/SHPPLC

Class :

   CALL METHOD g_shp_appl->place_railcar.

I am calling the above fm in another z fm.

thanks

amit

Read only

0 Likes
1,397

Dear Amit,

please give class name which u r using and how u r using it.

     or

if you want to capture error message which is raised in bapi then create z class and modify it.