09-16-2014 4:34 PM
Hi,
I am elaborating my issue below.
1 ) I am using BAPI_PO_CREATE to create a po number.
2 ) Before use BAPI_TRANSACTION_COMMIT,
I am calling BAPI_GOODSMVT_CREATE to create material document, only by using the po number.
3 ) Once BAPI_GOODSMVT_CREATE is sucessfull then i am commiting both the bapi by BAPI_TRANSACTION_COMMIT.
4 ) But IF BAPI_GOODSMVT_CREATE is unsuccessful then i am calling BAPI_TRANSACTION_ROLLBACK for BAPI_PO_CREATE.
when i m checking by debug, its executing the BAPI_TRANSACTION_ROLLBACK,but the po is not removing / rollbacking from table like EKKO or EKPO table.
Please provide some suggestion, because if BAPI_GOODSMVT_CREATE is fails, i need to use BAPI_TRANSACTIOB_ROLLBACK for both the above mentioned bapi.
Thanks & Regards,
Ajit sarangi
09-16-2014 4:44 PM
09-16-2014 6:00 PM
Dear,
yes, I used one Commit for both bapi, bcz if i m using bapi commit once then it ll work for all bapi.
Another think is that before COMMIT, the newly created po number has updated in tables, that i checked. (ekko and ekpo).
even i use separate commit for both bapi , still roll back is not working.
So please suggest, if BAPI_GOODSMVT_CREATE has fail , how to roll back BAPI_PO_CREATE ?
Thanks & REgards,
Ajit sarangi
09-17-2014 9:18 AM
Uhm
but if you call the BAPI BAPI_PO_CREATE without the commit, how BAPI_GOODSMVT_CREATE can create an incoming goods for purchase order?
This order will exist only after calling the COMMIT
After creating the PO if BAPI_GOODSMVT_CREATE fails you should "delete" the PO
Max
09-17-2014 10:25 AM
Dear Ajit,
I had similar problem with 2 table updates.
Try using "SET UPDATE TASK LOCAL", this will solve problem like this.
Ex:
SET UPDATE TASK LOCAL.
Call BAPI1
if sy-subrc = 0.
Call BAPI2.
if Sy-subrc = 0.
Commit.
else.
Rollback.
endif.
endif.
09-20-2014 4:08 AM
Dear Max,
My Bapi_goodsmvt_create is creating the material document without commit to bapi_po_create,bcz with the po number created after bapi_po_create run and before bapi_po_create commit.
Then once bapi_goodsmvt_create is sucessfull, i m commiting both the bapi once by bapi_transaction_commit.
But whn 2nd bapi fails , i m not able to rollback the po number generated by first bapi execution.
plz help ????
Regards,
Ajit
09-20-2014 4:10 AM
Dear Noorie,
Using SET UPDATE TASK lOCAL
also i m not able to roll back. can u plz expain abt set update task local clearly.
its urgent...
09-21-2014 2:53 PM
09-21-2014 4:09 PM
Dear Noorie,
As you suggest, I have done by below code...
SET UPDATE TASK LOCAL.
Call BAPI_PO_CREATE
if sy-subrc = 0.
(I am getting po number and also it updated in ekko and ekpo table)
Call BAPI_GOODSMVT_CREATE
(Passing po number)
if Sy-subrc = 0.
Commit. for both bapi
else.
Rollback.
perform error_mvt
endif.
else.
perfor error_bapi_po.
endif.
09-21-2014 5:01 PM
It is impossible to see EKKO entries before commit on Oracle DB. Maybe you did a commit in the debugger ?
09-16-2014 8:07 PM
Hi Ajit,
you are using SQL-Server. Am i right ?
Kind regards,
Hans-Juergen
09-20-2014 4:11 AM
09-21-2014 3:38 PM
If you use Oracle-Db and you can see EKKO and EKPO filled ins SE16 before commit, something is wrong. Maybe you have an user-exit where someone programmed a "commit work".
09-17-2014 9:37 AM
Hi Ajit,
Try scenario of failed goods movement without debug. Use write something similar to know what PO was created. I think you'll find that ROLLBACK works.
-Regards,
Amit
09-20-2014 4:12 AM
Dear,
I debugged and chked that po number created and update in table like ekko, ekpo.
but roll back is woking.
09-21-2014 4:30 PM
Roll back will work within the LUW. Table entries also sometimes reverted whenever roll back calls.
Regards
Vadamalai A
09-22-2014 9:57 AM
Hi Ajit,
I think your code logic is fine and it should behave the way you want. Does your logic works fine (rollback scenario & commit scenario both) when you do not debug it?
If it does, then I would put the blame on debugger. If SAP debugger is running in Non-exclusive mode then it'll do roll-in & roll-out for each step of code and hence commit is triggered at each step. So the PO creation done by your first BAPI call is committed even before you decide to commit or rollback.
Please let the community know if this explains things.
-Regards,
Amit
09-21-2014 6:21 PM
Dear hans,
Its not impossible, I am facing the problem,so that i am asking for suggestions from you guys...
Once bapi execute, without commit the po number is updated in tables.
09-22-2014 8:17 AM
Dear Ajit,
that's why I was asking for your DB-System. If you use Microsoft SQL-Server you are right, if you you use Oracle you can not see anything without commit.
Go to any function module of function group XM06 and make a string search for "commit" in MAIN PROGRAM. Search bapi implementations for ME21N and do the same. There has to be reason why you can see EKKO and EKPO values before commit when using Oracle DB.
09-22-2014 10:24 AM
Hi
I think Hans is right, there's something in your PO creation process raises a COMMIT, else:
- The data would not be saved in table (all saving processes start after COMMIT, so without commit no data in DB;
- The second BAPI would fail: I can't still understand how BAPI_GOODSMVT_CREATE can create a MM document for a PO if the PO doesn't exist (if you don't call the COMMIT after BAPI_PO_CREATE, you can have only the PO number, nothing else.
So something doesn't sound good
Try to check in the user-exit
Max