Caner.B
23rd January 2002, 15:45
Hi,
Is it possible to let a session run only by one user at the same time.
For example :
if the session is in use by a user and another user try to run it. it will give a message that the sesion is in use.
Thanks
Caner
steveauckly
23rd January 2002, 15:52
See the "application lock" functions:
appl.set
appl.get.user
appl.delete
When a user enters the session, test to see if there is a lock. If so, give the appropriate message and end.program(). If not, set a new lock, and allow the user to use the session.
Good luck,
Steve
emani80
23rd January 2002, 15:54
Yes, If you are writing code your self, you can lock the session using appl.set()and appl.delete() Commands to lock and unlock the session.
popeye
23rd January 2002, 21:20
Hi,
You could do the following.
Hope this helps.
Cheers,
Madhu
before.program:
if appl.set("tdpuro155m000", APPL.EXCL) <> 0 then
mess("tdpur.used.by", 1,strip$(tdpurodll00003.get.user.with.lock("td","pur","o155m000")))
|* This session is currently being used by %s.
exit()
endif
function extern domain tcmcs.str12 tdpurodll00003.get.user.with.lock(domain ccboi.cpac hold.cpac,
domain ccboi.cmod hold.cmod,
domain ccboi.cses hold.cses)
{
DLLUsage
*****************************************************************************
* Author : Madhu Nair
* Date : 08/20/01
* Description : This DLL function returns the user who has locked the session.
* Parameters : 1. Package
* 2. Module
* 3. Session
* Return Values : 1. Keyname
*****************************************************************************
EndDLLUsage
table tttadv997 | Maintain Application Lock Headers
table tttadv998 | Maintain Application Locks
select ttadv998.*, ttadv997.*
from ttadv998, ttadv997
where ttadv998.ocpac = :hold.cpac and
ttadv998.ocmod = :hold.cmod and
ttadv998.ocses = :hold.cses and
ttadv998._compnr = "000" and
ttadv997._index1 = {ttadv998.applid} and
ttadv997._compnr = "000"
as set with 1 rows
selectdo
return(ttadv997.user)
endselect
return("")
}
Caner.B
24th January 2002, 15:47
Thanks a lot for all your replies.
It works great!!
Caner
amarpreet
28th January 2003, 14:06
I am very new to tools development. I just tries to use this thread to restrict a session to be used by only a single person.
This works good while testing but sometimes application locks created by users are not automatically deleted even after user clos all the session & even logged out.
I have to manually delete application lock to use session again. Please find attached the script & suggest the remedy.
Thanks in advance
|******************************************************************************
|* tddel2410 0 VRC B40l c4 dil
|* Print MRP Shortage Report
|* General_User_NT
|* 2002-01-18
|******************************************************************************
|* Main table tibom010 Production BOMs, Form Type 4
|******************************************************************************
|****************************** declaration section ***************************
declaration:
table ttibom010 | Production BOMs
table ttiitm001 | Items
table ttimps520 | MPS orders
table ttimrp020 | MRP orders
table tticst001 | Items
table ttdinv001 | Inv.
table ttdinv150 | Inv.
extern domain tcitem mitm.f fixed
extern domain tcitem mitm.t fixed
extern domain tcitem bom.mitm,item,order.mitm | order.mitm(100)
extern domain tcitem bom.sitm,mitm,mfg.item,fant1.mitm,fant1.sitm
extern domain tcqana fant1.quan,bom.qty.per.set,tot.qty
extern domain tcitem sitm.f fixed
extern domain tcitem sitm.t fixed
extern domain tccitg citg.f fixed
extern domain tccitg citg.t fixed
extern domain tcemno buyr.f,sitm.buyr
extern domain tcemno buyr.t
extern domain tckitm kitm.f,type,item.type, order.type(1000)
extern domain tckitm kitm.t
extern domain tcdate date.f,date,stdt.t, order.date(1000)
extern domain tcdate date.t,today
extern domain tiqbm2 bom.qana,cst.qana,qty |, order.qty(1000)
extern domain tcyesno bom.cpha
extern domain tcorno or.no, order.no(1000)
extern domain tcosys osys, order.sys(1000)
extern domain tcqana qty.on.hand,reqd.qty, safety.stock, qty.on.order
extern domain tccuni sitm.cuni
extern domain tcsern i,j,n
extern domain tcdsca sitm.dsca
extern string next(16,10000)
extern string main.item(16,10000)
|****************************** form section **********************************
form.1:
init.form:
get.screen.defaults()
|****************************** choice section ********************************
choice.cont.process:
on.choice:
execute(print.data)
choice.print.data:
on.choice:
if rprt_open() then
read.main.table()
rprt_close()
else
choice.again()
endif
|****************************** field section *********************************
field.mitm.f:
when.field.changes:
mitm.t = mitm.f
before.zoom:
tiitm001.item = mitm.f
field.mitm.t:
before.zoom:
tiitm001.item = mitm.t
field.sitm.f:
when.field.changes:
sitm.t = sitm.f
field.kitm.f:
when.field.changes:
kitm.t = kitm.f
field.buyr.f:
when.field.changes:
buyr.t = buyr.f
field.date.f:
when.field.changes:
date.t = date.f
|****************************** function section ******************************
functions:
function read.main.table()
{
appl.set("00112334455", APPL.WRITE + APPL.WIDE)
if appl.set("tddel2410", APPL.EXCL) > 0 then
message("This session is already in use")
return
endif
today = date.num()
n=0
select tibom010.sitm:bom.sitm,tibom010.mitm:bom.mitm,tibom010.qana:bom.qana,
tibom010.cpha:bom.cpha ,tiitm001.kitm:item.type,tiitm001.dsca:sitm.dsca,tiitm001.cuni:sitm.cuni,tiitm001.buyr:sitm.buyr
from tibom010 ,tiitm001
where tibom010._index2 inrange {:sitm.f, :mitm.f} and {:sitm.t, :mitm.t}
and tibom010.sitm refers to tiitm001
and ( tibom010.exdt=0 or tibom010.exdt > date.num() )
selectdo
if item.type = tckitm.purchase then
select tibom010.mitm,tibom010.sitm,tibom010.qana,tibom010.cpha,tiitm001.dsca,tiitm001.cuni
from tibom010, tiitm001
where tibom010._index2 = {:bom.sitm}
and tibom010.mitm refers to tiitm001
and ( tibom010.exdt=0 or tibom010.exdt > date.num() )
selectdo
bom.qty.per.set = 0
order.mitm = " "
select tibom010.mitm:fant1.mitm,tibom010.sitm:fant1.sitm,tibom010.qana:fant1.quan
from tibom010
where tibom010._index2 = {:tibom010.mitm}
and tibom010.cpha = tcyesno.yes
and ( tibom010.exdt=0 or tibom010.exdt > date.num() )
selectdo
bom.qty.per.set = fant1.quan * tibom010.qana
order.mitm = fant1.mitm
select timrp020.item,timrp020.oqan
from timrp020
where timrp020._index2 = {:order.mitm}
and timrp020._index3 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timrp020.oqan * bom.qty.per.set)
endselect
select timps520.item,timps520.oqan
from timps520
where timps520._index3 = {:order.mitm}
and timps520._index2 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timps520.oqan * bom.qty.per.set)
endselect
selectempty
bom.qty.per.set = tibom010.qana
order.mitm = tibom010.mitm
select timrp020.item,timrp020.oqan
from timrp020
where timrp020._index2 = {:order.mitm}
and timrp020._index3 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timrp020.oqan * bom.qty.per.set)
endselect
select timps520.item,timps520.oqan
from timps520
where timps520._index3 = {:order.mitm}
and timps520._index2 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timps520.oqan * bom.qty.per.set)
endselect
endselect
endselect
select ticst001.subd,ticst001.issu,tcmcs003.cwar
from ticst001,tcmcs003
where ticst001._index3 = {:tibom010.sitm}
and ticst001.cwar refers to tcmcs003
and tcmcs003.nwrh=tcyesno.yes
and ( ticst001.subd > 0 or ticst001.issu > 0 )
selectdo
reqd.qty = reqd.qty + ticst001.subd + ticst001.issu
endselect
qty.on.hand = 0
safety.stock= 0
qty.on.order= 0
select tdinv001.stoc,tdinv001.sfst,tdinv001.ordr,tcmcs003.cwar
from tdinv001, tcmcs003
where tdinv001._index2 = {:tibom010.sitm}
and tdinv001.cwar refers to tcmcs003
and tcmcs003.nwrh=tcyesno.yes
selectdo
qty.on.hand = qty.on.hand + tdinv001.stoc
safety.stock= safety.stock+ tdinv001.sfst
| qty.on.order= qty.on.order+ tdinv001.ordr
endselect
select tdinv150.qana
from tdinv150
where tdinv150._index2 = {:tibom010.sitm}
and tdinv150._index1 = {tckoor.act.pur}
and tdinv150.kotr = tckotr.receipt
selectdo
qty.on.order= qty.on.order+ tdinv150.qana
endselect
mfg.item = bom.mitm
rprt_send()
reqd.qty = 0
else
n=n+1
next(1,n) = bom.sitm
main.item(1,n) = bom.mitm
endif
endselect
for i = 1 to n
mitm = next(1,i)
search()
endfor
APPL.DELETE("00112334455")
}
|654765
|APPL.DELETE("00112334455")
|***********************************************************************************
function search()
{
select tibom010.sitm:bom.sitm,tibom010.mitm:bom.mitm,tibom010.qana:bom.qana,
tibom010.cpha:bom.cpha,tiitm001.kitm:item.type,tiitm001.dsca:sitm.dsca,tiitm001.cuni:sitm.cuni,tiitm001.buyr:sitm.buyr
from tibom010 ,tiitm001
where tibom010._index1 = {:mitm}
and tibom010.sitm refers to tiitm001
and ( tibom010.exdt=0 or tibom010.exdt > date.num() )
selectdo
if item.type = tckitm.purchase then
select tibom010.mitm,tibom010.sitm,tibom010.qana,tibom010.cpha,tiitm001.dsca,tiitm001.cuni | tibom010.*,tiitm001.*
from tibom010, tiitm001
where tibom010._index2 = {:bom.sitm}
and tibom010.mitm refers to tiitm001
and ( tibom010.exdt=0 or tibom010.exdt > date.num() )
selectdo
bom.qty.per.set = 0
order.mitm = " "
select tibom010.mitm:fant1.mitm,tibom010.sitm:fant1.sitm,tibom010.qana:fant1.quan
from tibom010
where tibom010._index2 = {:tibom010.mitm}
and tibom010.cpha = tcyesno.yes
and ( tibom010.exdt=0 or tibom010.exdt > date.num() )
selectdo
bom.qty.per.set = fant1.quan * tibom010.qana
order.mitm = fant1.mitm
select timrp020.item,timrp020.oqan
from timrp020
where timrp020._index2 = {:order.mitm}
and timrp020._index3 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timrp020.oqan * bom.qty.per.set)
endselect
select timps520.item,timps520.oqan
from timps520
where timps520._index3 = {:order.mitm}
and timps520._index2 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timps520.oqan * bom.qty.per.set)
endselect
selectempty
bom.qty.per.set = tibom010.qana
order.mitm = tibom010.mitm
select timrp020.item,timrp020.oqan
from timrp020
where timrp020._index2 = {:order.mitm}
and timrp020._index3 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timrp020.oqan * bom.qty.per.set)
endselect
select timps520.item,timps520.oqan
from timps520
where timps520._index3 = {:order.mitm}
and timps520._index2 <= {:stdt.t}
selectdo
reqd.qty = reqd.qty + (timps520.oqan * bom.qty.per.set)
endselect
endselect
endselect
select ticst001.subd,ticst001.issu,tcmcs003.cwar
from ticst001,tcmcs003
where ticst001._index3 = {:tibom010.sitm}
and ( ticst001.subd > 0 or ticst001.issu > 0 )
and ticst001.cwar refers to tcmcs003
and tcmcs003.nwrh=tcyesno.yes
selectdo
reqd.qty = reqd.qty + ticst001.subd + ticst001.issu
endselect
qty.on.hand = 0
qty.on.order= 0
safety.stock= 0
select tdinv001.stoc,tdinv001.sfst,tdinv001.ordr,tcmcs003.cwar
from tdinv001, tcmcs003
where tdinv001._index2 = {:tibom010.sitm}
and tdinv001.cwar refers to tcmcs003
and tcmcs003.nwrh=tcyesno.yes
selectdo
qty.on.hand = qty.on.hand + tdinv001.stoc
safety.stock= safety.stock+ tdinv001.sfst
| qty.on.order= qty.on.order+ tdinv001.ordr
endselect
select tdinv150.qana
from tdinv150
where tdinv150._index2 = {:tibom010.sitm}
and tdinv150._index1 = {tckoor.act.pur}
and tdinv150.kotr = tckotr.receipt
selectdo
qty.on.order= qty.on.order+ tdinv150.qana
endselect
rprt_send()
reqd.qty = 0
else
n=n+1
next(1,n) = bom.sitm
endif
endselect
}
NPRao
28th January 2003, 22:08
Amarpreet,
You can please the appl.delete() function in the after.program or choice.end.program sections so that the lock is removed when the session is exited. Also you need to call that function if only the owner of the local is same as the current login which is executing the session.
Also,
This works good while testing but sometimes application locks created by users are not automatically deleted even after user clos all the session & even
BaaN standard program removes the application locks during a proper logoff process. If its an abnormal exit/loss of network connection etc, then the locks have to be manually deleted from the application locks session, ttadv9598m000.