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_TRANSACTION_COMMIT is dumping the program.

Former Member
0 Likes
9,027

I am Using BAPI    "BAPI_ACC_DOCUMENT_POST"   for FI Documents.

in return table, I am getting : 

TYPE  - S

ID     -   RW

MESSAGE - Document posted successfully: BKPFF 000030501310002013 STPCLNT600

After that when i am using BAPI_TRANSACTION_COMMIT, It cause a short dump.

I also tried Commit work  and wait.  But the response is same.

Please help me, this is really urgent.  

--> It may be urgent for you, but it is not for other members

The Dump message is:  

Long text of error message:

Diagnosis

     The material document posting was terminated to maintain data

     consistency. An expected COMMIT WORK or ROLLBACK WORK statement was

     triggered which is in turn caught by this error.

     Data has already been preselected for the UPDATE at the time of the

     COMMIT or ROLLBACK. If a COMMIT WORK or ROLLBACK is initiated in an

     enhancement, these are then written or rolled back into the

     database. If another error occurs during subsequent processing

     after a COMMIT, a complete ROLLBACK can no longer be performed,

     since the data up until the point of the COMMIT has already been

     written to the database. Otherwise, if no further errors occur

     following a ROLLBACK statement, the part that is subsequently

     entered into the posting is also written to the database.

     This can result in an inconsistent status, for example a material

     document without accounting document or an accounting document

     without a material document, which can only be repaired with

     considerable cost and effort.

     Inconsistencies that were caused by an incorrect implementation

     must be corrected by SAP in accordance with SAP Note 83020, subject

     to charge.

System Response

Procedure

     Remove the critical sections of code from your customer

     enhancements, such as MB_DOCUMENT_BADI. For more information about

     this error and how to avoid it, see SAP Note 1776835.

Procedure for System Administration

-

Message was edited by: Suhas Saha

1 ACCEPTED SOLUTION
Read only

deependra_shekhawat3
Contributor
0 Likes
5,729

Hi neeraj,

As per nabheet, there would be enhancement/BADI implementation  which having commit/rollback statements or in other words LUW are getting free. As BAPI_TRANSACTION_COMMIT runs an update process in system.

Thanks

Deependra

46 REPLIES 46
Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
4,824

You must be calling this in a BADI or enhancement. Please dont do a commit. Let SAP standard does it for you.

Read only

0 Likes
4,824

Hi, Nabheet,

  Yes, i am calling this in a badi. Recently we moved from ecc 6.0 to ehp 5.

My code was working fine old development. But in new development. It cause a dump.

and i am not able to understand the reason of dump.

Read only

PeterJonker
Active Contributor
0 Likes
4,824

A very clear error message off what you have done wrong. It even tells you what to do and which note to read.

Normally SAP is not so clear in what it means.

Why did you post the question  and why don't just read the error message and the note mentioned in the error message ? It explains everything you need to know.

Read only

deependra_shekhawat3
Contributor
0 Likes
5,731

Hi neeraj,

As per nabheet, there would be enhancement/BADI implementation  which having commit/rollback statements or in other words LUW are getting free. As BAPI_TRANSACTION_COMMIT runs an update process in system.

Thanks

Deependra

Read only

0 Likes
4,824

Hi Peter,

If i will not commit this, how i suppose to work further.

Cause i am picking the recently posted  BELNR from bkpf after that commit.

Read only

0 Likes
4,824

Maybe use perform on commit or define an rfc wrapper function module to do the task and call this in background task (new LUW), but first read the suggestions and note from SAP

Read only

0 Likes
4,824

You are doing something critically wrong which can cost the company you are working for a lot of money.

Did you read the passage in the error message:

"

Inconsistencies that were caused by an incorrect implementation

     must be corrected by SAP in accordance with SAP Note 83020, subject

     to charge.  "

????????

Read only

0 Likes
4,824

I think we need to hear more about the process being used.  I use BAPI_TRANSACTION_COMMIT after BAPI_ACC_DOCUMENT_POST in my own code with perfect success.  So it is the context in which the OP is calling these.

Neal

Read only

0 Likes
4,824

Exactly therefore why not read the note. Extract from the note:

If you want to avoid this error, check all customer enhancements in the FORM

routine BUCHEN_AUSFUEHREN in the include MM07MFB9_BUCHEN_AUSFUEHREN and remove

the existing COMMIT or ROLLBACK statements. Also check the methods and functions

