‎2012 Apr 04 10:47 AM
Dear Experts,
I have created a Z-program having several selection option and parameters. Now I want to lock the program based on the selection parameter.
For eg. there are 3 selection parameters: Plant, Company code and Material number. One user run this report for Plant 0100, company code 1000 and Material A00001. Now I want to lock the report for the above selection parameter i.e. I any user try to run the report Plant 0100, company code 1000 and Material A00001, he gets a message that the report is already locked by someone and can't be processed.
If anyone have idea how to perform this check please help.
Thanks & Best regards
Ankur Gupta
‎2012 Apr 04 10:50 AM
Use the ABAP Lock Concept. Create or Identify a lock object and use the ENQUEUE FM in the AT SELECTION-SCREEN event to lock those values, raise an error is lock fails. You can also add a DEQUEUE in the PBO (AT SELECTION-SCREEN OUTPUT) if you want the lock to occur only during excecution, leaving transaction as well as COMMIT/RIOLLBACK WORK will also release the lock.
Calling SE11, you could
- Create a Z_name structure with your parameters as fields,
- Create a EZ_name lock object using this structure, at activation it will generate 2 lock modules DEQUEUE_EZ_NAME and ENQUEUE_EZ_NAME that you will call in your report.
Regards,
Raymond
‎2012 Apr 04 10:50 AM
Use the ABAP Lock Concept. Create or Identify a lock object and use the ENQUEUE FM in the AT SELECTION-SCREEN event to lock those values, raise an error is lock fails. You can also add a DEQUEUE in the PBO (AT SELECTION-SCREEN OUTPUT) if you want the lock to occur only during excecution, leaving transaction as well as COMMIT/RIOLLBACK WORK will also release the lock.
Calling SE11, you could
- Create a Z_name structure with your parameters as fields,
- Create a EZ_name lock object using this structure, at activation it will generate 2 lock modules DEQUEUE_EZ_NAME and ENQUEUE_EZ_NAME that you will call in your report.
Regards,
Raymond
‎2012 Apr 04 11:10 AM
Hello Raymond,
Thanks for reply. It seems to be a good solution.
Can you please elaborate the code which is to be written in the program AT SELECTION-SCREEN and AT SELECTION-SCREEN OUTPUT.
Thanks a lot!!
Ankur Gupta
‎2012 Apr 04 12:15 PM
1 - create structure
Define one field for each parameter, activate
2 - Create lock object
Use the previous structure, insure all fields are checked, activate
3 - in report
Define parameter in a block
SELECTION-SCREEN BEGIN OF BLOCK b01.
PARAMETERS: p1 TYPE t1,
p2 TYPE t2,
p3 TYPE t3.
SELECTION-SCREEN END OF BLOCK b01.
At PBO release previous lock (opt)
AT SELECTION-SCREEN OUTPUT.
CALL FUNCTION 'DEQUEUE_EZTEST'
EXPORTING
field1 = p1
field2 = p2
field3 = p3
.
At PAI try to lock, if failure raise error
AT SELECTION-SCREEN ON BLOCK b01.
CALL FUNCTION 'ENQUEUE_EZTEST'
EXPORTING
field1 = p1
field2 = p2
field3 = p3
_wait = 'X'
EXCEPTIONS
OTHERS = 1.
IF sy-subrc = 1.
MESSAGE 'Error message text' TYPE 'E'.
ENDIF.
.
Regards,
Raymond
‎2012 Apr 04 12:35 PM
‎2012 Apr 04 11:20 AM