Application Development 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: 

Unable to unlock using Dequeue function module

Former Member
0 Kudos

hi,

I have created a lock entry for a z-table, which I update using a program. When I lock - update the table - unlock using enqueue / dequeue function modules from one program, it works fine. But now the need is, I selelct and lock a particular entry (which i display in an alv grid) in the first program, which submits another, and from there i update the table, and then unlock. But in this case, the dequeue fm fails, and the lock entry in SM12 is not getting deleted. When I try to edit the same entry coming back to the first program, it gives OBJECT IS CURRENTLY LOCKED BY the same user, it throws a foreign lock exception. should unlocking this way won't work, due to a submit call to another report? Where am I going wrong?

Regards,

Sathish

Edited by: Sathish on Nov 13, 2009 8:08 AM

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor
0 Kudos

When you create a lock this lock is related to the current LUW.

The following statements create another LUW, so wont share the locks :

  • CALL TRANSACTION

  • SUBMIT REPORT

  • SUBMIT REPORT AND RETURN

Read some documentation like [SAP Transactions|http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c2a79e11d1950f0000e82de14a/frameset.htm] or [The R/3 Lock Concept |http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm] or [Transactions and Logical Units of Work|http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4b9a79e11d1950f0000e82de14a/frameset.htm]

The ABAP statements CALL TRANSACTION (start a new transaction), SUBMIT (start an executable program), and CALL FUNCTION... DESTINATION (call a function module using RFC) open a new SAP LUW. When you call a program, it always opens its own SAP LUW. However, it does not end the LUW of the SAP transaction that called it. This means that a COMMIT WORK or ROLLBACK WORK statement only applies to the SAP LUW of the called program. When the new LUW is complete, the system carries on processing the first SAP LUW

Some solutions

- convert your update report into a Function Module.

- use DEQUEUE in the caller program when called program return control.

Regards,

Raymond

9 REPLIES 9

raymond_giuseppi
Active Contributor
0 Kudos

When you create a lock this lock is related to the current LUW.

The following statements create another LUW, so wont share the locks :

  • CALL TRANSACTION

  • SUBMIT REPORT

  • SUBMIT REPORT AND RETURN