that are called in your implementation. An SAP function module that is called in

a customer enhancement may also trigger a critical COMMIT statement. This is

incorrect.

Experience has shown that the incorrect implementation is in most

cases located in the BAdI MB_DOCUMENT_BADI in the method

MB_DOCUMENT_BEFORE_UPDATE. See SAP Notes 1284654 and 92550 for further

information.

Read only

ronaldo_aparecido
Contributor
0 Likes
4,824

Hi Neeraj.

       CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

         EXPORTING

           wait = 'X'.

Did you use the option wait?

You can send the code?

Read only

0 Likes
4,824

Hi Ronaldo,

Yes I did.

But still in the same position.

Read only

0 Likes
4,824

I think you should try to comment the bapi_commit and see what happens. Since it is in a BADI, there is  normally a bapi_commit done by SAP some point further in your flow. Try this and let us know what happens.

Read only

0 Likes
4,824

Neeraj,

Where you are commit , Could you please paste your code ??

Deependra

Read only

0 Likes
4,824

Dear Neeraj

I assume you have written this commit inside the badi MB_DOCUMENT_BADI.

Please romove this - BAPI_TRANSACTION_COMMIT statement.

Since you are trying to commit the database in between the whole process,  the system is not allowing this because, if any further rollback occurs, it cannot rollback whole as you already committed in between thus chances of data inconstancy.

Please remove this commit statement and check your transaction is complete. 

Regards,

Venkat

Read only

0 Likes
4,824

Hi Neeraj

What are you suppose to do further with this document? Basically you are interdering with sAP LUW when you do a commit it is not a good approrach. What i suggest is please telll us what exactly do you want to achieve via this enhancement. Their are many ways as everyone suggested either you can create a wrapper around you whole code and call it in background task etc.

Read only

0 Likes
4,824

Hi Neeraj

What are you suppose to do further with this document? Basically you are interdering with sAP LUW when you do a commit it is not a good approrach. What i suggest is please telll us what exactly do you want to achieve via this enhancement. Their are many ways as everyone suggested either you can create a wrapper around you whole code and call it in background task etc.

Read only

0 Likes
4,824

Here is my code:

LWA_DOC_HDR-bus_act = 'test1'.           "new
*    LWA_DOC_HDR-ref_doc_no = 'test2'.       "new
*    LWA_DOC_HDR-header_txt = 'test3'.       "new
    LWA_DOC_HDR-USERNAME = SY-UNAME.
    LWA_DOC_HDR-REF_DOC_NO = ref_number.
    LWA_DOC_HDR-COMP_CODE =  CCODE.                 "'1900'.
    LWA_DOC_HDR-DOC_DATE = WA_XMKPF-BLDAT."SY-DATUM.
    LWA_DOC_HDR-PSTNG_DATE = WA_XMKPF-BUDAT."'20090101'.
    LWA_DOC_HDR-DOC_TYPE = 'KC' .
    LWA_DOC_HDR-FISC_YEAR = FYEAR.                  "'2013'.
    LWA_DOC_HDR-FIS_PERIOD = FPERIOD.               "'03'.

    LWA_ACCPAY-ITEMNO_ACC = VEND.            "'0000000001'.
*    LWA_ACCPAY-VENDOR_NO = VENDOR.           "WA_XMSEG-WEMPF.
    LWA_ACCPAY-VENDOR_NO = VENDOR1.
    LWA_ACCPAY-GL_ACCOUNT = VACCT.
    LWA_ACCPAY-COMP_CODE = CCODE.
    LWA_ACCPAY-BUS_AREA = BAREA.
    LWA_ACCPAY-BUSINESSPLACE = CCODE.
    LWA_ACCPAY-SECTIONCODE = CCODE.
    LWA_ACCPAY-ALLOC_NMBR = WA_XMSEG-EBELN.
*    LWA_ACCPAY-ITEM_TEXT = VEND_GL.          "'TEST_VENDOR'.
    LWA_ACCPAY-ITEM_TEXT = VEND_GL1.
    APPEND LWA_ACCPAY TO IT_ACC_PAY.
    CLEAR LWA_ACCPAY.

    LWA_ACCNTGL-ITEMNO_ACC = GL.                    "'0000000002'.
    LWA_ACCNTGL-GL_ACCOUNT = '0004105001'.
    LWA_ACCNTGL-COMP_CODE  = CCODE.                 "'1900'  .
    LWA_ACCNTGL-DOC_TYPE   = 'KC'.
    LWA_ACCNTGL-COSTCENTER = CCENTRE."'0001000891'.
    LWA_ACCNTGL-BUS_AREA   = BAREA."'0001000891'.
