Enque and Deque
Hi all,
Can any one explain with example how to use Enque and Deque to lock a database table?
this editable alv using this to make change in standard table.
*& Report ZALVF
REPORT ZALVF.
TYPE-POOLS *
TYPE-POOLS: SLIS.
INTERNAL TABLES/WORK AREAS/VARIABLES *
DATA: I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV,
I_INDEX TYPE STANDARD TABLE OF I WITH HEADER LINE,
W_FIELD TYPE SLIS_FIELDCAT_ALV,
P_TABLE LIKE DD02L-TABNAME,
DY_TABLE TYPE REF TO DATA,
DY_TAB TYPE REF TO DATA,
DY_LINE TYPE REF TO DATA.
FIELD-SYMBOLS *
FIELD-SYMBOLS: <DYN_TABLE> TYPE STANDARD TABLE,
<DYN_WA> TYPE ANY,
<DYN_FIELD> TYPE ANY,
<DYN_TAB_TEMP> TYPE STANDARD TABLE.
SELECTION SCREEN *
PARAMETERS: TABNAME(30) TYPE C,
LINES(100) TYPE N.
START-OF-SELECTION *
START-OF-SELECTION.
Storing table name
P_TABLE = TABNAME.
Create internal table dynamically with the stucture of table name
entered in the selection screen
CREATE DATA DY_TABLE TYPE STANDARD TABLE OF (P_TABLE).
ASSIGN DY_TABLE->* TO <DYN_TABLE>.
IF SY-SUBRC <> 0.
MESSAGE I000(Z_ZZZ_CA_MESSAGES) WITH ' No table found'.
LEAVE TO LIST-PROCESSING.
ENDIF.
Create workarea for the table
CREATE DATA DY_LINE LIKE LINE OF <DYN_TABLE>.
ASSIGN DY_LINE->* TO <DYN_WA>.
Create another temp. table
CREATE DATA DY_TAB TYPE STANDARD TABLE OF (P_TABLE).
ASSIGN DY_TAB->* TO <DYN_TAB_TEMP>.
SORT I_FIELDCAT BY COL_POS.
Select data from table
SELECT * FROM (P_TABLE)
INTO TABLE <DYN_TABLE>
UP TO LINES ROWS.
REFRESH <DYN_TAB_TEMP>.
Display report
CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_STRUCTURE_NAME = P_TABLE
I_CALLBACK_USER_COMMAND = 'USER_COMMAND'
I_CALLBACK_PF_STATUS_SET = 'SET_PF_STATUS'
TABLES
T_OUTTAB = <DYN_TABLE>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
ENDIF.
*& Form SET_PF_STATUS
Setting custom PF-Status
-->RT_EXTAB Excluding table
FORM SET_PF_STATUS USING RT_EXTAB TYPE SLIS_T_EXTAB.
SET PF-STATUS 'Z_STANDARD'.
ENDFORM. "SET_PF_STATUS
*& Form user_command
Handling custom function codes
-->R_UCOMM Function code value
-->RS_SELFIELD Info. of cursor position in ALV
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
Local data declaration
DATA: LI_TAB TYPE REF TO DATA,
L_LINE TYPE REF TO DATA.
Local field-symbols
FIELD-SYMBOLS:<L_TAB> TYPE TABLE,
<L_WA> TYPE ANY.
Create table
CREATE DATA LI_TAB TYPE STANDARD TABLE OF (P_TABLE).
ASSIGN LI_TAB->* TO <L_TAB>.
Create workarea
CREATE DATA L_LINE LIKE LINE OF <L_TAB>.
ASSIGN L_LINE->* TO <L_WA>.
CASE R_UCOMM.
When a record is selected
WHEN '&IC1'.
Read the selected record
READ TABLE <DYN_TABLE> ASSIGNING <DYN_WA> INDEX
RS_SELFIELD-TABINDEX.
IF SY-SUBRC = 0.
Store the record in an internal table
APPEND <DYN_WA> TO <L_TAB>.
Fetch the field catalog info
CALL FUNCTION 'REUSE_ALV_FIELDCATALOG_MERGE'
EXPORTING
I_PROGRAM_NAME = 'Z_DEMO_PDF_JG'
I_STRUCTURE_NAME = P_TABLE
CHANGING
CT_FIELDCAT = I_FIELDCAT
EXCEPTIONS
INCONSISTENT_INTERFACE = 1
PROGRAM_ERROR = 2
OTHERS = 3.
IF SY-SUBRC = 0.
Make all the fields input enabled except key fields
W_FIELD-INPUT = 'X'.
MODIFY I_FIELDCAT FROM W_FIELD TRANSPORTING INPUT
WHERE KEY IS INITIAL.
ENDIF.
Display the record for editing purpose
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = SY-REPID
I_STRUCTURE_NAME = P_TABLE
IT_FIELDCAT = I_FIELDCAT
I_SCREEN_START_COLUMN = 10
I_SCREEN_START_LINE = 15
I_SCREEN_END_COLUMN = 200
I_SCREEN_END_LINE = 20
TABLES
T_OUTTAB = <L_TAB>
EXCEPTIONS
PROGRAM_ERROR = 1
OTHERS = 2.
IF SY-SUBRC = 0.
Read the modified data
READ TABLE <L_TAB> INDEX 1 INTO <L_WA>.
If the record is changed then track its index no.
and populate it in an internal table for future
action
IF SY-SUBRC = 0 AND <DYN_WA> <> <L_WA>.
<DYN_WA> = <L_WA>.
I_INDEX = RS_SELFIELD-TABINDEX.
APPEND I_INDEX.
ENDIF.
ENDIF.
ENDIF.
When save button is pressed
WHEN 'SAVE'.
Sort the index table
SORT I_INDEX.
Delete all duplicate records
DELETE ADJACENT DUPLICATES FROM I_INDEX.
LOOP AT I_INDEX.
Find out the changes in the internal table
and populate these changes in another internal table
READ TABLE <DYN_TABLE> ASSIGNING <DYN_WA> INDEX I_INDEX.
IF SY-SUBRC = 0.
APPEND <DYN_WA> TO <DYN_TAB_TEMP>.
ENDIF.
ENDLOOP.
Lock the table
CALL FUNCTION 'ENQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = P_TABLE
EXCEPTIONS
FOREIGN_LOCK = 1
SYSTEM_FAILURE = 2
OTHERS = 3.
IF SY-SUBRC = 0.
Modify the database table with these changes
MODIFY (P_TABLE) FROM TABLE <DYN_TAB_TEMP>.
REFRESH <DYN_TAB_TEMP>.
Unlock the table
CALL FUNCTION 'DEQUEUE_E_TABLE'
EXPORTING
MODE_RSTABLE = 'E'
TABNAME = P_TABLE.
ENDIF.
RS_SELFIELD-REFRESH = 'X'.
WHEN 'EXIT'.
LEAVE PROGRAM.
ENDCASE.
ENDFORM. "user_command
Similar Messages
-
Use of enque and deque function in BADI MB_DOCUMENT_BADI
Hi All,
I have implemented one implementation to the BADI MB_DOCUMENT_BADI.I have to use update command in this implementation to update on ZTABLE,In order to update I need to use enqueue and dequeue function before updating the table.
My concern is that in the documentation to the BADI it specifies that Unlocking the data( DEQUEUE_ALL) will be not used in this implementation.
Please let me know Can I use enqueue and deques function for this table to this BADI.
Thanks,.
Sandeep.Hi,
I think field GOODSMVT_CODE is not table type, you mension it type table of 'BAPI2017_GM_CODE'.
Thanks,
Anmol. -
Need to Lock Planning Area by using Enque and Deque Technique.
Hi Experts,
My problem is I have to lock the planning area till the Batch program complete and I have to unlock the planning area once the batch job is completed. if any one of the user is login i.e. accessing planning book while batch job is running then batch job getting Failed.
we can check the lock in SM12
We have a custom program to send message to user to come out of the planning area but it does hit upto the mark.
we are expecting some solution to lock and unlock the plannig area till the job completes.
I was using some functional module to lock the planning area but it does not helped us. Kindly provide some help to acheive this situation
The below functional modules I used to lock the Plannning area ZDP31. I have given the input while executing the Function module PAREAID = ZDP31 (our Planning area Name)
1) ENQUEUE_/SAPAPO/E_PAREA
2) /SAPAPO/TS_DM_LOCK
3) /SAPAPO/TS_DM_UNLOCK_NEW
4) /SAPAPO/TS_DM_LOCK_UNLOCK
Please help me its in high prioity for us.Hello Balaji,
Here are the needful function modules where you can use to lock the PA by enque & deque technique..
a) ENQUEUE_READ Pass Planning Area value as GARG and PAREAID as GNAME to get information about lock entries for selected planning area. GUNAME corresponding to GNAME = /SAPAPO/DM_PAREA_LOCK and GOBJ = /SAPAPO/E_PAREA entries provides user id (s) locking the planning area displayed in the field GTARG.
b) TH_POPUP to send out popup messages to the users locking the Planning Area.
c) TH_DELETE_USER to kick off users (GUNAME) who have been locking the planning area.
I hope this helps...
Cheers !!
Regards
Rahul Chitte -
How to use ENQUE and DEQUE BAPI in Visual Composer
Hi All,
We are planning to update employee Address through Portal for that one we did one BAPI which supports ADDRESS Change of an employye, through Visual Composer we developed the application and we integrated into SAP Portal but we are not able to update our records, then we found BAPI_EMPLOYEE_ENQUE and BAPI_EMPLOYEE_DEQUE, but we don't know how to use thease BAPI's in Visual Composer i mean how to make connection between out input form and thease BAPI''s and our custom BAPI's.
If any one having this experience please let me know.
Thanks in Advance.
Thanks and Regards,
Abhi.Hi,
Nice to see your reply, we got this error in R/3 it self, when we are trying to excuting SAP Standard BAPI we are getting this error "Employee/applicant is not locked yet". I think this is bug from SAP itself, do you have any idea about this one? is there any settings we need to do in R/3 for resolving this one or else is there any data we need to maintaine for our Employee Records.
Please resolve my issue.
Thanks in Advance.
Thanks and Regards,
Abhi. -
Unable to grant privileges to enque or deque
Hi ...
I am new to AQ. I am trying to send a notification mail using JMS when something changes in the database. I am just going through a guide for the beginers. ie
http://www.oracle.com/technology/products/ias/toplink/technical/tips/DbChangeNotification/index.htm
I connected to the database as system admin.But I am unable to grant previleges to any general user. I am getting "ORA-00900 invalid SQL statement" error.
How can I set up the environment for Advanced Queuing and How can I resolve this issue?
I would appreciate any help or relevant material to accomplish my task.
Thanks and Regards,
Prince.sql i am tryin to run.
EXEC DBMS_AQADM.GRANT_SYSTEM_PRIVILEGE(privilege => 'ENQUEUE_ANY',grantee => 'dbuser',admin_option => FALSE);
Error message:
ORA - 00900: invalid sql statement.
vendor code:900
Thanks for the help,
Prince -
Timestamp differs between AQ table and Java application
We are having the folllowing situation:
A message is enqueued from a database trigger using DBMS_AQ.ENQUEUE.
A message driven bean dequeues this message immediately. The message is an instance of oracle.jms.AQjmsTextMessage.
I need to determine the time at which the message was enqueued.
To do this, I use the method "long getJMSTimestamp()" .
I expected the returned value to be almost the same as the result of new Date.getTime(), since there is no significant delay between enqueing and dequeing. However, the result of getJMSTimestamp() is about 7200000 (milliseconds) less than Date.getTime(), that is: a two hour difference.
Both methods should return the number of millis in Unix format (since 1-1-1970).
I have verified that the enqueue time stored in the queue table is the same as wall clock time, and is identical to the value of sysdate:
select enq_time,sysdate from queue_table_text_myqueue t
1 09-APR-09 02.14.52.203307 PM 9-4-2009 14:15:02
I have tried two JDK's: HotSpot and JRockit. The chance that Date.getTime() is incorrect in both implementations seems minimal.
The J2EE container is started with arguments:
-Duser.language=en -Duser.country=US.
The database server is configured with the following timezones:
SQL> select DBTIMEZONE from dual;
DBTIME
+01:00
SQL> select SESSIONTIMEZONE from dual;
SESSIONTIMEZONE
+02:00
Client and server run on different hardware. When I execute "new Date.getTime()" simultaneously on client and server the results are identical (give or take a few milliseconds) so I know the clocks are synchronized.
Any ideas?Hi Silva ,
yeah , u can access only Transparent Tables data from SAP, u cannt access data from pool/cluster tables , in such cases u can make use of BAPI/create RFC enabled FMs to give data to ur Jave Application.
Regards
Prabhu -
How to transport Enqueue and Dequeue Objects / Lock Objects / R3
Hi Gurus,
i have created two lock Objects.
I transported those objects in Q system but the table tab has no objects.
But in Dev every thing is correct.
Could you please indicate how i can get the objects correctly transported?
ThanksEasy and best approach is by getting them re transported by using transport of copy request (Type of request)
1) Get the Transport of copy request created by basis team / urself under your user.
2) Go to SE10 and highlight the request and click on include objects icon
3) Later in the pop up window select the radio button which mentions "Include free objects"
4) Then in the next screen mention the details based on the attributes of the Enque and deque object or else provide the package name and execute and in the next screen choose the concerned enque and deque objects and include them in the request.
5) Transport the Transport of copy to quality.
Also, more easiest is.
Find out the task of the request with with the enque and deque objects were created with (if more than one select all), and then include the tasks in the transport of copy and transport it to next system
If you are not able to do the above two steps then i think the object is $TMP object, kindly cross check.
Cheers -
Hello,
just a little question from a very beginner :
In the documentation called "Using XML in Oracle Database Applications, Part 4, Exchanging Business Data Among Applications" Nov. 1999, it is said that an Oracle database can enqueue and dequeue XML messages and process them.
The question is... how ?
Do I have to use the XML SQL Utiliy in order to insert XML file into a table before process it... or... can I enqueue directly an XML file, parse it and dispatch its messages via the AQ process ?
Does the XML SQL Utility is mandatory every time I want to insert or update XML data into an Oracle Database ?
Thanks in advance and bonjour chez vous !
Eric JolentAQ supports enqueing and dequeing objects. These objects can have an attribute of type CLOB containing an XML Document, as well as other interested "factored out" metadata attributes that might make sense to send along with the message.
The new 8.1.6 documentation is now up on the OTN site, so you might want to dig into the AQ docs and find out more specific details and see examples. -
Creating logical locks generates two fm
Hi Expert!,
AS far I know, When we create logical locks in se11 transaction, two Function modules get generated by the the system.
My Question is , is there any other Function module which gets generated by system?
3rd FM?Hii Mithilesh,
When u create a lock object In SE11 only 2 FMs are generated by the system that is "ENQUE" and "DEQUE" .as par i know no third FM is generated automatically.
regards,
Archana -
Two Message Servers in one System
Dear all.
I learned from http://help.sap.com/saphelp_nw04s/helpdata/en/84/54953fc405330ee10000000a114084/content.htm that one SAP system has one central instance which contains one message server. But our system seems to have two message servers.
Our system ID is "ABC". When I open the SAP Management Console, there are three children nodes under our system: One blue database icon named "ABC" and two green icons named "ABC 14" and "ABC 31". Under "ABC 14", there are nodes "ABAP WP Table" and "J2EE Processes Table". In addition, there's a "Process List" node here. The processes include "msg_server.exe", "disp+work.exe", and "igswd.exe". Under "ABC 31", there's no "ABAP WP Table" or"J2EE Processes Table". There's only one node "Process List". It contains "msg_server.exe" and "enserver.exe".
My questions are:
1. What are "ABC 14" and "ABC 31"?
2. Does "ABC 14" contains at least two instances? One is for Java and another is for ABAP?
3. What's the role of "ABC 31"? It seems to only contain enque server and message server.
4. Why are there two message servers in a single system "ABC"? One is under "ABC 14" and another is under "ABC 31".
Thanks + Best Regards
JeromeHi Sunil,
Thanks a lot for the clarification. Just have a little bit confusion left.
1. Since there're two message servers, may I say that there are two central instances? Or these message servers belong to a single central instance?
2. There's no "enserver.exe" in ABAP instance. So is the "enserver.exe" in the JAVA instance also responsible for the ABAP enque and deque operations?
Thanks + Best Regards
Jerome -
Unable to connect the queue in AQ with weblogic 10G R3
I created queues, queue tables and started the queue in Oracle 10g. In weblogic, i configured staturpclass using http://www.oracle.com/technology/products/ias/oems/files/aqjmsv2.0.zip_ and weblogic able to create the JNDI names as configured in aqjms.properties file. I havent configured any JMS Foreign server or JMS Bridge. I followed the steps in http://biemond.blogspot.com/2008/11/using-aq-in-weblogic-103.html. When i started the server i am getting following error message.
<Oct 6, 2009 1:05:39 PM IST> <Warning> <EJB> <BEA-010061> <The Message-Driven EJB: MessageQMDB is unable to connect to the JMS destination: ORAQ_X_QUEUE. The Error was: java.lang.NullPointerException>
ORAQ_X_QUEUE is JNDI name of AQ queue AQ.X_QUEUE.I am successfully able to enque and deque messges using Java client, but when i am trying to do the same with MDB i am getting above error message.
thanks
NagHi Nag,
The best WebLogic AQ JMS integration option is the built in support provided with 10.3.1/11gR1 or later, see [ Interoperating with Oracle AQ JMS | http://download.oracle.com/docs/cd/E12839_01/web.1111/e13738/aq_jms.htm#JMSAD565 ].
If for some reason you can't use WebLogic's built in support for AQ, then it would help to see the full stack trace of your NullPointerException (we almost always need the full stack trace when trying to diagnose problems). With MDBs, the full stack trace is typically found in the WebLogic server log.
Please post any future JMS related posts to the "Weblogic Server - JMS" newsgroup.
Regards,
Tom -
Different ways to improve Insert Query
Hi All,
I want to improve the performance of SQL query
"INSERT (REF_TABLE_NAME) FROM TABLE INSERT_TAB." as it is taking v.long time to execute.
Would request you to suggest some best ways to do it ASAP.
Best Regards,
Arti.Hi,
Enque and deque the table and inb/n do this.
use roll back work and commit work
and if the datat is very high then its better to do by fixed number.
Regards,
sasi -
Connections in use in data-source
Is there a way to find out how many connections are in use in the pool for a particular data source?
I've gone through the Visualizer and JMX. I can find the configuration, but no MBEANS or metrics for how many connections are actually in use?I would separate the APPS and AQ adapters out to their own connection pools.
AQ should also have a separate connection pool for enqueing and dequeing. It is probably this connection that is hogging all the threads.
I have had heaps of issues with AQ tuning in the past. If possible be on the latest MLR patch as there are many fixes for AQ and performance. At least be the latest MRL for your version, e.g. MLR#5 for 10.1.3.4.
A good property to use is, this can go on the in the bpel.xml or the connection pool directly
<property name="cacheConnections">false</property>
cheers
James -
Problem in table update.
Hi All.
I am facing one problem while updating the Ztable. The scnerio is like that we are tracking PO changes. So we created one Ztable to store PO changes. In this table we ahve Sr No field as primary key. When user press SAVE button, first maximum Sr No is selected from table and with addition of 1 new record is created with taht PO number. Now problem is that when two users save different PO at same time , them only one entry is saved in table.
Can i use enque deque or any other login I have to use for this?
Thanks.Hy PKB,
Use Enque and Deque method..
your problem will be solve.
Create a lock object via SE11->Lock object and call the ENQUEUE_EZ_<TABLE> before updating the table and DEQUEUE_EZ_<TABLE> to unlock after updating the table ...
Requesting an SAP lock
When a lock object obj is activated, two function modules (see CALL
FUNCTION) with the names ENQUEUE_obj and DEQUEUE_obj are generated.
These lock modules are used to explicitly request or release SAP locks
in an ABAP program. The SAP lock concept thus assumes a cooperative
behavior by all the programs involved. This means that access from
programs that do not call the specified modules are not protected.
The lock conditions and lock modes for the requested locks are defined
by the IMPORT parameters of the lock modules.
The lock conditions are defined by the lock parameters of the lock
object. If the lock object has only one base table, each primary key
field of the table corresponds to exactly one lock parameter. Apart from
this, a lock parameter corresponds to a group of primary key fields that
are identified by the join conditions. For each lock parameter par, the
lock modules have two IMPORT parameters with the names par and X_par.
The lock condition is defined by these parameters. If a parameter par is
not defined or if it is defined with the initial value, this means that
the corresponding key fields should be locked generically. If you really
want to lock the key field with the initial value, you must also define
the parameter X_par with the value 'X'.
To define the lock modes, the lock modules have an IMPORT parameter
MODE_tab for each base table tab, with which the lock mode for this
table can be defined. A default value must already be set for this
parameter in the definition of the lock object.
this is second procedure.
each explicit locking process assumes that all programs which perform database accesses work together in a cooperative manner. If a program does not behave in this way, i.e. it reads or changes data without locking it beforehand, this may result in a conflict with another program, even this other program has locked data correctly.
The following program fragment presents a solution to this problem:
TABLES: SFLIGHT, SBOOK.
CALL FUNCTION 'ENQUEUE_ESFLIGHT'
EXPORTING MANDT = SY-MANDT
CARRID = 'LH'
CONNID = '0400'
FLDATE = '19960516'
MODE_SFLIGHT = 'E'
EXCEPTIONS FOREIGN_LOCK = 1
OTHERS = 2.
CASE SY-SUBRC.
WHEN 1. ...
WHEN 2. ...
ENDCASE.
SELECT SINGLE * FROM SFLIGHT
WHERE
CARRID = 'LH' AND
CONNID = '0400' AND
FLDATE = '19960516'.
IF SY-SUBRC 0.
MESSAGE E...
ENDIF.
IF SFLIGHT-SEATSOCC < SFLIGHT-SEATSMAX.
SBOOK-CARRID = 'LH'.
SBOOK-CONNID = '0400'.
SBOOK-FLDATE = '19960516'.
INSERT SBOOK.
IF SY-SUBRC <> 0.
MESSAGE E...
ENDIF.
UPDATE SFLIGHT
SET
SEATSOCC = SEATSOCC + 1
WHERE
CARRID = 'LH ' AND
CONNID = '0400' AND
FLDATE = '19960516'.
ELSE.
MESSAGE E...
ENDIF.
CALL FUNCTION 'DEQUEUE_ESFLIGHT'
EXPORTING MANDT = SY-MANDT
CARRID = 'LH'
CONNID = '0400'
FLDATE = '19960516'
MODE_SFLIGHT = 'E'.
COMMIT WORK. -
Double Document number Generation from Z-tables -urgent
I have a Z table with a number range and my user performs some task and when they press save button , a number is selected from the Z table, now problem is that when two users press ave at same instant same number is assigned to both for different entries -- try to sort this urgently
Hi Joshi,
Use Locks or Enque and Deque statements. Refer the following link.
http://help.sap.com/saphelp_47x200/helpdata/en/a3/df5b1ee1bed348b198719e50af835d/frameset.htm
regards,
Chandra.
Note: Please reward if helpful.
Maybe you are looking for
-
MBP Partition error when booting Windows 7
Hi there, I'm really pulling my hair out with this problem and woud appreciate any help! I've searched everywhere and not found a solution, and it's infuriating. The Background - I am using a 2008 MBP running Mountain Lion, and have partitioned my 32
-
I want to FIRE my cable company and strem to my flatscreen, what do i need
with my VIZIO TV and BRDP i streem Netflix, my cable company is getting outragous with pricing, so I want to FIRE my cable compay and streem TV, news etc from my Mac to my TV. how do I do this????
-
How to automate the data flow to content servers?
We have ECC connected to CS. Could you help tell how to automate the data flow into the CS? Thanks a lot!
-
Supported Version of Adobe reader on Windows Server 2012 ?
witch versions of Adobe reader is supported for install on remote desktop Windows Server 2012 ? And witch version of Adobe Reader can run with protected mode enable ?
-
How to make a picture realy big, for using on a truck, without losing quality
picture size is: 939 x 1000 px 300 dpi when i want to make it bigger so i can put this picutre on the side of a truck, but now it wil lose quality. how to fix this ?