Application Development and Automation 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: 
Read only

Lock the program based on selection parameter

Former Member
0 Likes
1,717

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

1 ACCEPTED SOLUTION
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,310

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

5 REPLIES 5
Read only

RaymondGiuseppi
Active Contributor
0 Likes
1,311

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

Read only

0 Likes
1,310

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

Read only

0 Likes
1,310

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

Read only

0 Likes
1,310

 

Read only

dayakar_sama
Explorer
0 Likes
1,310

This message was moderated.