Application Development 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: 

Bapi and Logical Unit of Work

Former Member
0 Kudos

Hi all,

I am using Bapi to post records in a loop on internal table itab. After posting records, I am again looping at itab and populating those records to my custom table.

Does this scenario use 2 logical unit of work?

If yes, then please tell me how do I use one logical unit of work.

Thanks,

Ridhima

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hey,

You should not post records to the custom table if the BAPI posting has failed.

In order to maintain data consistency the logic in your program should be as below:

LOOP AT itab.

CALL BAPI.

IF BAPI Call is successful

Post data to Custom table.

CALL BAPI_TRANSACTION_COMMIT.

ELSE.

CALL BAPI_TRANSACTION_ROLLBACK.

ENDIF.

ENDLOOP.

Talking about LUW's, any program uses 1 SAP LUW and Multiple Database LUWs depending on the number times you COMMIT the data to the database.

If in your program you were to use only one COMMIT statement or no COMMIT statement at all, your program would use 1 SAP LUW and 1 database LUW.

-Kiran

*Please mark useful answers

2 REPLIES 2

Former Member
0 Kudos

Hey,

You should not post records to the custom table if the BAPI posting has failed.

In order to maintain data consistency the logic in your program should be as below:

LOOP AT itab.

CALL BAPI.

IF BAPI Call is successful

Post data to Custom table.

CALL BAPI_TRANSACTION_COMMIT.

ELSE.

CALL BAPI_TRANSACTION_ROLLBACK.

ENDIF.

ENDLOOP.

Talking about LUW's, any program uses 1 SAP LUW and Multiple Database LUWs depending on the number times you COMMIT the data to the database.

If in your program you were to use only one COMMIT statement or no COMMIT statement at all, your program would use 1 SAP LUW and 1 database LUW.

-Kiran

*Please mark useful answers

0 Kudos

Hi Ridhima,

When Function module is called from within a program, then does another LUW start ?

Regards,

Chitwanjit