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 T-Code

Former Member
0 Likes
1,816

Hi,

I write a ABAP report, I want to lock some t-code when users run this report.

For example lock the t-code 'migo'

Please told me How to do?

Thanks!

17 REPLIES 17
Read only

Former Member
0 Likes
1,737

<irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:53 PM

Read only

0 Likes
1,737

Hi M Prasanth ,

Maybe my question's description not clear.

I means that, I write a abap report to get the W/O order's material withdraw qty.,

I want to block MIGO, And let all user can't use MIGO to do goods issue for W/O

when this report runing.

After this report run the t-code 'MIGO' will be unblocked automatically.

Read only

0 Likes
1,737

Hi,

Use transaction SM12 Lock entries to see lock entries

Naming: The lock object name must start with EZ

Create the lock object for the required table using SE11. When you create the locl object, two function

modules will be created automatically. These two function modules named

ENQUEUE_<lock object name> and DEQUEUE_<lock object name> can be called to lock or dislock

the table.

Example: " u can create a lock object for MKPF table

Create a lock object for table MSEG called EZTESTLOCK.

When you has created the lock object, the two function modules

ENQUEUE_EZTESTLOCK

DEQUEUE_EZTESTLOCK

Will automatically be created

REPORT lockentries.

PARAMETERS:

p_mbelnr LIKE mseg-mblnr DEFAULT '4900008001',

p_mjahr LIKE mseg-mjahr DEFAULT '2001',

p_zeile LIKE mseg-zeile DEFAULT 1,

p_lock RADIOBUTTON GROUP lock,

p_unlock RADIOBUTTON GROUP lock.

START-OF-SELECTION.

IF p_lock = 'X'.

  • Lock item

CALL FUNCTION 'ENQUEUE_EZTESTLOCK'

EXPORTING

  • MODE_MSEG = 'E'

  • MANDT = SY-MANDT

mblnr = p_mbelnr

mjahr = p_mjahr

zeile = p_zeile

  • X_MBLNR = ' '

  • X_MJAHR = ' '

  • X_ZEILE = ' '

  • _SCOPE = '2'

  • _WAIT = ' '

  • _COLLECT = ' '

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3

.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

ELSEIF p_unlock = 'X'.

  • Unlock item

CALL FUNCTION 'DEQUEUE_EZTESTLOCK'

EXPORTING

  • MODE_MSEG = 'E'

  • MANDT = SY-MANDT

mblnr = p_mbelnr

mjahr = p_mjahr

zeile = p_zeile

  • X_MBLNR = ' '

  • X_MJAHR = ' '

  • X_ZEILE = ' '

  • _SCOPE = '3'

  • _SYNCHRON = ' '

  • _COLLECT = ' '

.

ENDIF.

Read only

0 Likes
1,737

There is one transaction to lock any other transactions (I think you'll be able to find it alone in the forum), but I think it's a very bad idea to programmatically lock/unlock a transaction !.

Instead, I advise you to use lock objects ([lock concept|http://help.sap.com/saphelp_nw2004s/helpdata/en/c2/2d7037ecc92a7ee10000009b38f8cf/frameset.htm] and [lock objects in data dictionary|http://help.sap.com/saphelp_nw2004s/helpdata/en/cf/21eea5446011d189700000e8322d00/frameset.htm]) in your custom program, by locking the standard lock objects used by the MIGO, so that the MIGO can't be used (though the first screen is displayed, the user won't be able to record receipts)

Read only

0 Likes
1,737

Hi TT,

I think your idea is good idea,

But whether I can use this soultion to lock the entire table MSEG one time,Not one record one time.

I try use this code is ok?

***********************************************************************

FORM LOCKDATA.

CALL FUNCTION 'ENQUEUE_EZMSEGLOCK1'

EXPORTING

MODE_MSEG = 'E'

MANDT = SY-MANDT

EXCEPTIONS

foreign_lock = 1

system_failure = 2

OTHERS = 3.

ENDFORM .

************************************************************************

How to do testing whehter MSEG be locked

Read only

Former Member
0 Likes
1,737

<irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:53 PM

Read only

Former Member
0 Likes
1,737

<irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:54 PM

Read only

Former Member
0 Likes
1,737

<irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:54 PM

Read only

0 Likes
1,737

I'd like to know why you repeat the same answer as Venu ? Even though it's not in the rules of engagement (I think it's not said because it's obvious), this is a very bad practice.

STOP POLLUTING THE FORUM PLEASE

Read only

Former Member
0 Likes
1,737

Hi Experts,

I use the below code to lock the MSEG.But I do code debug.I found that I still can use MIGO to do Goods Issue.Who can help me!

__________________________________________________________________

......

START-OF-SELECTION .

PERFORM LOCKDATA .

PERFORM SELECT_DATA. " I set a break point in this line

PERFORM UNLOCKDATA .

END-OF-SELECTION.

......

FORM LOCKDATA.

call function 'ENQUEUE_E_TABLE'

exporting

MODE_RSTABLE = 'E'

tabname = 'MSEG'

varkey = ''

exceptions

foreign_lock = 1

system_failure = 2

others = 3 .

case sy-subrc.

when 1.

message i184(bctrain) with 'Foreignlock'.

when 2.

message i184(bctrain) with 'system failure'.

when 0.

message i184(bctrain) with 'success'.

when others.

message i184(bctrain) with 'others'.

endcase.

ENDFORM .

FORM UNLOCKDATA.

CALL FUNCTION 'DEQUEUE_E_TABLE'

EXPORTING

MODE_RSTABLE = 'E'

TABNAME = 'MSEG'

VARKEY = '' .

  • mblnr = ''

  • mjahr = ''

  • zeile = '' .

ENDFORM .

Read only

0 Likes
1,737

Why do you use this function module/lock object ? You don't lock MSEG records, it has nothing to do with MIGO !

I looked at MIGO, and I was surprised that no lock object is shown in sm12 during the entry.

I don't have any good idea.

Read only

Sandra_Rossi
Active Contributor
0 Likes
1,737

>

> I write a ABAP report, I want to lock some t-code when users run this report.

> For example lock the t-code 'migo'

Could you explain what the report does?

Read only

Former Member
0 Likes
1,737

<completely_irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:55 PM

Read only

nagarajan_ramudu
Active Participant
0 Likes
1,737

<irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:56 PM

Read only

Former Member
0 Likes
1,737

<interesting_but_still_completely_irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:58 PM

Read only

Former Member
0 Likes
1,737

<half_interesting_but_double_completely_irrelevant_answer_removed_by_moderator>

Edited by: Julius Bussche on Feb 12, 2009 11:59 PM

Read only

Former Member
0 Likes
1,737

Please take note that about half the answers to your question are complete rubbish...

They appear not to have read your question properly, or (also likely) have no idea how a SAP system works but will speculate anyway...

Please rephrase what exactly your question is. MIGO is a huge transaction context.... you cannot lock the tcode (e.g. SM01 - which is generally a bad idea anyway, and represents "stupid" concepts at the highest level...)

Even the enqueue has restraints...

If you provide more information, then perhaps the choice of transaction (or an armada of peripheral transactions) is the problem?

The quality of the question is generally directly proportional to the quality of the answers.....

Cheers,

Julius