Read some documentation like [SAP Transactions|http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c2a79e11d1950f0000e82de14a/frameset.htm] or [The R/3 Lock Concept |http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4c5a79e11d1950f0000e82de14a/frameset.htm] or [Transactions and Logical Units of Work|http://help.sap.com/saphelp_nw04/helpdata/en/41/7af4b9a79e11d1950f0000e82de14a/frameset.htm]

The ABAP statements CALL TRANSACTION (start a new transaction), SUBMIT (start an executable program), and CALL FUNCTION... DESTINATION (call a function module using RFC) open a new SAP LUW. When you call a program, it always opens its own SAP LUW. However, it does not end the LUW of the SAP transaction that called it. This means that a COMMIT WORK or ROLLBACK WORK statement only applies to the SAP LUW of the called program. When the new LUW is complete, the system carries on processing the first SAP LUW

Some solutions

- convert your update report into a Function Module.

- use DEQUEUE in the caller program when called program return control.

Regards,

Raymond

0 Kudos

Hi,

" use DEQUEUE in the caller program when called program return control."

-- have tried this (by passing a variable from submit to the caller and using dequeue), but doesn't work. I hope when it returns back the control to the caller program, it starts a fresh LUW again, but wonder how the lock gets deleted when i exit the report

Regards,

Sathish

0 Kudos

A flow like

- ENQUEUE record
- SUBMIT report AND RETURN
- DEQUEUE  record

should work, perform some testing by inserting break-points before and after the submit, and execute transaction SM12 on another node.

Sample program to test :

* program 1
REPORT zpgm1.

PARAMETERS: p_matnr LIKE mara-matnr.

CALL FUNCTION 'ENQUEUE_EMMARAE'
     EXPORTING
          mode_mara      = 'E'
          mandt          = sy-mandt
          matnr          = p_matnr
          x_matnr        = ' '
          _scope         = '2'
          _wait          = ' '
          _collect       = ' '
     EXCEPTIONS
          foreign_lock   = 1
          system_failure = 2
          OTHERS         = 3.

BREAK-POINT.

SUBMIT zpgm2 AND RETURN.

BREAK-POINT.

CALL FUNCTION 'DEQUEUE_EMMARAE'
     EXPORTING
          mode_mara = 'E'
          mandt     = sy-mandt
          matnr     = p_matnr
          x_matnr   = ' '
          _scope    = '2'
          _synchron = ' '
          _collect  = ' '.

* program2
report Zpgm2.

write: 'hello'.

Regards,

Raymond

0 Kudos

Hi,

Thanks for the answer. Of course, this works, but consider my case.

first i display a basic alv list (using reuse_alv_grid_display), i enabled selection rows using box_fieldname property of fieldcatalog. the user selects a desired row and clicks on a pf-status button, which submits another report.

here i lock the corrersponding row's id using enqueue, it appears in SM12

This called report gets values of the corresponding line selected and has a selection screen, after doing some changes for the values here, when executed, it displays a alv grid (using reuse_alv_grid_display). When a button is pressed in the pf-status of the called report, it in turn submits the caller (the first report) and displays the alv (of the first one).

here i unlock the corresponding row using dequeue, but it still appears in SM12, doesn't release the lock

when the user again selects the same line, and click on the button, the cycle repeats, as the lock is already there, it triggers a foreign_lock exception and says Object currently locked by user

if i go back from the alv using back button, *i again get the first alv (this was the initial screen displayed), if i go back from here, it leaves the program and the lock is released..

where am i wrong here? is it because the base alv list is not being overwritten when the callee submits this report..if i want to overwrite, how can it be achieved? or is it an alv refresh problem? as i use reuse_alv_grid_display, i can refresh it only using form alv_command in PAI, is it the problem?

Regards,

Sathish

0 Kudos

Each time you use a SUBMIT, you create a new LUW, so there are multiple LUW executing the first program and each one in its own LUW, so with its own locks, each time you left a report its LUW is closed and locks are released, when you leave the first LUW, no locks any longer.

NB: The ALV don't create any LUW, only the SUBMIT.

Regards,

Raymond

0 Kudos

Hi Raymond,

that's just it..thank you

along the lines, when i submit back the caller (submit alv1), can't i overlay the basic list from which the callee was called? because, after submit alv1, i get alv1 grid display, from where when i press the back button, i again get the alv1 grid display (the very first one), it's not a problem, but i just want to know whether this is possible...maybe if i use cl_gui_alv_grid class for alv, will this not occur, just curious to know

anyway, thanks a lot

Regards,

Sathish

0 Kudos

I dont't think that you may SUBMIT the previous LUW, you may try to create a "driver" program that SUBMIT the report/ALV, those ALV do not submit themselves another report but leave backl to the main driver program which manages the "stacks" of call and submit another report.

Regards,

Raymond

0 Kudos

raymond.giuseppi If you could suggest some guidance for my current issue for Submit and Save of two control tables. I am new to abap coding and this program allows to save the entries to both the Control tables, however after I click on SAVE, It throws out of the Transaction. Your help would be greatly appreciated.

I am using the code:-
FORM PROGRAM_AFTER_SAVE.


SUBMIT zProg2 "new program version
USING SELECTION-SET 'ZVar_ALL' "variant to be used
AND RETURN. "open a new SAP LUW for the program

* To read parameters from ZCONTROL1 to ZCONTROL2
SUBMIT ZPERIOD_SET.
RETURN. "open a new SAP LUW for the program
ENDFORM.

Thanks in advance!

Former Member
0 Kudos

After the submit command, when the next line of your program is getting executed call the FM "DEQUEUE_ALL"

This will solve your problem temporarily.