I assume that the SUB.LOCKED.SOH.RO is called to do the lock and then
returns.

The problem is that you open the file in this routine to do the locking
against.  Once this subroutine ends that file handle will go out of scope
(it was defined local to this subroutine) and the file is closed.  That
releases the lock.

The best way would be to pass in an open file handle.  If that is not
possible for some reason then open the file to a variable defined in named
common and test to see if it is already open using FILEINFO() before
attempting to do the open.

such as:

COMMON /MY.FILE.HANDLES/ F.THIS.FILE

IF FILEINFO(F.THIS.FILE,0) = 0 THEN
    OPEN .....
END


I would prefer passing in the open file handle myself if possible.  Named
common is very useful, but care needs to be taken in it's use.  For example
the common memory defined is associated to the process and not the account.
Therefore if you logto another account without first exiting U2 the file
handle would still be open, BUT pointed at the file in the account where it
was opened.   You would need to have logic in the logins to test for this
or add additional checks (using FILEINFO again for the path where the file
is located)

Rich Taylor | Senior Programmer/Analyst| VERTIS
250 W. Pratt Street | Baltimore, MD 21201
P 410.361.8688 | F 410.454.8392
[EMAIL PROTECTED] | http://www.vertisinc.com

Vertis is the premier provider of targeted advertising, media, and
marketing services that drive consumers to marketers more effectively.

"The more they complicate the plumbing
  the easier it is to stop up the drain"

- Montgomery Scott NCC-1701



                                                                           
             "Brutzman, Bill"                                              
             <[EMAIL PROTECTED]                                             
             ft.com>                                                    To 
             Sent by:                  "'[email protected]'"    
             [EMAIL PROTECTED]         <[email protected]>      
             stserver.u2ug.org                                          cc 
                                                                           
                                                                   Subject 
             05/07/2008 12:02          [U2] Record Locking Problems        
             PM                                                            
                                                                           
                                                                           
             Please respond to                                             
             [EMAIL PROTECTED]                                             
                er.u2ug.org                                                
                                                                           
                                                                           




I am trying to make sure that if one Customer.Service rep is updating a
Sales Order, then the other Cust.Svc rep is
blocked from accessing the same record.

The following code will indicates that the record is locked but when the
2nd
user goes in (in an independent session), the second user gets in no
problem.

Since it does not seem to do what I think that it should, [1] I am
wondering
if I am missing something.  [2] I am inclined to create a file to handle
this (brute force) with multivalues for user, port, time, date, program,
file, record.

Comments would be appreciated.

--Bill



  SUBROUTINE SUB.LOCK.SOH.R0 ( Record.ID, Error.Code )

  prompt ''

  open 'SOH' to F.This.File  else  gosub  Error.Opening.File

  gosub Lock.And.Hold

  go    The.End

*---------------------------------------------------------------------------

--
*---------------------------------------------------------------------------

--
Lock.And.Hold:

  Lock.Test = recordlocked (F.This.File, Record.ID)

 crt '**11 Lock.Test ' : Lock.Test : '  [<] '
 input Ans

  begin case
        case Lock.Test =  0  ;  recordlocku F.This.File, Record.ID
        case 1               ;  gosub Error.Record.Locked
  end   case

 Lock.Test = recordlocked (F.This.File, Record.ID)

 crt '**12 Lock.Test ' : Lock.Test : '  [<] '
 input Ans

return

*---------------------------------------------------------------------------

---
Error.Record.Locked:

  Lock.Test = recordlocked (F.This.File, Record.ID)

  crt '**13 Lock.Test ' : Lock.Test : '  [<] '
  input Ans

  Error.Code = 'E'

  crt @(-1)
  crt @(-5)

  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt '                                                    ' : @(-6)
  crt
  crt ' ___________________________                          '
  crt ' \                          \                         '
  crt '  \   Error, Record Locked   \                        '
  crt '   \__________________________\    Try Later          '
  crt '                                                      '
  crt '                                                      '

  crt '                                              [X]  '
  crt '                                               '   :

  input Ans, 1
        Ans  = upcase(Ans)

  begin case
        case Ans = 'X'  ;  null
             case 1          ;  go Error.Record.Locked
  end   case

return

*---------------------------------------------------------------------------

---
Error.Opening.File:

  crt @(-1)
  crt @(-5)

  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt
  crt '      Big Problem...                                ' : @(-6)
  crt
  crt ' _________________________                          '
  crt ' \                        \      SOH                '
  crt '  \   Error Opening File   \                        '
  crt '   \________________________\    Contact HK.IT      '
  crt '                                               [X]  '
  crt '                                                '   :

  input Ans, 1
        Ans  = upcase(Ans)

  begin case
        case Ans = 'X'  ;  null
             case 1          ;  go Error.Opening.File
  end   case

return to The.End

*---------------------------------------------------------------------------

---
The.End:

  RETURN
  END
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to