*    LWA_ACCNTGL-ITEM_TEXT = VEND_GL.            
    LWA_ACCNTGL-ITEM_TEXT = VEND_GL1.
*    LWA_ACCNTGL-VENDOR_NO = VENDOR.         "WA_XMSEG-WEMPF.
    LWA_ACCNTGL-VENDOR_NO = VENDOR1.
    LWA_ACCNTGL-PSTNG_DATE  = WA_XMKPF-BUDAT."VENDOR."'0001000891'.
    LWA_ACCNTGL-FISC_YEAR = FYEAR.                  "'2013'.
    LWA_ACCNTGL-FIS_PERIOD = FPERIOD.               "'02'.
    LWA_ACCNTGL-TAXJURCODE = '9000'.
    LWA_ACCNTGL-ALLOC_NMBR = WA_XMSEG-EBELN.
    APPEND LWA_ACCNTGL TO IT_ACC_GL.
    CLEAR LWA_ACCNTGL.

    LWA_CURRAMNT-ITEMNO_ACC = VEND."VENDOR
    LWA_CURRAMNT-CURR_TYPE = '00'.
    LWA_CURRAMNT-CURRENCY   = 'INR'   .
    LWA_CURRAMNT-AMT_DOCCUR = PRICE1.  "'-10.00'.
    LWA_CURRAMNT-DISC_BASE  = PRICE1.
    APPEND LWA_CURRAMNT TO IT_CURR_AMT.
    CLEAR LWA_CURRAMNT.

    LWA_CURRAMNT-ITEMNO_ACC = GL."GL
    LWA_CURRAMNT-CURR_TYPE = '00'.
    LWA_CURRAMNT-CURRENCY   = 'INR'   .
    LWA_CURRAMNT-AMT_DOCCUR = 0 - PRICE1.  "'10.00' .   "
    LWA_CURRAMNT-DISC_BASE  = 0 - PRICE1.  "'10.00' .
    APPEND LWA_CURRAMNT TO IT_CURR_AMT.
    CLEAR LWA_CURRAMNT.

*************************************************************************************************

   AT LAST.
     CALL FUNCTION 'BAPI_ACC_DOCUMENT_POST' IN  BACKGROUND TASK AS SEPARATE UNIT
EXPORTING
  DOCUMENTHEADER   = LWA_DOC_HDR

**IMPORTING

**  OBJ_TYPE         =
**  OBJ_KEY          =
**  OBJ_SYS          =
TABLES
  ACCOUNTGL        =  IT_ACC_GL
  ACCOUNTPAYABLE   =  IT_ACC_PAY
  CURRENCYAMOUNT   =  IT_CURR_AMT
  RETURN           =  IT_RETURN
*extension1       =  lt_extn.
EXCEPTIONS
    OTHERS     = 1.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

EXPORTING
  WAIT = 'X'
IMPORTING
  RETURN    = RETURN .

  WAIT UP TO 10 SECONDS.

SELECT BELNR INTO CORRESPONDING FIELDS OF TABLE IT_BKPF FROM BKPF

          WHERE BUKRS = CCODE

          AND   BUDAT = WA_XMKPF-BUDAT

          AND   GJAHR = FYEAR

          AND   BLART = 'KC'.

        SORT IT_BKPF DESCENDING BY BELNR.

        READ TABLE IT_BKPF INTO WA_BKPF INDEX 1.

        WA_MIGO-PO_NO = WA_BKPF-BELNR.

        WA_MIGO-MBLNR = WA_XMKPF-MBLNR.

        MODIFY ZSCH_MIGO FROM WA_MIGO.

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

            EXPORTING

              WAIT = 'X'.

Read only

0 Likes
4,824

Why are you using the second BAPI_TRANSACTION_COMMIT?

Read only

0 Likes
4,824

Hi Neeraj

Please move this all code into a new function module which isRFC enabled and inside it call this code. Do not call BAPI in background instead call new function module in background.

Read only

0 Likes
4,824

Hi Neeraj

Please move this all code into a new function module which isRFC enabled and inside it call this code. Do not call BAPI in background instead call new function module in background.

Read only

0 Likes
4,824

