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

BAPI sy-subrc

Former Member
0 Likes
1,981

Hello All,

I am working with a BAPI. While i am testing my BAPI I found that BAPI is failing to put the data in SAP. But still i am seeing that sy-subrc returned by BAPI is "0".

Why is it happening? How to fix it?

Thanks

SDN FAN

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,357

Hi,

If there is no row of type 'E' in the return internal table..WHich means it is successfully posted..

After calling the BAPI.

Call the function module 'BAPI_TRANSACTION_COMMIT' to commit the changes..Then check the database..

Thanks,

Naren

7 REPLIES 7
Read only

Former Member
0 Likes
1,357

Hi,

Bapi will not set the sy-subrc if there is any exception or successful..Instead you have to look at the parameter RETURN..Which will have error messages if there is any..

Example of how to check the error messages..

READ TABLE T_RETURN WITH KEY TYPE = 'E'.

IF SY-SUBRC = 0.

  • Not successful.

ELSE.

  • Successfull.

ENDIF.

Thanks,

Naren

Read only

0 Likes
1,357

Naren,

That is what I doing checking for some exepection catching into Return table which is not happening even though the recording not posted.

I found the reason for Return table not being filled up due to sy-subrc = 0.

Why it is happening is biggg!!! wonder for me

Read only

Former Member
0 Likes
1,357

Try to give Commit work after sy-subrc check.

Madhavi

Read only

0 Likes
1,357

Madhavi- My requirement was not save the record but to know why it is happening

Read only

Former Member
0 Likes
1,357

Hi,

CALL FUNCTION 'BAPI_TRANSACTION_COMMIT' after the BAPI call.

Check the BAPI table I_RETURN :

LOOP AT i_return INTO wa_return WHERE type = c_e AND

id <> c_mepo.

PERFORM populate_error_log USING c_fail

p_input-column1

ws_po

wa_return-message space space.

EXIT.

ENDLOOP.

Reward points if this helps.

Manish

Read only

uwe_schieferstein
Active Contributor
0 Likes
1,357

Hello

Assuming that you have committed your BAPI call either success or failure will be returned as following:

- Success: either no return message at all or 'S'(uccess) message

- Failure: at least a single 'AEX' message (abort, error, X = dump)

Regards

Uwe

Read only

Former Member
0 Likes
1,358

Hi,

If there is no row of type 'E' in the return internal table..WHich means it is successfully posted..

After calling the BAPI.

Call the function module 'BAPI_TRANSACTION_COMMIT' to commit the changes..Then check the database..

Thanks,

Naren