cancel
Showing results for 
Search instead for 
Did you mean: 

How to catch an ABAP Exception using .Net Connector?

Former Member
0 Kudos

Hi, I've created a SapProxy class with a function that wraps an ABAP function: TAX_NUMBER_CHECK. This function has 2 ABAP exceptions: different_fprcd and

not_valid.

When I test this function from SAP GUI I can check that it works properly, it throws ABAP exceptions when tax number is not correct. But when I try to catch this exception from my .NET application, no exception is thrown.

I changed MapBapiExceptions SapProxy class property to true, but nothing happend.

Can anybody help me with catching ABAP exceptions from .NET?

Best regards.

Accepted Solutions (0)

Answers (3)

Answers (3)

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Daniel,

if you want to work with BAPI's that are published as Web services you can also catch ABAP exceptions from .NET as I have described in my following blog:

Best regards,

André

Former Member
0 Kudos

Hi Andre, thanks for your reply.

I'm using ABAP function TAX_NUMBER_CHECK. A piece of code is the following:

SELECT SINGLE * FROM t005 WHERE land1 = country.

IF sy-subrc NE 0.

MESSAGE e001 WITH country RAISING not_valid.

ENDIF.

I can catch "NOT_VALID" ABAP exception from .NET, but proxy class properties "BapiReturn" and "BapiRetTable" are empty. Do you know if I can get "e001" message from .NET?

Regards

0 Kudos

Hello Daniel,

why you don't work with a BAPIRETURN or BAPIRET2 structure ? In this way you can get the error(s) and than throw it like André has descripted in his blog and samples.

Regards

Holger

Former Member
0 Kudos

Hi Holger, the problem is that my .NET proxy class properties "BapiReturn" and "BapiRetTable" are empty.

The ABAP function I am using does not return anything else than "NOT_VALID" ABAP exception. Please, see the following piece of ABAP code:

SELECT SINGLE * FROM t005 WHERE land1 = country.

IF sy-subrc NE 0.

MESSAGE e001 WITH country RAISING not_valid.

ENDIF.

Regards

Andre_Fischer
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Daniel,

you could do the following:

Exceptions that are thrown by an ABAP function module can be catched in ABAP as described in the SAP Online Help

<a href="http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db98ef35c111d1829f0000e829fbfe/content.htm">Calling Function Modules</a>

Then you can write a wrapper BAPI that will fill the BAPIRET2 structure based on the exception catched from the called function module.

Best regards,

Andre

Former Member
0 Kudos

I found that it is important the order the things are done.

If I set MapBapiExceptions to true first and then I drag & drop the function, ABAP exceptions are thrown. If I change the order, ABAP exceptions are ignored.

(Thanks to Reiner Hille-Doering's post on thread "Processing BAPIRET2 in VB.NET".)

Former Member
0 Kudos

I don't know whether you can catch exceptions via .net connector, but I can recommend another way. You can create ZTAX_NUMBER_CHECK function and you call TAX_NUMBER_CHECK bapi in this function. Parameters should be same as bapi. In this function you can use catch blocks to cath the bapi's exceptions. And you can return as a parameter the exception.

Best Regards

Huseyin Akturk

-


www.huseyinakturk.net