To just commit the work.

Read only

0 Likes
4,824

Hi Nabheet,

I will try this and the i will let you know.

But i have a question,

The same implementation i did 7 days back in ECC 6.0 over there my code is working fine.

Now i am using EHP 5. Here the same code is not working.

Read only

0 Likes
4,824

The eror is due to the second commit on your  Ztable.

Remove the second commit.

Read only

0 Likes
4,824

Hi Venkateswaran,

I removed the second commit, But Still program dump.

The same implementation i did 7 days back in ECC 6.0 over there my code is working fine.

Now i am using EHP 5. Here the same code is not working. 

Read only

0 Likes
4,824

Can you tell us which BAPI_TRANSACTION_COMMIT the dump is on?

Neal

Read only

0 Likes
4,824

Please put a Break in BAPI_TRANSACTION_COMMIT.  Also, put a break on the command "commit work".  Now run your program and see all of the places that your code stops and the call stack for each.  When you find one that you didn't know about, there will be your problem. 

Then you will have to determine how to get away from your current problem.

My best guess is going to be that you will have to build this section of code into an FM and execute it as a background task as has been previously mentioned.

Neal

Read only

0 Likes
4,824

I thinks most likely, it is  the last one.

Read only

0 Likes
4,824

After

        MODIFY ZSCH_MIGO FROM WA_MIGO.

you don't need to use this,

        CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'

            EXPORTING

              WAIT = 'X'.

this function is only used when each time you call BAPI .

AND you should use COMMIT WORK AND WAIT instead.

Read only

0 Likes
4,824

Hi Wang,

I already removed that part.

But still same error.

Read only

0 Likes
4,824

Did you create a wrapper function module and call your all code inside.

Read only

0 Likes
4,824

Remove WAIT UP TO 10 SECONDS.

and where  the BAPI_TRANSCATION_COMMIT .

and add the following.

READ TABLE it_return WITH KEY type = 'E' TRANSPORTING NO FILEDS.

IF sy-subrc = 0.

   CALL FUNCATION 'BAPI_TRANSCATION_ROLLBACK'.

ELSE.

  CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'


EXPORTING

WAIT = 'X'

IMPORTING

RETURN   = RETURN .

ENDIF.

If this still can't solve the problem, you'd better to look for SAP NOTE which corresponding to your problem.

Read only

0 Likes
4,824

Hi Wang,

I tried tour code, But Still i am getting dump.

I also go through the Sap Note, Its asking for Service patch.

Then i talk to basis team, they told me there is some problem with MIGO transaction.

As soon it will be soled. I will try this again.

Read only

0 Likes
4,824

Have you navigate through the relevant enhancements that you have done, which may cause this problem.

Accout to SAP note, it is possible. 

Read only

0 Likes
4,824

Hi Nabheet,

Can u guide me, How to create a wrapper function module ?

Read only

Former Member
0 Likes
4,824

Hi Neeraj,

The code that gets executed inside BAPI_TRANSACTION_COMMIT is again COMMIT WORK with wait or COMMIT WORK AND WAIT in case wait = 'X' is not provided.

Committing work inside a BADI or an EXIT may result in wrong execution of program if the roll back needs to happen outside of BADI/ User Exit and is done through standard program.

To commit only a BAPI, you have to branch out of the program loop and come back but it is not recommended at all.

Tejus.

Read only

0 Likes
4,824

Hello all,

If a won't commit,

How i get the belnr from bkpf.

Read only

0 Likes
4,824

The problem is that it is (probably errantly) already being committed else where.  You have to find that commit and determine why it is being done and what the correct remedy is.

Neal

Read only

Former Member
0 Likes
4,824

Hi Neeraj,

Try the addition "BYPASSING BUFFER" in your select query, so that you will get updated entry from database.

Hope this helps...

Cheers,

Sumit

Read only

RaymondGiuseppi
Active Contributor
0 Likes
4,824

You MUST not use a COMMIT in a BAdi of a standard transaction which itself execute one.

Your call to BAPI MUST be executed in another LUW, so wrap it in a RFC enabled Z-FM (wrap the BAPI AND the COMMIT) and execute it IN BACKGROUND TASK, so it will execute after the material document is posted.

If you execute the CALL at a correct step you can also get the material document number and use it in your FI document and not a dummy BKPFF type but the material document MKPF. (User will see two FI document from MB03 standard ans customer specific)

Regards,

Raymond