I'm on digest, but here's an example of named common which we use
extensively supporting many many concurrent users (makes the systems fly
without all
that open file overhead, imho).  Hpux / UniData, btw.

001: *INCLUDE EX.NAMED.COMMON
002: * EX named common and file open routine
003: *
004:
*=======================================================================
==
005: * WARNING
006: *   If you are making changes here, please review all programs that
007: *   include this common block and recompile / catalog them as
necessary.
008:
*=======================================================================
==
009: *
010:
*-----------------------------------------------------------------------
--
011: *  NOTE: THE ex.all.files.opened Var MUST be the first COMMON
012: COMMON /EXAMPLE/ ex.all.files.opened
013:
*-----------------------------------------------------------------------
--
014: *
015: COMMON /EXAMPLE/ F.CUSTOMER.FILE
016: COMMON /EXAMPLE/ F.CUSTOMER.XREF
017: COMMON /EXAMPLE/ F.ACCTS.RECV
018: COMMON /EXAMPLE/ F.INVOICES
019: COMMON /EXAMPLE/ F.BRANCH.FILE
020: COMMON /EXAMPLE/ F.BRANCH.XREF
021: COMMON /EXAMPLE/ F.CASH.DRAWER
022: COMMON /EXAMPLE/ F.CASH.SALE.FILE
023: COMMON /EXAMPLE/ F.CREDIT.FILE
024: *
025:
*=======================================================================
==
026: * open.files
027:
*=======================================================================
==
028: *
029:
*-----------------------------------------------------------------------
--
030: * This Section Of Code Must Always Remain At The End Of The
Include. This
031: * Was Added Here To Avoid Having To Check For Open Files For Any
Program
032: * That Requires This Named Common.
033:
*-----------------------------------------------------------------------
--
034: *
035: * If EX Files Are Not Opened
036: IF UNASSIGNED(ex.all.files.opened) OR NOT(ex.all.files.opened) THEN
037:   *
038:   * Set Opened Flag Assuming Success
039:   ex.all.files.opened=1; ERR=''
040:   *
041:   * Call Open Files Routine
042:   CALL EX.OPEN.ALL.FILES(ERR)
043:   *
044:   * If File Open Failed
045:   IF ERR # "" THEN
046:     *
047:     * Display Error Message
048:     INPUTERR "Contact Support. The following EX file(s) could not
be opened
:"; CRT
049:     *
050:     * Display Filenames That Were Not Opened
051:     MAX = DCOUNT(ERR,@AM)
052:     FOR X = 1 TO MAX
053:       CRT X'R%2. ':ERR<X>
054:     NEXT X
055:     *
056:     * Get Response (Let Them See Errors)
057:     PROMPT ""
058:     CRT "Press <RTN> ":
059:     INPUT AFT,1
060:     *
061:     * Flag Attempt Unsuccessful
062:     ex.all.files.opened=0
063:     *
064:     * Bailout
065:     STOP
066:   END
067: END
Bottom.

001: SUBROUTINE EX.OPEN.ALL.FILES(ERR)
002: * Put the opening of EX files in one place
003: *
004: ************************** Program Description
**************************
005: * Put the opening of EX files in one place
006:
************************************************************************
**
007: *
008: $INCLUDE EX.NAMED.COMMON
009: *
010: ERR = ''
011: *
012:
*-----------------------------------------------------------------------
--
013: * Open files
014:
*-----------------------------------------------------------------------
--
015: *
016: OPEN "CUSTOMER.FILE"   TO F.CUSTOMER.FILE   ELSE ERR<-1> =
"CUSTOMER.FILE"
017: OPEN "CUSTOMER.XREF"   TO F.CUSTOMER.XREF   ELSE ERR<-1> =
"CUSTOMER.XREF"
018: OPEN "ACCTS.RECV"      TO F.ACCTS.RECV      ELSE ERR<-1> =
"ACCTS.RECV"
019: OPEN "INVOICES"        TO F.INVOICES        ELSE ERR<-1> =
"INVOICES"
020: OPEN "BRANCH.FILE"     TO F.BRANCH.FILE     ELSE ERR<-1> =
"BRANCH.FILE"
021: OPEN "BRANCH.XREF"     TO F.BRANCH.XREF     ELSE ERR<-1> =
"BRANCH.XREF"
022: OPEN "CASH.DRAWER"     TO F.CASH.DRAWER     ELSE ERR<-1> =
"CASH.DRAWER"
023: OPEN "CASH.SALE.FILE"  TO F.CASH.SALE.FILE  ELSE ERR<-1> =
"CASH.SALE.FILE"
024: OPEN "CREDIT.FILE"     TO F.CREDIT.FILE     ELSE ERR<-1> =
"CREDIT.FILE"
025: *
026: RETURN
Bottom.

If you have multiple accounts that users can hop around to, put a line
in your VOC login that will remove the named common block in each
account such as
DELETECOMMON "EXAMPLE" or if you use many named common blocks, as we do,
create a separate paragraph or proc that does it to all of them and put
that in each account's VOC login.  Now all programs and subroutines that
use these files can have the 'EX.NAMED.COMMON" included at the top and
the file
handles will stay available (opened) throughout their login session.

Hope this helps!

Shaun Ferguson
Sr. Program Analyst
Ferguson Enterprises, Inc.
-------
u2-users mailing list
[email protected]
To unsubscribe please visit http://listserver.u2ug.org/

Reply via email to