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

Handling error messages in BAPI

Former Member
0 Likes
1,058

Hello,

I am doing a replica of an SAP R3 std report in portal. I've converted the report pgm to a BAPI. My question is how to populate the BAPIRETURN table with the error messages raised from a std report? I mean how to capture these error messages? I am doing a SUBMIT to call this report from within the BAPI.

Thanks in advance.

Rgds,

Nathan.

Hello,

I am doing a replica of an SAP R3 std report in portal. I've converted the report pgm to a BAPI. My question is how to populate the BAPIRETURN table with the error messages raised from a std report? I mean how to capture these error messages? I am doing a SUBMIT to call this report from within the BAPI.

Thanks in advance.

Rgds,

Nathan.

5 REPLIES 5
Read only

Former Member
0 Likes
799

I believe you cannot capture errors from a submit statement..

Instead use CALL TRANSACTION and capture the messages in the MESSAGES addition..

CALL TRANSACTION 'ZZZ' MESSAGES INTO itab.

Thanks,

Naren

Read only

Former Member
0 Likes
799

If you are calling a BAPI from portal, what you are trying to do is to get the data for the given selection criteria. So, you should not do a SUBMIT of the report inside the BAPI, as SUBMIT just executes the report and doesn't give back the results to the BAPI

You should design the BAPI in such a way that you collect all the data you want and return them via parameters and if there is not data, then pass back the error parameters.

You could use the logic which is already there in the report to collect the data.

Regards,

Ravi

Read only

0 Likes
799

Hi,

Thanks for your immediate replies. I have taken a Z Version of the std report program. I am exporting the result table to memory in the Z program and importing it in the BAPI after the SUBMIT. This works fine. So for this approach is there any solution?

Rgds,

Nathan.

Read only

0 Likes
799

You can change your copy so that instead of raising error messages, it exports the errors to memory and then the BAPI imports them and passes them back to the caller.

Rob

Read only

Former Member
0 Likes
799

Hi,

Collect all the errors in an internal table..Lets say ITAB.

At the end of the program export it to the memory.

EXPORT T_ERRORS TO MEMORY ID 'BAPI_CALL'.

In the Bapi after the program is completed..use the import statement to get it from the memory...

SUBMIT 'ZREPORT' AND RETURN.

IMPORT T_ERRORS FROM MEMORY ID 'BAPI_CALL'.

Then pass the errors to the return parameter of the BAPI..

Thanks,

Naren