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

​Runtime Errors COMMIT_IN_POSTING

Former Member
0 Likes
8,085

I want to create Purchase order based on material document in transaction MB1B,

1. IF_EX_MB_DOCUMENT_BADI ~ MB_DOCUMENT_BEFORE_UPDATE
2. IF_EX_MB_DOCUMENT_BADI ~ MB_DOCUMENT_UPDATE
3. EXIT_SAPLMBMB_001

I call "BAPI_PO_CREATE" function in Badi and exits above, I get the following error.
Many thanks in advance for your help

Category ABAP programming error
Runtime Errors COMMIT_IN_POSTING
ABAP Program SAPLBAPT
Application Component BC-MID-ALE

Short Text
Invalid COMMIT WORK in an update function module.

Information on where terminated

The termination occurred in the ABAP program or include "SAPLBAPT", in "TRANSACTION_END". the main program was "RSM13000". In the source code, the termination point is in line 10 of the program or include "LBAPTU05". The program "SAPLBAPT" was started in the update system.

1 ACCEPTED SOLUTION
Read only

Nawanandana
Active Contributor
0 Likes
5,544

Hi,

Don't use commit work with this BAPI, You must call BAPI_PO_CREATE function module as

CALL FUNCTION 'BAPI_PO_CREATE' IN UPDATE TASK. Otherwise It will give dump. Don't your

Try to call the BAPI_PR_CREATE1 in background task so that it creates a separate task.

In this case commit is not required. The task will start after commit has occured in the current transaction.

Regards,

Nawa

4 REPLIES 4
Read only

Former Member
0 Likes
5,544

Hi everyone,

I copied the problem with the BAPI_PO_CREATE function as ZBAPI_PO_CREATE and ran it as a background,

Read only

5,544

if you have copied the function, maybe you could try to set asynchronous

call function in update task ..

it seems something is doing a comit, at the wrong moment

Read only

Nawanandana
Active Contributor
0 Likes
5,545

Hi,

Don't use commit work with this BAPI, You must call BAPI_PO_CREATE function module as

CALL FUNCTION 'BAPI_PO_CREATE' IN UPDATE TASK. Otherwise It will give dump. Don't your

Try to call the BAPI_PR_CREATE1 in background task so that it creates a separate task.

In this case commit is not required. The task will start after commit has occured in the current transaction.

Regards,

Nawa

Read only

5,544

I don't really understand the way you say it.

I'd say: if one uses "commit work" during the update task, that triggers COMMIT_IN_POSTING. That is logic because an update task is being triggered via commit work, so commit work inside commit work is non-sense. C.f. ABAP documentation of COMMIT WORK.

Using IN BACKGROUND TASK (tRFC/SM58) is possible and should be executed before the standard commit work too (can also be executed inside the update task but that doesn't change anything).