BAPI Lock issue
Hi Friends,
I have a situation where several instance of a workflow gets created at one time which as a part of the process calls a BAPI and updates a table. Only few instances could update the table successfully (Sometimes none). Rest of them couldnt. The BAPIRETURN message says 'E-PV100-Business Event nnnn is currently locked; Try again later'. I tried to call BAPI_TRANSACTION_COMMIT after the BAPI call. It didnt help. I tried to read all the locks for the user using FM ENQUE_READ and delete them using FM ENQUE_DELETE before and after the BAPI call. It doesnt help either.
How can this be handled? Prompt replies would be appreciated and rewarded suitably.
Thanks in advance.
Nathan.
Hi Nathan,
if COMMIT and WAIT does not help, a COMMIT without work has been issued before. Many not too experienced/responsible developers tend to issue COMMIT WORKS in any kind of user exit just to make sure that their specific changes get written to the database. And you have to survive with the results.
What you could do is check the locks and do a loop before calling BAPI as long as the object is locked. Here's some stone-old code we used for material updates:
FORM WARTEN_VERBUCHER
USING P_MAX_WAIT_SECONDS TYPE I
CHANGING P_SUBRC LIKE SY-SUBRC.
DATA:
L_ENDTIME LIKE SY-UZEIT,
L_TABIX LIKE SY-TABIX,
L_TRIES TYPE I,
L_SUCCESS LIKE SY-SUBRC,
L_ANSW TYPE C,
L_TRY_AGAIN LIKE RMCLS-XFLAG VALUE 'X'.
GET TIME.
L_ENDTIME = SY-UZEIT.
ADD P_MAX_WAIT_SECONDS TO L_ENDTIME.
WHILE L_TRY_AGAIN = 'X'.
LOOP AT ITAB.
PERFORM CHECK_LOCK_EMMARCE
USING ZAUF-WERKS ITAB-MATNR CHANGING P_SUBRC.
GET TIME.
IF P_SUBRC <> 0 OR SY-UZEIT >= L_ENDTIME.
EXIT. "Loop
ENDIF. " sy-subrc = 0.
ENDLOOP. " AT itab.
IF P_SUBRC = 0.
CLEAR: L_TRY_AGAIN.
ELSE.
IF SY-UZEIT >= L_ENDTIME .
PERFORM POPUP_TO_CONFIRM_WAIT
USING P_MAX_WAIT_SECONDS CHANGING L_ENDTIME P_SUBRC.
IF P_SUBRC <> 0.
CLEAR L_TRY_AGAIN.
ELSE.
CLEAR P_SUBRC.
ENDIF. " p_subrc <> 0.
ENDIF. " sy-uzeit >= l_endtime.
ENDIF. " p_subrc = 0.
ENDWHILE. " l_try_again = 'X'.
ENDFORM. " WARTEN_VERBUCHER
*& Form POPUP_TO_CONFIRM_WAIT
* -->P_WAIT_SECONDS
* <--P_ENDTIME
FORM POPUP_TO_CONFIRM_WAIT USING P_WAIT_SECONDS TYPE I
CHANGING P_ENDTIME LIKE SY-UZEIT
P_SUBRC LIKE SY-SUBRC.
DATA:
L_STARTCOLUMN LIKE SY-CUCOL VALUE 10,
L_STARTROW LIKE SY-CUROW VALUE 20,
L_TITLE(35),
L_TEXTLINE1(70),
L_TEXTLINE2(70),
L_ANSW.
L_TITLE = 'Warten auf gesperrte Tabelle'.
L_TEXTLINE1 = 'Tabelle(n) sind zur Zeit gesperrt'.
IF NOT SY-MSGV1 IS INITIAL. "Foreign lock
CONCATENATE L_TEXTLINE1 'durch Benutzer' SY-MSGV1
INTO L_TEXTLINE1 SEPARATED BY SPACE.
ENDIF. " sy-msgv1 IS INITIAL.
WRITE: P_WAIT_SECONDS TO L_TEXTLINE2.
CONDENSE: L_TEXTLINE2.
CONCATENATE:
'Wollen Sie weitere' L_TEXTLINE2 'Sekunden warten?'
INTO L_TEXTLINE2 SEPARATED BY SPACE.
L_STARTCOLUMN = SY-UZEIT+2(2) MOD 30 + 10.
L_STARTROW = SY-UZEIT+2(2) MOD 10 + 3.
CALL FUNCTION 'POPUP_TO_CONFIRM_STEP'
EXPORTING
* DEFAULTOPTION = 'Y'
TEXTLINE1 = L_TEXTLINE1
TEXTLINE2 = L_TEXTLINE2
TITEL = L_TITLE
START_COLUMN = L_STARTCOLUMN
START_ROW = L_STARTROW
* CANCEL_DISPLAY = 'X'
IMPORTING
ANSWER = L_ANSW
EXCEPTIONS
OTHERS = 1.
IF L_ANSW = 'J'. "(!)
GET TIME.
P_ENDTIME = SY-UZEIT.
ADD P_WAIT_SECONDS TO P_ENDTIME.
P_SUBRC = 0.
ELSE.
P_SUBRC = 8.
ENDIF. " l_answ = 'J'. "(!)
ENDFORM. " POPUP_TO_CONFIRM_WAIT
*& Form CHECK_LOCK_EMMARCE
* Prüfen ob Sperre gesetzt
* Code teilweise aus RSENQRR2 übernommen
* -->P_WERKS text *
* -->P_MATNR text *
* <--P_SUBRC text *
FORM CHECK_LOCK_EMMARCE
USING VALUE(P_WERKS) LIKE MARC-WERKS
VALUE(P_MATNR) LIKE MARC-MATNR
CHANGING P_SUBRC.
DATA: ENQ LIKE SEQG3 OCCURS 0 WITH HEADER LINE.
DATA: DEL LIKE SEQG3 OCCURS 0 WITH HEADER LINE.
DATA: SELECT_ALL.
DATA: GUSR LIKE SEQG3-GUSR.
DATA: GMODE LIKE SEQG3-GMODE.
DATA: GNAME LIKE SEQG3-GNAME.
DATA: GARG LIKE SEQG3-GARG.
DATA: GTARG LIKE SEQG3-GTARG.
DATA: GOBJ LIKE SEQG3-GOBJ.
DATA: GUNAME LIKE SEQG3-GUNAME.
DATA: GCLIENT LIKE SEQG3-GCLIENT.
DATA: GTCODE LIKE SEQG3-GTCODE.
DATA: GUSE LIKE SEQG3-GUSE.
DATA: GUSEVB LIKE SEQG3-GUSEVB.
DATA: GBCKTYPE LIKE SEQG3-GBCKTYPE..
DATA: GRANULE LIKE SEQTA.
*** initializations ****************************************************
FREE ENQ.
FREE DEL.
CLEAR: P_SUBRC.
* Konvertieren Matnr
CALL FUNCTION 'CONVERSION_EXIT_MATN1_INPUT'
EXPORTING
INPUT = P_MATNR
IMPORTING
OUTPUT = P_MATNR
EXCEPTIONS
OTHERS = 1.
GNAME = 'MARC'.
GOBJ = 'EMMARCE'.
GUNAME = SY-UNAME.
GCLIENT = SY-MANDT.
CONCATENATE SY-MANDT P_MATNR P_WERKS INTO GARG.
* first try via RFC, retry up to 3 times ******************************
DO 3 TIMES.
CALL FUNCTION 'ENQUEUE_READ'
EXPORTING
GCLIENT = GCLIENT
GUNAME = GUNAME
GNAME = GNAME
IMPORTING
SUBRC = P_SUBRC
TABLES
ENQ = ENQ
EXCEPTIONS
OTHERS = 1.
IF SY-SUBRC = 0.
EXIT.
ENDIF.
ENDDO.
* if RFC fails read via NFS ********************************************
IF SY-SUBRC <> 0.
CALL FUNCTION 'ENQUE_READ'
EXPORTING
GCLIENT = GCLIENT
GUNAME = GUNAME
GNAME = GNAME
GARG = GARG
IMPORTING
SUBRC = P_SUBRC
TABLES
ENQ = ENQ.
MESSAGE ID '03' TYPE 'W' NUMBER 113.
ENDIF. "sy-subrc <> 0.
LOOP AT ENQ.
CHECK ENQ-GARG(25) = GARG(25).
CHECK ENQ-GOBJ = GOBJ.
SY-MSGV1 = ENQ-GUNAME.
P_SUBRC = 8.
EXIT.
ENDLOOP." AT enq WHERE garg(25) = garg(25) and gobj = 'EMMARCE'.
ENDFORM. " CHECK_LOCK_EMMARCE
Please adapt to your needs; I think as your processes are running in background, you can take out the POPUP_TO_CONFIRM_WAIT. We used it just to have a chance to get out of the waiting loop if someone slept at his terminal...
Regards,
Clemens
Similar Messages
-
Delivery Document Lock Issue in Z Program using BAPI(s)
Hi,
I am a functional consultant posting this in ABAP forum. We have developed a Z-Program.
User enters the Service Order no. in this program and executes it.
The program then updates the following linked documents in the following sequence using BAPI(s)
Outbound Delivery
Service Notification
Service Order (This is done using BDC of IW32)
It sometimes happens that once the Program reaches the iw32 bdc, it gives error "Delivery XXXXXXXX is locked by User ID XXXXXX"
The user ID being that of the person executing the transaction.
This happens like 3 out of 100 times in the Production Server. We are unable to replicate this issue in Quality or Development Server.
We believe it to be a performance issue (database updating is slow)
However Client wants us to investigate the Program and see what is possible.
We are thinking of putting WAIT after the BAPI(s) of the Delivery Update.
Any suggestions, please help.Hello Suhas,
Thanks for the reply.
These documents are seperate objects but are interlinked. i.e I can see in the Document Flow for Service Order, which is the Service Notification and Outbound Delivery for the Material.
Also, If I'm in change mode in the Outbound Delivery, I cannot go into the change mode of the Service Order.
Yes, we are using BAPI_TRANSACTION_COMMIT after each BAPI in the Program. We have used the Wait Statement in all BAPIs for the Service Notification. These BAPI(s) are before the IW32 BDC.
I am copying code from one of the commit BAPI(s)
CALL FUNCTION 'BAPI_TRANSACTION_COMMIT'
EXPORTING
wait = c_x.
WAIT UP TO 1 SECONDS.
I noticed in the Outbound Delivery BAPI(s) (two of them) don't have the wait in the BAPI_TRANSACTION_COMMIT. Hence I though if we add this, could this resolve the issue?
Service Order gets updated last through BDC for IW32 after all the BAPI(s) are executed for Outbound Delivery and Service Notification.
I understand WAIT would increase processing time, that is why I am posting this to know if we have some other solution available for such a lock issue. -
How to prevent plant locking issue while calling a BAPI? Please help!
Hi Experts,
I have following scenario:
BizTalk sends 4B2 PIP to XI via JMS adapter. XI then sends the same to ECC system via ABAP Proxy.
4B2 PIP in our case contains one PO header and one line item.
In ECC, ABAP proxy calls BAPI to process the GR (Goods Receipt).
The problem is BizTalk can send many 4B2 PIPs simultaneously (Parallel). When The first PIP is getting processed in ECC the BAPI locks some plant data till it completes the GR. But if second PIP request comes when the first once is still getting processed then we get "plant is locked" error.
How can we avoid this plant locking error? What is the best option to solve this?
While calling BAPI in my ECC ABAP Proxy if I use qRFC as given by the code below then will it solve the problem?
Will this use only one queue "QUEUE01" for all the 4B2 PIP requests?
Will it create a new queue for every request?
If we assume that there are 3 PIP requests already in a queue. If the GR processing for the first PIP returns some data error (not the locking error) in the BAPIRETURN then will the second PIP gets processed or will it wait till the first one is successfully processed?
CALL FUNCTION 'TRFC_SET_QUEUE_NAME'
IMPORTING
QNAME = 'QUEUE01'.
CALL FUNCTION '<CREATE GR BAPI>'
IN BACKGROUND TASK
EXPORTING
TABLES ....
COMMIT WORK.
Thanks & Regards
GopalMan, you guys/gals are great! You notice everything...I sure appreciate all the help so far. I've updated a few things, but I still can't get x1 in the method to pass the right input to line 39. For instance, if I set a=2, b=4, and c=-30, then x1 should = 3 and x2 should =-5, but both keep showing -5. They are always equal for some reason, even when they are not supposed to be.
I see what you were saying with d always equalling zero. I was looking in the main where it doesn't always = zero, but in the method it was always set to zero. Thanks...good eye!
num1 = quad(a, b, c, 1); //line 39
num2 = quad(a, b, c, 2); //line 40
JOptionPane.showMessageDialog(null, "There are two real roots. They are root 1 = "+ num1 + " , and root 2 = " + num2 + ".");I also added this to the method so d won't always = zero
d = (Math.pow(b,2) - (4 * a * c));I also have all of the variables declared at the top, but I forgot to copy and paste all of them and I updated the System.exit(0) to close the JOptionPane along with extra } 's to close the program correctly.
Again, thanks a bunch. -
Locking issue in workflow with conseutive database update
Dear Workflowers,
We are in ECC 5.0 and release 6.40. We went live for SAP in February and we are currently using workflow in PLM module for DMS and ECM.
We have been facing this locking issue randomly happened in our production and quality system. The error from workflow log is "Document XXXX is locked by WF-BATCH". I have two steps in workflow one is to update the document user( from originator to editor with custom BO "zdraw" new method "setuser") and the next step is to update the document status( BO "zdraw" "setstatus" method which inherited form standard BO "draw").
I have tried to use "wait" (1st try) , statements "BAPI_DOCUMENT_ENQUEUE", "BAPI_DOCUMENT_DEQUEUE" (2nd try) and "Commit work and wait" (3rd try) to add one step in between, however the issue remains.
The other question I had was we need to write "commit work" when we use BAPI to perform database update in the ABAP program. But I don't see "commit work" in the method of BO(for example "setstatus" in "draw" object) which performs database update. How does workflow perform DB update properly without "commit work" by referencing standard method?
Could anyone please share your expertise with the issue I am facing?
Thank you in advance,
MertaHi Merta,
Regarding COMMITs: theoretically you should never use COMMIT statements because the Workflow runtime handles that - the transaction of executing the task is the LUW, not your method. By adding COMMIT WORK you are also committing the workflow task execution.
In practice however there are the occasional exceptions where something just won't work without an explicit commit - but the theory remains that you should always try it without.
Regarding your problem, the one way to be certain that a DB update is complete is to use a terminating event - either through change documents or status management.
Failing that, you can write a wrapper method for SETSTATUS that does something like:
do 10 times.
try to lock it.
if success.
unlock.
swc_call_method self 'SetStatus' container.
set success flag.
else.
wait up to 3 seconds.
endif.
enddo.
if no success, raise exception.
Cheers,
Mike -
Locking issue with BAPI_GOODSMVT_CREATE in userexit_save_document
Hello All,
I am performing a separate goods movement for one of the materials in the delivery userexit_save_document during PGI. I have an issue. We might have multiple users trying to PGI deliveries and thereby performing the goods movement for the same material through the BAPI in the userexit_save_document.
How do I prevent the locking issue when say two users go through the BAPI for goods movement for the same material data at the same time.
Any answer in this regards is highly appreciated.
Thanks,
MathangiThanks Rich... this make work for me, but one question -
Do you know if this function releases all lock objects for the user system wide or only for the current session? My concern is that if it is system wide, then I could be releasing lock objects for other sessions unintentionally. For example, if there are multiple RFC calls in parallel for the same function and same user then I could be destroying lock entries that I shouldn't be! I am hoping that it removes lock entries only for the current session...
any ideas?
Regards,
Lee
> I've used this BAPI in many of my programs, and
> always after the call, I code.....
>
>
>
> commit work and wait.
> call function 'DEQUEUE_ALL'.
>
>
>
> The DEQUEUE_ALL show release any/all locks.
>
>
> Regards,
> Rich Heilman -
Hi,
We have found locking issue while accessing same report(Created in Report Designer) by multi users at a time .
Has anyone face this issue and How to fix it. It's major concern because same report can be accessed by multiusers at same time
Thanks
SivaSiva,
only one person at a time has permission to open the report in the Report designer - just like with Queries in the query designer. This should not have any effect on you actually executing the report in the portal - multiple people can do it then.
this is a security issue that other software vendors use as well - just like you cannot open any MS Office files on the network for editing that someone has opened already.
Thanks -
Locking Issue in Planning DSO in SAP BW 7.3(Integrated Planning)
Hi Experts,
We have built Aggregation Level on Direct Update (planning enabled) DSO and used the same in the input ready queries.( Its complete Manual planning - new row addition feature in WAD).
We have 5 characteristic and one key figure for planning.
We are facing lock issue while planning the data i.e. when one user is planning, other user cannot plan.
The lock relevant characteristic is Column A and the same has been added to the Lock Characteristic tab(RSPLSE) of the infoprovider. The input ready query is also restricted with a variable on Column A (manual input single variable- mandatory).
While the user opens the Planning Layout and plans the data, we can see lock entry in RSPLSE(locks tab) for the Column A selection in the infoprovider, yet if another user is trying to plan for data for some other selection of Column A, a lock entry in RSPLSE is shown with the selection but it errors in thelayout with lock on the infoprovider and cannot plan the data.
Any inputs will be of great help.
Regards,
PriyankaPost is closed.
Refer http://scn.sap.com/thread/3564212 for the solution.
Regards,
Priyanka -
Locking Issue in Planning DSO- SAP BW 7.3 Integarted Planning
Hi Experts,
We have built Aggregation Level on Direct Update (planning enabled) DSO and used the same in the input ready queries.( Its complete Manual planning - new row addition feature in WAD).
We have 5 characteristic and one key figure for planning.
We are facing lock issue while planning the data i.e. when one user is planning, other user cannot plan.
The lock relevant characteristic is Column A and the same has been added to the Lock Characteristic tab(RSPLSE) of the infoprovider. The input ready query is also restricted with a variable on Column A (manual input single variable- mandatory).
While the user opens the Planning Layout and plans the data, we can see lock entry in RSPLSE(locks tab) for the Column A selection in the infoprovider, yet if another user is trying to plan for data for some other selection of Column A, a lock entry in RSPLSE is shown with the selection but it errors in thelayout with lock on the infoprovider and cannot plan the data.
Any inputs will be of great help.
Regards,
PriyankaFound the answer.
We had used the Planning Function directly in the WAD layout before saving data without filter.(basically to check some condition).
Created the Planning Sequence with Column A filter on the Aggregation level and used the same sequence before saving the data in WAD
Issue resolved.
Consider this post as closed.
Regards,
Priyanka -
[ADF-11.1.2] Locking issue with SQL 92
I see one Locking issue with SQL92 Oracle ADF Application.
ADF Version: [ADF-11.1.2]
Database: Oracle 10g Express Edition
Situation 1:
With Following setting:
File: Application Resource > Description > ADF META-INF > adf-config.xml
<startup>
<amconfig-overrides>
<config:Database jbo.SQLBuilder="SQL92" jbo.locking.mode="optimistic"/>
</amconfig-overrides>
</startup>I have a page showing record 'x' of view object. I open same record on another page. Now I have same record showing on two different tabs of browser.
1. I modify first record and save it. It worked... Got commited to database.
2. I goto second tab and modify same record and tried to same it. It throws me an error - Another user has changed the row with primary key oracle.jbo.Key[38 ] . As expected...
3. I then, reopen the same record on 3rd tab of browser. Modify it and tried to save it. It just hang... as if it is processing the record endlessly.
If I see the Log:
<BaseSQLBuilderImpl> <doEntitySelectForAltKey> [312] BaseSQLBuilderImpl Executing doEntitySelect ... (true)
<BaseSQLBuilderImpl> <doEntitySelectForAltKey> [313] Generating new LOCK statement
<BaseSQLBuilderImpl> <buildSelectString> [314] Built select: 'SELECT ID, CI_ID, COLUMN_NAME, DISPLAY_COLUMN_NAME, COLUMN_VALUE, CREATE_DATE, CREATE_BY FROM ESUSER.CI_AUDIT'
<BaseSQLBuilderImpl> <doEntitySelectForAltKey> [315] Executing LOCK "SELECT ID, CI_ID, COLUMN_NAME, DISPLAY_COLUMN_NAME, COLUMN_VALUE, CREATE_DATE, CREATE_BY FROM ESUSER.CI_AUDIT WHERE ID=? FOR UPDATE"
<BaseSQLBuilderImpl> <bindWhereAttrValue> [316] Where binding param 1: 38
That's it.. nothing happens further.. If I execute above query on SQL Worksheet, it doesn't come up with the result. Just hang for something...
SELECT ID, CI_ID, COLUMN_NAME, DISPLAY_COLUMN_NAME, COLUMN_VALUE, CREATE_DATE, CREATE_BY FROM ESUSER.CI_AUDIT WHERE ID='38' FOR UPDATE I can execute above query for other record of same table but not '38'. Even if I fire commit command to database, it is not working.
I have to restart the database services to bring everything to normal state.
Situation 2:
With Oracle as Database :
<startup>
<amconfig-overrides>
<config:Database jbo.SQLBuilder="Oracle" jbo.locking.mode="optimistic"/>
</amconfig-overrides>
</startup>Everything is working file. i.e. at step 3, record is getting modified successfully with following log:
<OracleSQLBuilderImpl> <doEntitySelectForAltKey> [27] OracleSQLBuilder Executing doEntitySelect on: ESUSER.CI_AUDIT (true)
<ADFLogger> <begin> Entity read all attributes
<OracleSQLBuilderImpl> <buildSelectString> [28] Built select: 'SELECT ID, CI_ID, COLUMN_NAME, DISPLAY_COLUMN_NAME, COLUMN_VALUE, CREATE_DATE, CREATE_BY FROM ESUSER.CI_AUDIT CIAudit'
<OracleSQLBuilderImpl> <doEntitySelectForAltKey> [29] Executing LOCK...SELECT ID, CI_ID, COLUMN_NAME, DISPLAY_COLUMN_NAME, COLUMN_VALUE, CREATE_DATE, CREATE_BY FROM ESUSER.CI_AUDIT CIAudit WHERE ID=? FOR UPDATE NOWAIT
<ADFLogger> <addContextData> Entity read all attributes
<OracleSQLBuilderImpl> <bindWhereAttrValue> [30] Where binding param 1: 38
<ADFLogger> <addContextData> Entity read all attributes
<ADFLogger> <end> Entity read all attributes
<ADFLogger> <end> Lock Entity
<ADFLogger> <begin> Before posting the entity's changes
<ADFLogger> <begin> Updating audit columns
<ADFLogger> <end> Updating audit columns
<ADFLogger> <end> Before posting the entity's changes
<OracleSQLBuilderImpl> <doEntityDML> [31] OracleSQLBuilder Executing, Lock 2 DML on: ESUSER.CI_AUDIT (Update)
<OracleSQLBuilderImpl> <buildUpdateStatement> [32] UPDATE buf CIAudit>#u SQLStmtBufLen: 210, actual=60
<OracleSQLBuilderImpl> <doEntityDML> [33] UPDATE ESUSER.CI_AUDIT CIAudit SET COLUMN_VALUE=? WHERE ID=?
<ADFLogger> <begin> Entity DML
<OracleSQLBuilderImpl> <bindUpdateStatement> [34] Update binding param 1: cip7ri1
<OracleSQLBuilderImpl> <bindWhereAttrValue> [35] Where binding param 2: 38
<ADFLogger> <addContextData> Entity DML
<ADFLogger> <end> Entity DML
Can any one please tell me, what is the issue with SQL92 setting ?
Edited by: Anandsagar Sah on Mar 11, 2012 8:10 AMThe framework works correctly in the Situation #1. Please, note that the locking statement in this case is "SELECT ... FOR UPDATE", but not "SELECT ... FOR UPDATE NOWAIT" (as it is in the Situation #2). When you entered the 2nd tab and tried to update the row, then the framework executed the locking statement and the row was locked (and it remained locked because the framework detected that another user had modified the row, so it stopped the processing and no COMMIT operation was executed). When you entered the 3rd tab and tried to update the row, then the framework tried to lock the row againg, but the locking statement was blocked by the existign lock and it started waiting on the lock from the 2nd tab. So this is expected behaviour.
The interesting question is why you do not get any error in the Situation #2. In my opinion you should get an error because the locking statement from the 3rd tab should fail immediately (because the row should have been locked from the 2nd tab and the locking statement is with NOWAIT option). I suspect that when the DB is Oracle and you use Oracle SQLBuilder, then the ADF issues a DB savepoint at the beginning of the DML operation and rolls back to the savepoint is a case of some failure, so the 2nd tab has not left any lock. You can check this by setting on SQL trace on the DB server.
Dimitar -
Hi ,
We are processing IDoc. The IDoc FM does GR of STO by using MIGO transaction via BDC , then FM also does GR of STO Delivery number by using VL02N transaction . MIGO transaction is successful but while doing GR of STO Delivery number via VL02N we are getting an error like ' Purchase order XXXXXXXXXX is currently locked by user XXXXXX .
This happens if we process the IDoc in background . If I process the IDoc in foreground by putting breakpoint at MIGO and VL02N , it executes successfully .
I feel it is a locking issue . I tried using FM DEQUEUE_ALL , MM_DEQUEUE_DOCUMENT after MIGO but it did not work out .
Please suggest for any pointers on this locking issue .
Regards,
Kiran.Forget about WAIT statement.
Use:
set update task local.
...before starting MIGO.
regards -
FOR UPDATE cursor is causing Blocking/ Dead Locking issues
Hi,
I am facing one of the complex issues regarding blocking / dead locking issues. Please find below the details and help / suggest me the best approach to ahead with that.
Its core Investment Banking Domain, in Our Day to day Business we are using many transaction table for processing trades and placing the order. In specific there are two main transaction table
1) Transaction table 1
2) Transaction table 2
These both the tables are having huge amount of data. In one of our application to maintain data integrity (During this process we do not want other users to change these rows), we have placed SELECT …………….. FOR UPDATE CURSOR on these two table and we have locked all the rows during the process. And we have batch jobs (shell scripts ) , calling this procedure , we will be running 9 times per day 1 hrs each start at 7:15AM in the morn finish it up in the eve 5PM . Let’s say. The reason we run the same procedure multiple times is, our business wants to know the voucher before its finalized. Because there is a possibility that order can be placed and will be updated/cancelled several times in a single day. So at the end of the day , we will be sending the finalized update to our client.
20 07 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 08 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 09 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 10 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 11 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 12 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 13 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 14 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 15 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 16 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
20 17 * * 1-5 home/bin/app_process_prc.sh >> home/bin/app1/process.out
Current Program will look like:
App_Prc_1
BEGIN
/***** taking the order details (source) and will be populate into the table ****/
CURSOR Cursor_Upload IS
SELECT col1, col2 … FROM Transaction table1 t 1, Source table 1 s
WHERE t1.id_no = t2.id_no
AND t1.id_flag = ‘N’
FOR UPDATE OF t1.id_flag;
/************* used for inserting the another entry , if theres any updates happened on the source table , for the records inserted using 1st cursor. **************/
CURSOR cursor_update IS
SELECT col1, col2 … FROM transaction table2 t2 , transaction table t1
WHERE t1.id_no = t2.id_no
AND t1.id_flag = ‘Y’
AND t1.DML_ACTION = ‘U’,’D’ -- will retrieve the records which are updated and deleted recently for the inserted records in transaction table 1 for that particular INSERT..
FOR UPDATE OF t1.id_no,t1.id_flag;
BLOCK 1
BEGIN
FOR v_upload IN Cursor_Upload;
LOOP
INSERT INTO transaction table2 ( id_no , dml_action , …. ) VALUES (v_upload.id_no , ‘I’ , … ) RETURNING v_upload.id_no INTO v_no -- I specify for INSERT
/********* Updating the Flag in the source table after the population ( N into Y ) N order is not placed yet , Y order is processed first time )
UPDATE transaction table1
SET id_FLAG = ‘Y’
WHERE id_no = v_no;
END LOOP;
EXCEPTION WHEN OTHER THEN
DBMS_OUTPUT.PUT_LINE( );
END ;
BLOCK 2
BEGIN -- block 2 starts
FOR v_update IN Cursor_Update;
LOOP;
INSERT INTO transaction table2 ( id_no ,id_prev_no, dml_action , …. ) VALUES (v_id_seq_no, v_upload.id_no ,, … ) RETURNING v_upload.id_no INTO v_no
UPDATE transaction table1
SET id_FLAG = ‘Y’
WHERE id_no = v_no;
END LOOP;
EXCEPTION WHEN OTHER THEN
DBMS_OUTPUT.PUT_LINE( );
END; -- block2 end
END app_proc; -- Main block end
Sample output in Transaction table1 :
Id_no | Tax_amt | re_emburse_amt | Activ_DT | Id_Flag | DML_ACTION
01 1,835 4300 12/JUN/2009 N I ( these DML Action will be triggered when ever if theres in any DML operation occurs in this table )
02 1,675 3300 12/JUN/2009 Y U
03 4475 6500 12/JUN/2009 N D
Sample output in Transaction table2 :
Id_no | Prev_id_no Tax_amt | re_emburse_amt | Activ_DT
001 01 1,835 4300 12/JUN/2009 11:34 AM ( 2nd cursor will populate this value , bcoz there s an update happened for the below records , this is 2nd voucher
01 0 1,235 6300 12/JUN/2009 09:15 AM ( 1st cursor will populate this record when job run first time )
02 0 1,675 3300 12/JUN/2009 8:15AM
003 03 4475 6500 12/JUN/2009 11:30 AM
03 0 1,235 4300 12/JUN/2009 10:30 AM
Now the issues is :
When these Process runs, our other application jobs failing, because it also uses these main 2 tranaction table. So dead lock is detecting in these applications.
Solutin Needed :
Can anyone suggest me , like how can rectify this blocking /Locking / Dead lock issues. I wants my other application also will use this tables during these process.
Regards,
Maranhmmm.... this leads to a warning:
SQL> ALTER SESSION SET PLSQL_WARNINGS='ENABLE:ALL';
Session altered.
CREATE OR REPLACE PROCEDURE MYPROCEDURE
AS
MYCOL VARCHAR(10);
BEGIN
SELECT col2
INTO MYCOL
FROM MYTABLE
WHERE col1 = 'ORACLE';
EXCEPTION
WHEN PIERRE THEN
NULL;
END;
SP2-0804: Procedure created with compilation warnings
SQL> show errors
Errors for PROCEDURE MYPROCEDURE:
LINE/COL ERROR
12/9 PLW-06009: procedure “MYPROCEDURE” PIERRE handler does not end in RAISE or RAISE_APPLICATION_ERROR
:) -
Row locking issue with version enabled tables
I've been testing the effect of locking in version enabled tables in order to assess workspace manager restrictions when updating records in different workspaces and I have encountered a locking problem where I can't seem to update different records of the same table in different sessions if these same records have been previously updated & committed in another workspace.
I'm running the tests on 11.2.0.3. I have ROW_LEVEL_LOCKING set to ON.
Here's a simple test case (I have many other test cases which fail as well but understanding why this one causes a locking problem will help me understand the results from my other test cases):
--Change tablespace names as required
create table t1 (id varchar2(36) not null, name varchar2(50) not null) tablespace XXX;
alter table t1 add constraint t1_pk primary key (id) using index tablespace XXX;
exec dbms_wm.gotoworkspace('LIVE');
insert into t1 values ('1', 'name1');
insert into t1 values ('2', 'name2');
insert into t1 values ('3', 'name3');
commit;
exec dbms_wm.enableversioning('t1');
exec dbms_wm.gotoworkspace('LIVE');
exec dbms_wm.createworkspace('TESTWSM1');
exec dbms_wm.gotoworkspace('TESTWSM1');
--update 2 records in a non-LIVE workspace in preparation for updating in different workspaces later
update t1 set name = name||'changed' where id in ('1', '2');
commit;
quit;
--Now in a separate session (called session 1 for this example) run the following without committing the changes:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
--Now in another session (session 2) update a different record from the same table. The below update will hang waiting on the transaction in session 1 to complete (via commit/rollback):
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
I'm surprised records of different ids can't be updated in different sessions i.e. why does session 1 lock the update of record 2 which is not being updated anywhere else. I've tried this using different non-LIVE workspaces with similar results. I've tried changing table properties e.g. initrans with and still get a lock. The changes to table properties are successfully propagated to the _LT tables but not all the related workspace manager tables created for table T1 above. I'm not sure if this is the issue.
Note an example of the background workspace manager query that may create the lock is something like:
UPDATE TESTWSM.T1_LT SET LTLOCK = WMSYS.LT_CTX_PKG.CHECKNGETLOCK(:B6 , LTLOCK, NEXTVER, :B3 , 0,'UPDATE', VERSION, DELSTATUS, :B5 ), NEXTVER = WMSYS.LT_CTX_PKG.GETNEXTVER(NEXTVER,:B4 ,VERSION,:B3 ,:B2 ,683) WHERE ROWID = :B1
Any help with this will be appreciated. Thanks in advance.Hi Ben,
Thanks for your quick response.
I've tested your suggestion and it does work with 2 workspaces but the same problem is enountered when additional workspaces are created.
It seems if multiple workspaces are used in a multi user environment, locks will be inevitable which will degrade performance especially if a long transaction is used.
Deadlocks can also be encountered where eventually one of the sessions is rolled back by the database.
Is there a way of avoiding this e.g. by controlling the creation of workspaces and table updates?
I've updated my test case below to demonstrate the extra workspace locking issue.
--change tablespace name as required
create table t1 (id varchar2(36) not null, name varchar2(50) not null) tablespace XXX;
alter table t1 add constraint t1_pk primary key (id) using index tablespace XXX;
exec dbms_wm.gotoworkspace('LIVE');
insert into t1 values ('1', 'name1');
insert into t1 values ('2', 'name2');
insert into t1 values ('3', 'name3');
commit;
exec dbms_wm.enableversioning('t1');
exec dbms_wm.gotoworkspace('LIVE');
exec dbms_wm.createworkspace('TESTWSM1');
exec dbms_wm.gotoworkspace('TESTWSM1');
update t1 set name = name||'changed' where id in ('1', '2');
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
--end of original test case, start of additional workspace locking issue:
Session 1:
rollback;
Session 2:
rollback;
--update record in both workspaces
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '3';
commit;
exec dbms_wm.gotoworkspace('TESTWSM1');
update t1 set name = 'changed' where id = '3';
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
Session 1:
rollback;
Session 2:
rollback;
exec dbms_wm.gotoworkspace('LIVE');
exec dbms_wm.createworkspace('TESTWSM2');
exec dbms_wm.gotoworkspace('TESTWSM2');
update t1 set name = name||'changed2' where id in ('1', '2');
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
--this now gets locked out by session 1
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
Session 1:
rollback;
Session 2:
rollback;
--update record 3 in TESTWSM2
exec dbms_wm.gotoworkspace('TESTWSM2');
update t1 set name = 'changed' where id = '3';
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
--this is still locked out by session 1
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
Session 1:
rollback;
Session 2:
rollback;
--try updating LIVE
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '3';
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
--this is still locked out by session 1
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
Session 1:
rollback;
Session 2:
rollback;
--try updating TESTWSM1 workspace too - so all have been updated since TESTWSM2 was created
exec dbms_wm.gotoworkspace('TESTWSM1');
update t1 set name = 'changed' where id = '3';
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
--this is still locked out by session 1
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
Session 1:
rollback;
Session 2:
rollback;
--try updating every workspace afresh
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changedA' where id = '3';
commit;
exec dbms_wm.gotoworkspace('TESTWSM1');
update t1 set name = 'changedB' where id = '3';
commit;
exec dbms_wm.gotoworkspace('TESTWSM2');
update t1 set name = 'changedC' where id = '3';
commit;
Session 1:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '1';
--this is still locked out by session 1
session 2:
exec dbms_wm.gotoworkspace('LIVE');
update t1 set name = 'changed' where id = '2';
Session 1:
rollback;
Session 2:
rollback; -
Bapi Improvement Issue - 'BAPI_PBSRVAPS_CHANGEKEYFIGVAL'?
Hi,
I am using the following BAPI to change the Key figure value . I am using the following Export combinations .
I am not sure but still the BAPI performance issues we are facing. Is anything else we can use the steps to improve the performance of following BAPI.?
Also do need to pass more export paramters for the same ? If yes, please share the same how to use that.
CALL FUNCTION 'BAPI_PBSRVAPS_CHANGEKEYFIGVAL'
EXPORTING
PLANNINGBOOK = PLANNING_BOOK
DATA_VIEW =
SELECTION_ID =
LOGICAL_SYSTEM =
BUSINESS_SYSTEM_GROUP =
SOURCE_PARTNER =
TARGET_PARTNER =
COMMIT_CONTROL = 'E'
Appreciated your inputs regarding the same.
Thank you - Prasad.Thank you Emmanuel for the response.
Please see my comments below.
1. How much data are you passing to the BAPI? (e.g. how many combinations
Comment : - Min record size is of 6000 records in a file and more .
2) Are you calling the BAPI just once or multiple times?
Comment : - No I am calling BAPI for only once.
3) Are you writing into a very detailed level or an aggregate level?
Comment : The combination in file used - Product , Location and Key figure Value.
4) What planning book are you writing on? Does it contain a lot of KFs?
Comment : There are couple of Key figures in the planning book.
Please let me know if you have any information on this
Thank You - Prasad. -
BAPI Performance Issue - 'BAPI_PBSRVAPS_CHANGEKEYFIGVAL'?
Hi,
I am using the following BAPI to change the Key figure value . I am using the following Export combinations .
I am not sure but still the BAPI performance issues we are facing. Is anything else we can use the steps to improve the performance of following BAPI.?
Also do need to pass more export paramters for the same ? If yes, please share the same how to use that.
CALL FUNCTION 'BAPI_PBSRVAPS_CHANGEKEYFIGVAL'
EXPORTING
PLANNINGBOOK = PLANNING_BOOK
DATA_VIEW =
SELECTION_ID =
LOGICAL_SYSTEM =
BUSINESS_SYSTEM_GROUP =
SOURCE_PARTNER =
TARGET_PARTNER =
COMMIT_CONTROL = 'E'
Appreciated your inputs regarding the same.
Thank you - Prasad.Thank you Emmanuel for the response.
Please see my comments below.
1. How much data are you passing to the BAPI? (e.g. how many combinations
Comment : - Min record size is of 6000 records in a file and more .
2) Are you calling the BAPI just once or multiple times?
Comment : - No I am calling BAPI for only once.
3) Are you writing into a very detailed level or an aggregate level?
Comment : The combination in file used - Product , Location and Key figure Value.
4) What planning book are you writing on? Does it contain a lot of KFs?
Comment : There are couple of Key figures in the planning book.
Please let me know if you have any information on this
Thank You - Prasad. -
User Lock issue when processing IDOCS
Hi Folks,
We are pushing the data into SAP using IDOCS.During this process some IDOCS are getting failed due to User Lock on shipment header.Anyone here can share their experience in dealing with User Lock issues.
Thanks,
Kiran.Kiran,
Only one can edit the document, it's standard fucntion. I think No note can resolve this. I can suggest you to run a back ground job very frequently ,which picks these status 51 IDOCs and reprocess. Report is :RBDMANi2
We can use Message class & error message number on selection screen, so that we can make sure that only those idocs which were failed due to Lock problem are taken by the job.
Reddy
Maybe you are looking for
-
Can't install Boot Camp drivers on Early 2010 MBP
Hello there, so I'm having a problem installing drivers as you can see from the title. I was trying to create a Boot Camp partition on my girlfriend's MBP. She has the 2010 early one. Now we got windows installed on there with no problem; however, we
-
How to clear "file open" dropdown list?
I have Quicktime installed on my Windows 7 system. When click the "Open File" option I get a dialog box that is a regular Windows "Open a File" box in which I can either select from the directory tree on the left or type an entry directly into the "F
-
JFileChooser working dir on a PC
I am working with jdk1.4.2 on Windows 2000. I can't seem to get JFileChooser to display any directory on opening except My Documents. here are samples of what I have tried: String workingDir = "D:\\data"; JFileChooser saveAsFile = new JFileChooser(wo
-
External activity deletion error
Hi, I am having a problem in deleting externa services associated with control key PS04. I have created PR thru CJ20N and pulled service from contract.Now BOQ contract is updated.How can I delete these service I m trying to delete PR thru me52n
-
Counter changed in 6.0.0-745 for 'Reputation Filtering'?
After upgrading to 6.0.0-745 we noticed that the amount of incoming mails for 'Stopped by Reputation Filtering' is 3 x higher then before with version 5.5.1-011. We can see the jump to the 3x higher level for the time after the upgrade. We have check