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

Need to know whether the module pool program is already running

former_member182465
Active Participant
0 Likes
1,701

Hi,

I got a scenario where module pool is not working correctly while simultaneously multiple users run that program. How can i know while code execution that the program is already opened. I dont think ABAP memory works is there any other efficient way for this please share your suggestions...

Hi abilash,

If you want to know if the application is used by another user then you can use the concept of lock objects. This will allow only one user to work in the application one at a time and other user's will not be allowed to work in it . The lock is done by enqueue and after processing Dequeue takes place.

Once the dequeue is successful then next user can work with the application.

Refer : SAP Lock Concept (SAP Library - The SAP Lock Concept (BC-CST-EQ))

Regards,

Sivaganesh

13 REPLIES 13
Read only

rosenberg_eitan
Active Contributor
0 Likes
1,656

Hi,

Lock object ?

Regards.

Read only

venkateswaran_k
Active Contributor
0 Likes
1,656

Dear Abhilash,

first of all want to know, what is going wrong when multiple users executes that program? Is it related to Database tables?  Then you may have to look for different strategy.

However, if you want to stop, then look for current users logged in and filter by who uses the tcode.  (you can get this information0).  If so then stop it by a message.

Regards,

Venkat

Read only

former_member219762
Contributor
0 Likes
1,656

Hi,

Use shared memory object to store users, and check for that users in programme.

Regards,

Sreenivas.

Read only

0 Likes
1,656

Hi,

You can check the SM12 to view the list of users working on the which transactions and programs.

Pragmatically you can use the lock objects.

Read only

nabheetscn
SAP Champion
SAP Champion
0 Likes
1,656

Simply use the concept of Lock objects.. The moment you enter a tcode to edit one record you call enqueue function module to lock that entry so that other person shall not edit it in parallel.

Read only

Former Member
0 Likes
1,656

Hi Abilash,

If your module pool program updates a DB table, and the update is not working properly - lock object is your solution.

Otherwise, when the program starts, put a flag variable in global memory (using EXPORT, or you can use a function group for this purpose). And before that, IMPORT that flag and check if it is set, if yes, don't proceed further saying 'This t-code is already being run by someone else!'.

Hope this make sense! Cheers.

Read only

sivaganesh_krishnan
Contributor
0 Likes
1,656

Hi abilash,

If you want to know if the application is used by another user then you can use the concept of lock objects. This will allow only one user to work in the application one at a time and other user's will not be allowed to work in it . The lock is done by enqueue and after processing Dequeue takes place.

Once the dequeue is successful then next user can work with the application.

Refer : SAP Lock Concept (SAP Library - The SAP Lock Concept (BC-CST-EQ))

Regards,

Sivaganesh

Read only

former_member226225
Contributor
0 Likes
1,656

Hi Abhi,

DATA : lt_seqg3 TYPE STANDARD TABLE OF seqg3,

        wa_seqg3 TYPE seqg3,

        gv_name  TYPE seqg3-gname.

gv_name  = sy-repid.

CALL FUNCTION 'ENQUEUE_READ'

  EXPORTING

    gclient                     = sy-mandt

*   gname                       = 'TRDIR'

*   GARG                        = ' '

    guname                      = '*'

*   LOCAL                       = ' '

*   FAST                        = ' '

* IMPORTING

*   NUMBER                      =

*   SUBRC                       =

   TABLES

     enq                         = lt_seqg3

  EXCEPTIONS

    communication_failure       = 1

    system_failure              = 2

    OTHERS                      = 3.

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

IF lt_seqg3[] IS NOT INITIAL.

   LOOP AT lt_seqg3 INTO wa_seqg3 WHERE garg CS gv_name.

     IF wa_seqg3 IS NOT INITIAL.

       EXIT.

     ENDIF.

   ENDLOOP.

ENDIF.

CHECK wa_seqg3 is NOT INITIAL.

WRITE : wa_seqg3-garg.

Thanks & Regards,

Raghunadh Kodali.

Read only

former_member182465
Active Participant
0 Likes
1,656

Hi Guys,

Thanks for replies. I cant use Lock objects because the transaction is of moving the Stock from one storage bin to other storage bin. Each user will have individual pull list. But the 'n' no of pull list can have a common material,storage type and storage bin.  If i keep lock objects that will effect all other users using material,storage type and storage bin.

Read only

0 Likes
1,656

Hi abilash n

You can try like this

if tcode already in use it trigger error message...

DATA : v_opcode(1) TYPE x,
        wa_tcode  TYPE usrinfo.

DATA: BEGIN OF usr_tcode OCCURS 10.
         INCLUDE STRUCTURE usrinfo.
DATA: END OF usr_tcode.

CONSTANTS: opcode_list LIKE v_opcode VALUE 2.

CALL 'ThUsrInfo' ID 'OPCODE' FIELD opcode_list

        ID 'TABUSR' FIELD usr_tcode-*sys* .


READ TABLE usr_tcode INTO wa_tcode with key tcode 'SE38'.

if wa_tcode is not INITIAL.
message : 'Already in Use' type 'E'.
endif.


break-point.

Read only

0 Likes
1,656

Then on what basis you want to prevent multiple user from executing the tcode.

Read only

0 Likes
1,656

Nabheet its by Material,storage bin,storage type. Is there any other way than Lock objects......

Read only

0 Likes
1,656

Please do as Ramesh suggested in previous post. SM04 shows us the detail who is doing what