‎2013 Oct 24 1:01 PM
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.
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
‎2013 Oct 24 1:11 PM
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
‎2013 Oct 24 1:05 PM
You must be calling this in a BADI or enhancement. Please dont do a commit. Let SAP standard does it for you.
‎2013 Oct 24 1:12 PM
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.
‎2013 Oct 24 1:11 PM
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.
‎2013 Oct 24 1:11 PM
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
‎2013 Oct 24 1:16 PM
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.
‎2013 Oct 24 1:20 PM
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
‎2013 Oct 24 1:24 PM
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. "
????????
‎2013 Oct 24 1:29 PM
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
‎2013 Oct 24 1:33 PM
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.
‎2013 Oct 24 1:17 PM
Hi Neeraj.
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = 'X'.
Did you use the option wait?
You can send the code?
‎2013 Oct 24 1:19 PM
‎2013 Oct 24 1:25 PM
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.
‎2013 Oct 24 1:26 PM
Neeraj,
Where you are commit , Could you please paste your code ??
Deependra
‎2013 Oct 24 1:37 PM
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
‎2013 Oct 24 1:51 PM
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.
‎2013 Oct 24 1:51 PM
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.
‎2013 Oct 24 1:56 PM
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'.
‎2013 Oct 24 1:59 PM
‎2013 Oct 24 2:00 PM
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.
‎2013 Oct 24 2:00 PM
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.
‎2013 Oct 24 2:01 PM
‎2013 Oct 24 2:09 PM
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.
‎2013 Oct 24 2:14 PM
The eror is due to the second commit on your Ztable.
Remove the second commit.
‎2013 Oct 24 2:32 PM
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.
‎2013 Oct 24 7:58 PM
Can you tell us which BAPI_TRANSACTION_COMMIT the dump is on?
Neal
‎2013 Oct 24 8:53 PM
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
‎2013 Oct 25 1:47 AM
‎2013 Oct 25 1:49 AM
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.
‎2013 Oct 25 5:48 AM
‎2013 Oct 25 6:11 AM
Did you create a wrapper function module and call your all code inside.
‎2013 Oct 25 6:43 AM
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.
‎2013 Oct 25 9:00 AM
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.
‎2013 Oct 25 9:15 AM
Have you navigate through the relevant enhancements that you have done, which may cause this problem.
Accout to SAP note, it is possible.
‎2013 Oct 25 10:59 AM
Hi Nabheet,
Can u guide me, How to create a wrapper function module ?
‎2013 Oct 24 1:37 PM
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.
‎2013 Oct 24 1:53 PM
‎2013 Oct 24 1:56 PM
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
‎2013 Oct 24 2:48 PM
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
‎2013 Oct 24 2:49 PM
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