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

Avoid simultaneous access to a transaction/ program

Former Member
0 Likes
1,841

Hi ,

How to avoid multiple access to a transaction/program. I,e, if the transaction is running , then it should not allow running this code till the first is completed .

This should work across all the clients .

Thanks

Supriya

1 ACCEPTED SOLUTION
Read only

former_member611006
Active Participant
0 Likes
1,552

Hi,

maybe you can use the SAP Lock Concept:

http://help.sap.com/saphelp_nw04/helpdata/DE/7b/f9813712f7434be10000009b38f8cf/content.htm

Hope this helps.

Regards,

David

16 REPLIES 16
Read only

former_member611006
Active Participant
0 Likes
1,553

Hi,

maybe you can use the SAP Lock Concept:

http://help.sap.com/saphelp_nw04/helpdata/DE/7b/f9813712f7434be10000009b38f8cf/content.htm

Hope this helps.

Regards,

David

Read only

0 Likes
1,552

I think this normally works with a table .

How to use for programs and transaction ?

Read only

0 Likes
1,552

Hi,

you're right ! You can use it to lock access to all tables used in your Program.

Or you can create your own lock concept (i.e. with a Z* table with the Prog ID/User ID etc...)

Regards,

David

Read only

Former Member
0 Likes
1,552

That depends upon the purpose u are using the particular tranaction or program

if the program directly impacts the table by changing the value or inserting the value it needs to be done by a enqueue and dequeue concept (i.e., by creating a lock object based on the primary.

so according it will prevent other transaction or table or program from prevent using it

with regards

s.janagar

Read only

0 Likes
1,552

But My transaction does not modify any table.

It is just a report.

How to avoid multiple access for a transaction/program

Read only

SuhaSaha
Product and Topic Expert
Product and Topic Expert
0 Likes
1,552

Hello Supriya,

I donot think you need an additional Z-table for this. You can use the IMPORT/EXPORT statements to achieve this.

Try something like this:

START-OF-SELECTION.

  DATA:
  BEGIN OF st_tcode,
    tcode TYPE tcode,
    flag TYPE flag,
  END OF st_tcode.

  DATA:
        wa_indx  TYPE indx,
        v_flag   TYPE flag.

  IMPORT st_tcode = st_tcode
  FROM DATABASE indx(tc)
  TO wa_indx
  CLIENT sy-mandt ID sy-tcode.

  IF sy-subrc = 0.
    CHECK st_tcode-tcode = sy-tcode.

    v_flag = st_tcode-flag.
  ENDIF.

  IF v_flag IS INITIAL. "No other instance of tcode running
    st_tcode-tcode = sy-tcode.
    st_tcode-flag = 'X'.

    EXPORT st_tcode = st_tcode
    TO DATABASE indx(tc)
    FROM wa_indx
    CLIENT sy-mandt ID sy-tcode.
    
*   Proceed Further Processing
  ELSE.
* DONOT Proceed Further Processing
  ENDIF.

Hope i am clear.

BR,

Suhas

Read only

Former Member
0 Likes
1,552

Query solved

Read only

0 Likes
1,552

Suhas , thank you for your solution.

I have got d solution

Read only

0 Likes
1,552

Hi Suhas ,

The solution which you gave works fine at the first instances , But sometimes behaves vaguely .

Can you give me any other solution ?

Thanks ,

Supriya .

Read only

0 Likes
1,552

Use this code. Hope this will work.

TABLES: UINFO.
DATA: BEGIN OF COMMON PART USR.
  DATA: BEGIN OF USR_TABL OCCURS 10.
          INCLUDE STRUCTURE USRINFO.
  DATA: END OF USR_TABL.
DATA: END OF COMMON PART USR.    
call 'ThUsrInfo' id 'OPCODE' field opcode_list
      id 'TABUSR' field usr_tabl-*sys* .

U will get value which user is runnign which TCODE, if ur tcode is not exit in table usr_tabl ,go ahead else dont allow.

Read only

0 Likes
1,552

Hi,

What is opcode_list .

I tried giving value 2 , but I am not getting all the sessions which are logged in.

Also , i get no values for id 'TABUSR' field usr_tabl-sys .

I had to change it to id 'TAB' field usr_tabl-sys . ;

but still no proper result

Read only

0 Likes
1,552

SORRY ABOUT THAT.

use this.

DATA:               TH_OPCODE(1)         TYPE X,
                      myname like msxxlist-name.
CONSTANTS: OPCODE_LIST                     LIKE TH_OPCODE VALUE 2.

call 'C_SAPGPARAM' id 'NAME'  field 'rdisp/myname'   " syetem
                   id 'VALUE' field myname.

Edited by: KaushiK©Datta on Sep 3, 2009 12:32 PM

Read only

0 Likes
1,552

Hi , its still not working.

Please provide me the entire code

Read only

0 Likes
1,552

Hey I have written the same code in my system , its working fine here. Im pasting the code here, just have a look.

REPORT  ZKD_USER.

TABLES: UINFO.

DATA:  TH_OPCODE(1)         TYPE X.

DATA: BEGIN OF COMMON PART USR.
DATA: BEGIN OF USR_TABL OCCURS 10.
        INCLUDE STRUCTURE USRINFO.
DATA: END OF USR_TABL.
DATA: END OF COMMON PART USR.

CONSTANTS: OPCODE_LIST                     LIKE TH_OPCODE VALUE 2.


CALL 'ThUsrInfo' ID 'OPCODE' FIELD OPCODE_LIST
      ID 'TABUSR' FIELD USR_TABL-*SYS* .


BREAK-POINT.

Read only

0 Likes
1,552

Hi Kaushik ,

I pasted the code which you gave but no result .

Also , I am getting syntax error USRINFO not found.

I am working on sap 4.7 .

Also , the ID TABUSR'' doesnt work , I have to use 'TAB' because of which i do get 3 sessions but not all.

Is there some config to be done ?

Read only

0 Likes
1,552

Ok , that might be the problem, Im using ECC6. Can u check the program for tcode SM04? There you can find the correct code there.