evertsen
2nd July 2002, 22:56
I am trying to use appl.delete() to remove a lock created by another script (without using ttstpdellocks). I have been told that it is not working because I have not specified the same parameters as appl.write() used. One problem is I do not have source to check the parameters used by the other session but the bigger problem is I do not know how to specify parameters with appl.delete() the help file didn't aid me at all. Any help will be appreciated. BTW I am using 4c4.
alejandro
2nd July 2002, 23:33
To use this function:
long APPL.DELETE( string name(32) )
It returns:
0 : OK, lock is removed
-1 : error, lock not found
-3 : internal error
The variable name is in session ttstpdelllocks, first field.
Hope this help
evertsen
3rd July 2002, 04:12
Thanks, but that is exactly what I tried (like it says in the help file) and it returns -3.
Han Brinkman
3rd July 2002, 14:14
Please post your code, than we can probably help you out.
Han
isimeon
3rd July 2002, 15:23
I think you cannot delete application lock created by another process or user (except via the session ttstpdellocks). Try to use function appl.modify(...) or/and manipulate data in tables ttadv997 and ttadv998 in company 000.
evertsen
3rd July 2002, 18:08
| This session is designed to allow our sales order entry staff to
| delete their own app locks.
declaration:
extern domain tcmcs.str32.l app.name
extern domain tcmcs.str6 order.num
extern domain tcmcs.str8 curr.user
extern domain tcmcs.str12 app.user
long ret
long ret2
choice.cont.process:
on.choice:
curr.user = getenv$("LOGNAME")
ret2 = appl.get.user(app.name, app.user)
if ret2 = 0 then
if strip$(app.user) = strip$(curr.user) then
ret = appl.delete(app.name)
else
message("Cannot Remove! Lock belongs to %s.", app.user)
endif
else
message("Lock for order %s not found!", order.num)
endif
field.order.num:
when.field.changes:
app.name = "tdsls040" & order.num
alejandro
3rd July 2002, 18:44
I think that in your post, app.name variable is empty or full with spaces. If you do not fullfill this variable I think you will always see your message "Lock for order %s not found!"
app.name it is not a reference variable like app.user
evertsen
3rd July 2002, 19:35
I looked at my app.name variable as the cause of the error by having it print in a message and also by replacing it with it's value in the statement. I purposely created a lock for sales order 100065 then tried to remove it with appl.delete("tdsls040100065") but still received a return value of -3. It never returns the "Lock for order %s not found!" message.
isimeon
3rd July 2002, 19:35
OK.
If you insert a next line before appl.delete(..)
ret=appl.modify(app.name,old.pid,pid)
where old.pid is owner pid of application lock, pid is current pid.
Application Lock will be deleted. But, this working only when process with old.pid is still active and in current bshell. To get owner pid you have to select ttadv998 in company 000 (authorization problem!)
I think you cannot delete Application Lock with user session using appl.delete function.
A possible solution is to delete ttadv998 record, but you have to give authorization to user for the table in company 000, which is not preferable.
evertsen
3rd July 2002, 19:56
I have tried appl.modify solution but still receive the same return value from appl.delete
isimeon
3rd July 2002, 20:09
I have tried it and work fine. Remember: in the same bshell and owner pid process is still active.
This technique is usable when a child process of locking process have to delete application lock. But this is not your case.