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: 

SAP Lock Concept - Wich User Locks my TCode

Former Member
0 Kudos

Hey Experts,

i am using the SAP Lock Concept in my Transaktion, but i have a problem to find out how to get the Name of the User how locks my Tcode.

I build in the Function 'ENQUEUE_EZ_SMARTFORMS',

after that i print out a Message thet the 'Tcode gets edit by another User at the moment'.

Now i want to replace 'another User ' with the User-Name of the User.

Thanks for Help

3 REPLIES 3

Former Member
0 Kudos

by standard, you will find that info in one of the sy-msgv1-4 parameters

Former Member
0 Kudos

This message was moderated.

former_member195402
Active Contributor
0 Kudos

Hi,

fm ENQUEUE_READ will give you the informations you want.

Pass th name of thge lock object to parameter GNAME, pass the lock argument to parameter GARG and pass SPACE to argument GUNAME.

Sample:

* Call custom lock object

  CALL FUNCTION 'ENQUEUE_MYLOCKOBJ'

    EXPORTING

      sase           = xv_sase

      _scope         = '3' "till the end

    EXCEPTIONS

      foreign_lock   = 1

      system_failure = 2

      OTHERS         = 3.

* Check return code

  CASE  sy-subrc.

    WHEN  0.      "lock successful

      xv_lock                 =  'X'.

    WHEN  1.      "foreign lock

      xv_uname                =  text-unk.

      CONCATENATE                sy-mandt

                                 xv_sase

                           INTO  xv_garg.

      CLEAR                      xt_enq.

      CALL FUNCTION 'ENQUEUE_READ'

        EXPORTING

          gname  = xk_gname_sase

          garg   = xv_garg

          guname = space

        TABLES

          enq    = xt_enq

        EXCEPTIONS

          OTHERS = 4.

      IF  sy-subrc           EQ  0.

        READ  TABLE              xt_enq

                           INTO  xs_enq

                          INDEX  1.

        IF  sy-subrc         EQ  0.

          xv_uname            =  xs_enq-guname.

        ENDIF.

      ENDIF.

      MESSAGE  s000(38)

                   DISPLAY LIKE  'E'

                           WITH  text-sas

                                 xv_sase

                                 text-m07

                                 xv_uname.

      EXIT.

    WHEN  OTHERS.  "unknown lock error

      MESSAGE  s000(38)

                   DISPLAY LIKE  'E'

                           WITH  text-sas

                                 xv_sase

                                 text-m04

                                 sy-subrc.

      EXIT.

  ENDCASE.

Regards,

Klaus